feat(icons): update application icon with new colorful radial design

Replace all platform-specific icon files with new radial burst design featuring teal, orange, and yellow gradients. Updated icons include:
- PNG variants for all required sizes (32x32 to 1024x1024)
- macOS ICNS bundle with all resolutions
- Windows Square logo variants for modern app packaging
This commit is contained in:
Jason
2025-08-26 22:57:57 +08:00
parent dcf49cc094
commit adee37ab66
18 changed files with 0 additions and 126 deletions

View File

@@ -1,126 +0,0 @@
# CC SwitchElectron → Tauri代码走查与优化建议
- 目的记录此次针对前后端React/TypeScript + Tauri/Rust的全面走查结论与可落地优化点。
- 方法:从项目结构、主进程逻辑、前端状态与交互、持久化与文件操作、构建与配置一致性等维度逐项审查,输出问题清单与具体改动建议。
## 逻辑正确性
- 自动导入 default 的重复路径风险:
- 现状Rust `setup` 内自动导入,前端在供应商为空时也会调用 `import_default_config`;若两端先后成功,可能对同一 `id: "default"` 重复写入(虽为覆写但无必要)。
- 建议:`import_default_config` 命令中先检查 `providers` 是否已有 `default`,存在则直接 `Ok(true)` 返回。
- 配置路径显示可能误导:
- 现状:前端用 `getClaudeCodeConfigPath` 显示“配置文件位置”,即使文件不存在也显示候选路径。
- 建议:用 `getClaudeConfigStatus`(含 `exists`)替换,并在 UI 显示“未创建,切换或保存时自动创建”。
- 打开外链健壮性:
- 现状:`open_external` 对缺少协议的 URL`example.com`)可能失败。
- 建议Rust 端规范化,未以 `http://`/`https://` 开头则自动补 `https://`
- 复制主配置前的目录兜底:
- 现状:`switch_provider` 复制到主配置文件前未确保父目录存在(大多已存在,但存在边界风险)。
- 建议:在复制前创建 `settings_path.parent()` 目录。
## 类型与健壮性
- 定时器类型:
- 现状:`useRef<NodeJS.Timeout | null>`;在浏览器环境 `setTimeout` 返回 `number`,类型不一致。
- 建议:改为 `useRef<ReturnType<typeof setTimeout> | null>` 并统一 `clearTimeout`
- Provider 配置最小校验:
- 现状:仅校验是否为合法 JSON。
- 建议:前端提交前检查 `env.ANTHROPIC_BASE_URL``env.ANTHROPIC_AUTH_TOKEN` 等关键字段类型Rust 端 `add/update_provider` 可再做一层基础校验,返回友好错误。
- 供应商文件名清洗:
- 现状:仅替换非法字符并小写化。
- 建议:
- 空白替换为 `-`,连续 `-` 合并为单个。
- 过长名称截断,降低跨平台文件系统问题概率。
## 用户体验
- “打开官网”语义与失败反馈:
- 现状:`<a href="#" onClick>` 伪链接;失败只 `console.error`
- 建议:使用按钮或 `role="button"`,失败时显示通知(沿用全局浮动通知组件)。
- 通知淡出时长硬编码:
- 现状JS 用 `300ms` 与 CSS 动画强绑定。
- 建议:提取为常量或用动画结束事件,避免样式变更导致时间不一致。
- 自动填充官网地址:
- 现状:`extractWebsiteUrl` 仅在匹配 `https://api.` 时去前缀,策略合理。
- 建议:保留现状,并在 UI 旁提示“自动推断,可手动修改”。
## 前端结构与可维护性
- 自动导入策略统一:
- 现状Rust 与前端均可能触发默认导入。
- 建议:前端仅展示“导入当前 Claude Code 配置为 default”的按钮或保留静默导入但配一次性提示避免重复路径与认知负担。
- 预设与 API Key 注入:
- 现状:选择预设后,输入 Key 会实时写入 `settingsConfig`
- 建议在保存时再进行一次注入校验UI 加只读提示“保存时写入”,避免误解已永久保存。
- 打开配置目录按钮文案:
- 现状:固定为“打开”。
- 建议:依据 `exists` 显示“打开配置目录”或“创建并打开配置目录”。
## Rust 侧结构与持久化
- 错误上下文:
- 现状:大多数错误已包含路径信息。
- 建议:保持现状,确保关键 I/O 错误信息包含“目标路径 + 具体原因”。
- 锁粒度:
- 现状:命令中修改后释放锁再保存,合理。
- 建议:保持现状。
- 日志:
- 现状:`tauri-plugin-log` 仅在 debug 下启用。
- 建议release 也输出 Warn 级别到 `~/.cc-switch/app.log`,便于用户反馈问题。
## 配置与构建
- 版本一致性:
- 现状:`package.json` 版本 `2.0.3``src-tauri/tauri.conf.json``3.0.0-beta.1`
- 建议:统一版本号,避免混淆。
- 依赖清理:
- 现状:`@tauri-apps/plugin-shell` 未被使用。
- 建议:移除无用依赖,保持最小化。
- 产物目录:
- 现状:`dist/` 存在,本仓库 `.gitignore` 已忽略。
- 建议:保持忽略,避免误提交产物。
## 建议的具体改动(示例)
- 防重导入 default
- 文件:`src-tauri/src/commands.rs`
- 位置:`import_default_config` 内加锁后
- 变更:若 `manager.providers.contains_key("default")` 则直接返回 `Ok(true)`
- 复制主配置前确保目录存在:
- 文件:`src-tauri/src/provider.rs`
- 位置:`switch_provider``copy_file`
- 变更:`create_dir_all(settings_path.parent())` 兜底。
- 规范化外链 URL
- 文件:`src-tauri/src/commands.rs`
- 位置:`open_external`
- 变更:非 `http(s)://` 开头自动补 `https://`
- 配置路径展示基于存在性:
- 文件:`src/App.tsx`
- 位置:配置路径加载逻辑
- 变更:改用 `getClaudeConfigStatus`,结合 `exists` 决定展示文案与按钮态。
- 定时器类型修正:
- 文件:`src/App.tsx`
- 位置:`timeoutRef` 定义处
- 变更:`useRef<ReturnType<typeof setTimeout> | null>(null)`
- 文件名清洗增强:
- 文件:`src-tauri/src/config.rs`
- 位置:`sanitize_provider_name`
- 变更:空白替换为 `-`、连续 `-` 合并、过长截断。
## 可选优化
- 前端轻量校验:使用本地校验(或 zod检查关键字段格式与类型错误在表单内联展示。
- 按钮可用态与提示:`ProviderList` 的三按钮增加 `title` 提示,失败提示复用浮动通知。
- 日志落盘release 模式按 Warn 级别落盘,便于排障。
## 结论与建议
- 当前代码结构清晰,核心逻辑(供应商 CRUD、文件持久化、切换备份正确能够可靠完成从 Electron 到 Tauri 的迁移目标。
- 建议优先落地的改动:
- 防重导入 default
- 定时器类型与外链规范化;
- 复制主配置前的目录兜底;
-`getClaudeConfigStatus` 驱动配置路径 UI
- 版本号统一与依赖清理。
- 如需我直接按上述方案修改代码并提交,请告知优先级或指定改动范围。

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 KiB

After

Width:  |  Height:  |  Size: 1.4 MiB