mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-29 09:37:37 +08:00
Fix/一键配置失效 (#2249)
* style(FailoverQueueManager): 显示供应商备注信息 * style(FailoverQueueItem): 添加供应商备注字段以支持备注信息显示 * style(FailoverQueueManager): 显示供应商备注信息 * style(FailoverQueueItem): 添加供应商备注字段以支持备注信息显示 * style(FailoverQueueManager): 更新供应商备注信息的显示样式 * style(FailoverQueueItem): 添加条件序列化以优化供应商备注字段 * fix: 优化模型状态管理,确保配置更新时正确引用最新设置 * fix(skill): improve error handling for skill source directory resolution Co-authored-by: Copilot <copilot@github.com> * fix(gemini): simplify project directory retrieval in scan_sessions function * fix(useModelState): optimize latestConfigRef assignment in useModelState hook * fix(useModelState): remove unnecessary blank line in useModelState hook --------- Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -61,6 +61,9 @@ export function useModelState({
|
||||
|
||||
const isUserEditingRef = useRef(false);
|
||||
const lastConfigRef = useRef(settingsConfig);
|
||||
const latestConfigRef = useRef(settingsConfig);
|
||||
|
||||
latestConfigRef.current = settingsConfig;
|
||||
|
||||
// 初始化读取:读新键;若缺失,按兼容优先级回退
|
||||
// Haiku: DEFAULT_HAIKU || SMALL_FAST || MODEL
|
||||
@@ -130,8 +133,8 @@ export function useModelState({
|
||||
if (field === "ANTHROPIC_DEFAULT_OPUS_MODEL") setDefaultOpusModel(value);
|
||||
|
||||
try {
|
||||
const currentConfig = settingsConfig
|
||||
? JSON.parse(settingsConfig)
|
||||
const currentConfig = latestConfigRef.current
|
||||
? JSON.parse(latestConfigRef.current)
|
||||
: { env: {} };
|
||||
if (!currentConfig.env) currentConfig.env = {};
|
||||
const env = currentConfig.env as Record<string, unknown>;
|
||||
@@ -146,12 +149,14 @@ export function useModelState({
|
||||
// 删除旧键
|
||||
delete env["ANTHROPIC_SMALL_FAST_MODEL"];
|
||||
|
||||
onConfigChange(JSON.stringify(currentConfig, null, 2));
|
||||
const updatedConfig = JSON.stringify(currentConfig, null, 2);
|
||||
latestConfigRef.current = updatedConfig;
|
||||
onConfigChange(updatedConfig);
|
||||
} catch (err) {
|
||||
console.error("Failed to update model config:", err);
|
||||
}
|
||||
},
|
||||
[settingsConfig, onConfigChange],
|
||||
[onConfigChange],
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user