add 6.1构建镜像原则

This commit is contained in:
seahi 2025-11-19 12:41:53 +08:00
parent 6e348e7ffb
commit 540f33cc30
3 changed files with 144 additions and 0 deletions

View File

@ -0,0 +1,77 @@
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Development Commands
### Frontend Development
- `pnpm dev` - Start development mode with hot reload
- `pnpm build` - Build the application for production
- `pnpm typecheck` - Run TypeScript type checking
- `pnpm format` - Format code with Prettier
- `pnpm format:check` - Check code formatting without making changes
### Backend Development (Rust)
- `cd src-tauri && cargo fmt` - Format Rust code
- `cd src-tauri && cargo clippy` - Run Rust linter/analyzer
- `cd src-tauri && cargo test` - Run Rust tests
### Build Commands
- `pnpm tauri build` - Build production application bundle
- `pnpm tauri build --debug` - Build debug version
## Architecture Overview
This is a **Tauri 2.0 desktop application** that manages Claude Code and Codex provider configurations. The application uses a hybrid architecture:
### Frontend (React + TypeScript)
- **Location**: `src/` directory
- **Framework**: React 18 with TypeScript, Vite build system, TailwindCSS 4.x
- **Key Components**:
- `App.tsx` - Main application component with routing logic
- `components/` - UI components including modals, forms, and provider management
- `lib/tauri-api.ts` - Centralized API layer for all Tauri command calls
- `types.ts` - TypeScript type definitions for Provider, Settings, etc.
### Backend (Rust)
- **Location**: `src-tauri/src/` directory
- **Key Modules**:
- `lib.rs` - Main entry point, tray menu system, and application setup
- `commands.rs` - Tauri command handlers (API endpoints)
- `config.rs` - Configuration file management (reads/writes JSON configs)
- `provider.rs` - Provider management logic and switching operations
- `store.rs` - Application state management with Mutex protection
- `migration.rs` - Handles migration from legacy configurations
- `vscode.rs` - VS Code integration for automatic config sync
### Data Flow Architecture
The application follows a **Single Source of Truth (SSOT)** pattern:
1. **Centralized Config**: All provider data stored in `~/.cc-switch/config.json`
2. **Live Config Files**:
- Claude Code: `~/.claude/settings.json`
- Codex: `~/.codex/auth.json` + `~/.codex/config.toml`
3. **Switching Process**: Copy from centralized config → live config files
4. **Atomic Operations**: Uses atomic writes with rollback for configuration safety
### System Integration
- **System Tray**: Dynamic menus that reflect current provider states
- **VS Code Integration**: Automatic sync with VS Code Codex plugin settings
- **Cross-Platform**: Windows (MSI installer), macOS (app bundle), Linux (deb/AppImage)
- **Updates**: Built-in updater system for automatic application updates
### State Management
- **Frontend**: React hooks and context for UI state
- **Backend**: `AppState` struct with Mutex-protected shared state
- **IPC**: Tauri commands for frontend-backend communication
- **Events**: Event system for real-time updates (provider switching, etc.)
## Project Structure Notes
- Configuration presets are defined in `src/config/providerPresets.ts` and `src/config/codexProviderPresets.ts`
- The application supports both portable and installed modes
- Icons and assets are stored in `src-tauri/icons/` with platform-specific variants
- The build system uses Vite with React plugin and TailwindCSS integration

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2025 Jason Young
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,46 @@
{
"name": "cc-switch",
"version": "3.3.1",
"description": "Claude Code & Codex 供应商切换工具",
"scripts": {
"dev": "pnpm tauri dev",
"build": "pnpm tauri build",
"tauri": "tauri",
"dev:renderer": "vite",
"build:renderer": "vite build",
"typecheck": "tsc --noEmit",
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,css,json}\"",
"format:check": "prettier --check \"src/**/*.{js,jsx,ts,tsx,css,json}\""
},
"keywords": [],
"author": "Jason Young",
"license": "MIT",
"devDependencies": {
"@tauri-apps/cli": "^2.8.0",
"@types/node": "^20.0.0",
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.0",
"@vitejs/plugin-react": "^4.2.0",
"prettier": "^3.6.2",
"typescript": "^5.3.0",
"vite": "^5.0.0"
},
"dependencies": {
"@codemirror/lang-json": "^6.0.2",
"@codemirror/lint": "^6.8.5",
"@codemirror/state": "^6.5.2",
"@codemirror/theme-one-dark": "^6.1.3",
"@codemirror/view": "^6.38.2",
"@tailwindcss/vite": "^4.1.13",
"@tauri-apps/api": "^2.8.0",
"@tauri-apps/plugin-dialog": "^2.4.0",
"@tauri-apps/plugin-process": "^2.0.0",
"@tauri-apps/plugin-updater": "^2.0.0",
"codemirror": "^6.0.2",
"jsonc-parser": "^3.2.1",
"lucide-react": "^0.542.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tailwindcss": "^4.1.13"
}
}