mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 12:44:18 +08:00
2c90ae3509
Complete the device-level settings separation for cloud sync support. Backend changes: - Modify switch() to update both local settings and database is_current - Modify current() to read from local settings first, fallback to database - Rename sync_current_from_db() to sync_current_to_live() - Update tray menu to read current provider from local settings Frontend changes: - Update Settings interface: remove legacy fields (customEndpoints*, security) - Add currentProviderClaude/Codex/Gemini fields - Update settings schema accordingly Test fixes: - Update Gemini security tests to check ~/.gemini/settings.json instead of ~/.cc-switch/settings.json (security field was never stored in CC Switch settings) This ensures each device maintains its own current provider selection independently when database is synced across devices.
30 lines
871 B
TypeScript
30 lines
871 B
TypeScript
import { z } from "zod";
|
|
|
|
const directorySchema = z
|
|
.string()
|
|
.trim()
|
|
.min(1, "路径不能为空")
|
|
.optional()
|
|
.or(z.literal(""));
|
|
|
|
export const settingsSchema = z.object({
|
|
// 设备级 UI 设置
|
|
showInTray: z.boolean(),
|
|
minimizeToTrayOnClose: z.boolean(),
|
|
enableClaudePluginIntegration: z.boolean().optional(),
|
|
launchOnStartup: z.boolean().optional(),
|
|
language: z.enum(["en", "zh"]).optional(),
|
|
|
|
// 设备级目录覆盖
|
|
claudeConfigDir: directorySchema.nullable().optional(),
|
|
codexConfigDir: directorySchema.nullable().optional(),
|
|
geminiConfigDir: directorySchema.nullable().optional(),
|
|
|
|
// 当前供应商 ID(设备级)
|
|
currentProviderClaude: z.string().optional(),
|
|
currentProviderCodex: z.string().optional(),
|
|
currentProviderGemini: z.string().optional(),
|
|
});
|
|
|
|
export type SettingsFormData = z.infer<typeof settingsSchema>;
|