mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-29 01:25:33 +08:00
refactor(common-config): extract snippet from editor content instead of active provider
- Change extraction source from current active provider to editor's live content - Add i18n support for JSON parse error messages via invalid_json_format_error() - Simplify API by removing unused providerId parameter - Update button labels and error messages in zh/en/ja locales
This commit is contained in:
@@ -246,13 +246,17 @@ export function useCodexCommonConfig({
|
||||
setUseCommonConfig(hasCommon);
|
||||
}, [codexConfig, commonConfigSnippet, isLoading]);
|
||||
|
||||
// 从当前供应商提取通用配置片段
|
||||
// 从编辑器当前内容提取通用配置片段
|
||||
const handleExtract = useCallback(async () => {
|
||||
setIsExtracting(true);
|
||||
setCommonConfigError("");
|
||||
|
||||
try {
|
||||
const extracted = await configApi.extractCommonConfigSnippet("codex");
|
||||
const extracted = await configApi.extractCommonConfigSnippet("codex", {
|
||||
settingsConfig: JSON.stringify({
|
||||
config: codexConfig ?? "",
|
||||
}),
|
||||
});
|
||||
|
||||
if (!extracted || !extracted.trim()) {
|
||||
setCommonConfigError(t("codexConfig.extractNoCommonConfig"));
|
||||
@@ -270,7 +274,7 @@ export function useCodexCommonConfig({
|
||||
} finally {
|
||||
setIsExtracting(false);
|
||||
}
|
||||
}, []);
|
||||
}, [codexConfig, t]);
|
||||
|
||||
return {
|
||||
useCommonConfig,
|
||||
|
||||
Reference in New Issue
Block a user