mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-28 16:56:16 +08:00
refactor(profiles): shared project entity with per-scope switching
Projects are now global shared entities; Claude and Codex groups switch independently via scoped current pointers and scoped payload slots. - Remove scope column from profiles; keep current_profile_id_<scope> - Use Option<Vec<String>> for mcp/skills to distinguish 'never captured' from 'captured empty', preventing cross-side accidental disable - Update/apply operations scoped to the active group via merge_scope_from - Tray menu nests same shared list under Claude Code/Codex groups - Add i18n for per-scope tooltips and 'not saved for this side' hint Refs: profile P1 shared-entity redesign
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import type { AppId } from "@/lib/api/types";
|
||||
import type { PerApp, Profile, ProfileScope } from "@/lib/api/profiles";
|
||||
|
||||
/**
|
||||
* 应用页 → 所属项目分组(后端 ProfileScope::for_app 的前端镜像,两处同步)
|
||||
*
|
||||
* 不在映射里的应用不支持 Profile,其标签页不渲染切换器。
|
||||
*/
|
||||
export const APP_PROFILE_SCOPE: Partial<Record<AppId, ProfileScope>> = {
|
||||
claude: "claude",
|
||||
"claude-desktop": "claude",
|
||||
codex: "codex",
|
||||
};
|
||||
|
||||
/** 分组显示名(产品名,不进 i18n;与后端托盘子菜单标签一致) */
|
||||
export const PROFILE_SCOPE_LABELS: Record<ProfileScope, string> = {
|
||||
claude: "Claude Code",
|
||||
codex: "Codex",
|
||||
};
|
||||
|
||||
/** 分组内的 payload 槽位 key(后端 ProfileScope::apps 的前端镜像) */
|
||||
const SCOPE_SLOT_KEYS: Record<ProfileScope, (keyof PerApp<unknown>)[]> = {
|
||||
claude: ["claude", "claude-desktop"],
|
||||
codex: ["codex"],
|
||||
};
|
||||
|
||||
/**
|
||||
* 项目在某分组是否拍过快照(任一槽位非 null 即视为拍过)
|
||||
*
|
||||
* 未拍过的项目在该分组应用时不改动配置,只绑定 current 标记。
|
||||
*/
|
||||
export function hasScopeSnapshot(profile: Profile, scope: ProfileScope) {
|
||||
const { providers, mcp, skills, prompts } = profile.payload;
|
||||
return SCOPE_SLOT_KEYS[scope].some(
|
||||
(app) =>
|
||||
providers[app] !== null ||
|
||||
mcp[app] !== null ||
|
||||
skills[app] !== null ||
|
||||
prompts[app] !== null,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user