# Codex_ClaudeCode中转API切换 **Repository Path**: elvist/cc-switch ## Basic Information - **Project Name**: Codex_ClaudeCode中转API切换 - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-06-08 - **Last Updated**: 2026-06-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # LinwangOS CC Switch LinwangOS CC Switch 是一个基于 Tauri 的桌面工具,用来管理 Claude Code 和 Codex 的中转 API 配置。应用只面向 macOS 和 Windows,界面文案为中文。 ## 功能 - 保存多组 Claude Code / Codex API 配置。 - 一键启用某个配置。 - 启用前自动备份已有配置文件。 - 只修改目标 CLI 配置中的必要字段,保留其他配置。 - 支持覆盖默认配置路径。 ## 默认写入路径 Claude Code: - `~/.claude/settings.json` Codex: - `~/.codex/auth.json` - `~/.codex/config.toml` Windows 使用 `%USERPROFILE%` 下的相同相对目录。 ## 开发 需要先安装 Node.js、npm 和 Rust 工具链。 ```bash npm install npm run tauri dev ``` ## 打包 需要先安装 Node.js、npm、Rust 工具链,并在打包前安装依赖: ```bash npm ci ``` Tauri 会在打包前自动执行 `npm run build`,产物版本号来自 `src-tauri/tauri.conf.json`。 ### macOS 打包 当前 macOS 配置会生成 `.app` 和 `.dmg`,最低系统版本为 macOS 10.15。 在当前 Mac 架构上打包: ```bash npm run tauri build ``` 只打 Apple Silicon 版本: ```bash rustup target add aarch64-apple-darwin npm run tauri build -- --target aarch64-apple-darwin ``` 只打 Intel Mac 版本: ```bash rustup target add x86_64-apple-darwin npm run tauri build -- --target x86_64-apple-darwin ``` 打通用包,同时支持 Apple Silicon 和 Intel Mac: ```bash rustup target add aarch64-apple-darwin x86_64-apple-darwin npm run tauri build -- --target universal-apple-darwin ``` 对外分发 macOS `.dmg` 时,每次打包都要对本次生成的 `.app` 和 `.dmg` 重新签名。只要重新构建、修改文件、替换资源或改版本号,旧签名都不能复用。让其他用户正常打开还需要 Apple notarization 公证;只签名但未公证时,Gatekeeper 仍可能拦截。 使用已安装到 Keychain 的 Developer ID Application 证书签名: ```bash security find-identity -v -p codesigning export APPLE_SIGNING_IDENTITY="Developer ID Application: Huizhou CarNetVC Technology Co. LTD (P6QGVV3468)" export APPLE_TEAM_ID="P6QGVV3468" npm run tauri build -- --target universal-apple-darwin ``` 如果证书还没有导入 Keychain,先导入 `.p12`: ```bash security import /path/to/DeveloperIDApplication.p12 \ -k ~/Library/Keychains/login.keychain-db \ -P "p12导出密码" \ -T /usr/bin/codesign ``` 签名并使用 Apple ID app-specific password 做公证: ```bash export APPLE_SIGNING_IDENTITY="Developer ID Application: Huizhou CarNetVC Technology Co. LTD (P6QGVV3468)" export APPLE_TEAM_ID="P6QGVV3468" export APPLE_ID="Apple ID 邮箱" export APPLE_PASSWORD="Apple ID app-specific password" npm run tauri build -- --target universal-apple-darwin ``` 也可以用 App Store Connect API Key 做公证: ```bash export APPLE_SIGNING_IDENTITY="Developer ID Application: Huizhou CarNetVC Technology Co. LTD (P6QGVV3468)" export APPLE_TEAM_ID="P6QGVV3468" export APPLE_API_KEY="Key ID" export APPLE_API_ISSUER="Issuer ID" export APPLE_API_KEY_PATH="/absolute/path/AuthKey_KEYID.p8" npm run tauri build -- --target universal-apple-darwin ``` macOS 产物路径: ```text src-tauri/target/release/bundle/macos/*.app src-tauri/target/release/bundle/dmg/*.dmg ``` 验证 macOS 可执行文件架构: ```bash lipo -info "src-tauri/target/release/bundle/macos/LinwangOS CC Switch.app/Contents/MacOS/cc-switch" ``` 验证签名和公证状态: ```bash codesign -dv --verbose=4 "src-tauri/target/universal-apple-darwin/release/bundle/macos/LinwangOS CC Switch.app" spctl -a -vvv -t install "src-tauri/target/universal-apple-darwin/release/bundle/dmg/LinwangOS CC Switch_0.1.0_universal.dmg" ``` 正式分发希望看到 `Authority=Developer ID Application: ...`、`TeamIdentifier=P6QGVV3468`,以及 `source=Notarized Developer ID`。如果看到 `source=Unnotarized Developer ID`,说明已经签名但还没有公证。 ### Windows 打包 在 Windows 上打包推荐使用原生 Windows 环境。当前 Windows 配置会生成 NSIS `.exe` 安装包和 `.msi` 安装包。 ```powershell npm ci npm run tauri build ``` Windows 产物路径: ```text src-tauri\target\release\bundle\nsis\*.exe src-tauri\target\release\bundle\msi\*.msi ``` 只打 NSIS `.exe`: ```powershell npm run tauri build -- --bundles nsis ``` 只打 `.msi`: ```powershell npm run tauri build -- --bundles msi ``` ### 在 macOS 上交叉打 Windows `.exe` macOS 上交叉编译 Windows 包时建议只打 NSIS `.exe`。`.msi` 需要 Windows 原生环境。 第一次需要安装工具链: ```bash brew install makensis llvm rustup target add x86_64-pc-windows-msvc cargo install --locked cargo-xwin ``` 打 Windows x64 NSIS `.exe`: ```bash PATH="/opt/homebrew/opt/llvm/bin:$PATH" \ npm run tauri build -- \ --runner cargo-xwin \ --target x86_64-pc-windows-msvc \ --config src-tauri/tauri.windows.conf.json \ --config '{"bundle":{"targets":["nsis"]}}' ``` 交叉编译产物路径: ```text src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis/*.exe ``` 验证 Windows 可执行文件是否为 GUI 程序: ```bash PATH="/opt/homebrew/opt/llvm/bin:$PATH" \ llvm-readobj --file-headers src-tauri/target/x86_64-pc-windows-msvc/release/cc-switch.exe | rg "Subsystem" ``` 应该看到 `IMAGE_SUBSYSTEM_WINDOWS_GUI`。如果看到 `IMAGE_SUBSYSTEM_WINDOWS_CUI`,Windows 双击运行时会弹出终端窗口。 ### 签名说明 未签名的 Windows 安装包可能触发 SmartScreen 提示。macOS 对外分发必须使用 Developer ID Application 证书签名并完成 notarization 公证;仅 ad-hoc 签名或只签名未公证都可能被 Gatekeeper 拦截。 ## 验证 ```bash npm run build cd src-tauri && cargo test ``` `npm run build` 检查前端类型并生成前端产物。`cargo test` 检查 Rust 配置写入逻辑。