cc-haha/desktop/sidecars/cli-launcher.ts
程序员阿江(Relakkes) f9c42c3b40 feat: Tauri desktop app with sidecar, brand identity, and CORS fix
- Add Tauri sidecar architecture: Rust shell spawns claude-server binary,
  dynamic port allocation, health-check wait loop, graceful shutdown
- Fix CORS middleware to accept `tauri://localhost` and `https://tauri.localhost`
  origins from Tauri WebView, and add CORS headers to /health endpoint
- Enable native macOS window decorations (traffic lights) with Overlay title bar,
  add data-tauri-drag-region on sidebar for window dragging
- Conditionally apply desktop-only padding (44px for traffic lights) vs web (12px)
- Generate brand identity: light-background app icon, horizontal logo, full icon
  set (icns/ico/png) for Tauri bundle
- Add brand mark + GitHub link in sidebar, replace mascot SVG with app icon
  in EmptySession page
- Update README (zh/en) and docs hero image with new branding
- Add sidecar build scripts and launcher entry points
- Gitignore Rust target/, Tauri gen/, and brand-assets candidates

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 16:07:38 +08:00

36 lines
1014 B
TypeScript

import path from 'node:path'
import { pathToFileURL } from 'node:url'
const { appRoot, args } = parseLauncherArgs()
process.env.CLAUDE_APP_ROOT = appRoot
process.env.CALLER_DIR ||= process.cwd()
process.argv = [process.argv[0]!, process.argv[1]!, ...args]
const preloadEntrypoint = pathToFileURL(path.join(appRoot, 'preload.ts')).href
const cliEntrypoint = pathToFileURL(path.join(appRoot, 'src/entrypoints/cli.tsx')).href
await import(preloadEntrypoint)
await import(cliEntrypoint)
function parseLauncherArgs() {
const rawArgs = process.argv.slice(2)
const nextArgs: string[] = []
let appRoot: string | null = process.env.CLAUDE_APP_ROOT ?? null
for (let index = 0; index < rawArgs.length; index++) {
const arg = rawArgs[index]
if (arg === '--app-root') {
appRoot = rawArgs[index + 1] ?? null
index += 1
continue
}
nextArgs.push(arg)
}
if (!appRoot) {
throw new Error('Missing --app-root for claude-cli sidecar')
}
return { appRoot, args: nextArgs }
}