feat(auth): backup settings file before auth modification

- Add backupSettingsFile() utility to create .orig backup before modifying settings
- Update success message to indicate backup was created
- Sync i18n translations for all supported languages
- Update documentation to reflect the change

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
mingholy.lmh 2026-02-26 20:38:38 +08:00
parent 44b8ff729e
commit 0c53b19a74
11 changed files with 48 additions and 21 deletions

View file

@ -35,6 +35,7 @@ import {
CodingPlanRegion,
CODING_PLAN_ENV_KEY,
} from '../../constants/codingPlan.js';
import { backupSettingsFile } from '../../utils/settingsUtils.js';
export type { QwenAuthState } from '../hooks/useQwenAuth.js';
@ -304,6 +305,10 @@ export const useAuthCommand = (
// Get persist scope
const persistScope = getPersistScopeForModelSelection(settings);
// Backup settings file before modification
const settingsFile = settings.forScope(persistScope);
backupSettingsFile(settingsFile.path);
// Store api-key in settings.env (unified env key)
settings.setValue(persistScope, `env.${CODING_PLAN_ENV_KEY}`, apiKey);
@ -384,7 +389,7 @@ export const useAuthCommand = (
{
type: MessageType.INFO,
text: t(
'Authenticated successfully with {{region}}. API key is stored in settings.env.',
'Authenticated successfully with {{region}}. API key and model configs saved to settings.json (backed up).',
{ region: regionName },
),
},