mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-04-23 01:14:51 +08:00
fix(common-config): reset initialization flag when preset changes
The common config checkbox was only auto-enabled for the first preset (custom) because hasInitializedNewMode ref was permanently locked to true after first initialization. Add selectedPresetId parameter to all three common config hooks and reset the initialization flag when preset changes, allowing the initialization logic to re-run for each preset switch.
This commit is contained in:
@@ -358,6 +358,7 @@ export function ProviderForm({
|
||||
settingsConfig: form.watch("settingsConfig"),
|
||||
onConfigChange: (config) => form.setValue("settingsConfig", config),
|
||||
initialData: appId === "claude" ? initialData : undefined,
|
||||
selectedPresetId: selectedPresetId ?? undefined,
|
||||
});
|
||||
|
||||
// 使用 Codex 通用配置片段 hook (仅 Codex 模式)
|
||||
@@ -373,6 +374,7 @@ export function ProviderForm({
|
||||
codexConfig,
|
||||
onConfigChange: handleCodexConfigChange,
|
||||
initialData: appId === "codex" ? initialData : undefined,
|
||||
selectedPresetId: selectedPresetId ?? undefined,
|
||||
});
|
||||
|
||||
// 使用 Gemini 配置 hook (仅 Gemini 模式)
|
||||
@@ -460,6 +462,7 @@ export function ProviderForm({
|
||||
envStringToObj,
|
||||
envObjToString,
|
||||
initialData: appId === "gemini" ? initialData : undefined,
|
||||
selectedPresetId: selectedPresetId ?? undefined,
|
||||
});
|
||||
|
||||
const [isCommonConfigModalOpen, setIsCommonConfigModalOpen] = useState(false);
|
||||
|
||||
Reference in New Issue
Block a user