refactor: redesign cli settings export/import API with endpoint-based schema

Replace nested settings structure with flat endpoints array for
export/import. Add conflict strategy options (skip/overwrite/merge)
and skipInvalid/disableImported flags.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
catlog22
2026-03-24 17:24:42 +08:00
parent 45756aad83
commit f112d4b9a2
3 changed files with 154 additions and 161 deletions

View File

@@ -6159,28 +6159,17 @@ export async function upgradeCcwInstallation(
*/
export interface ExportedSettings {
version: string;
exportedAt: string;
settings: {
cliTools?: Record<string, unknown>;
chineseResponse?: {
claudeEnabled: boolean;
codexEnabled: boolean;
};
windowsPlatform?: {
enabled: boolean;
};
codexCliEnhancement?: {
enabled: boolean;
};
};
timestamp: string;
endpoints: Array<Record<string, unknown>>;
}
/**
* Import options for settings import
*/
export interface ImportOptions {
overwrite?: boolean;
dryRun?: boolean;
conflictStrategy?: 'skip' | 'overwrite' | 'merge';
skipInvalid?: boolean;
disableImported?: boolean;
}
/**

View File

@@ -619,7 +619,7 @@ function ResponseLanguageSection() {
const data = JSON.parse(text) as ExportedSettings;
// Validate basic structure
if (!data.version || !data.settings) {
if (!data.version || !data.endpoints) {
toast.error(formatMessage({ id: 'settings.responseLanguage.importInvalidStructure' }));
return;
}