diff --git a/src/components/providers/forms/ProviderForm.tsx b/src/components/providers/forms/ProviderForm.tsx index 3a47653..edafc9b 100644 --- a/src/components/providers/forms/ProviderForm.tsx +++ b/src/components/providers/forms/ProviderForm.tsx @@ -90,7 +90,7 @@ export function ProviderForm({ initialData, showButtons = true, }: ProviderFormProps) { - const { t, i18n } = useTranslation(); + const { t } = useTranslation(); const isEditMode = Boolean(initialData); const [selectedPresetId, setSelectedPresetId] = useState( @@ -221,14 +221,13 @@ export function ProviderForm({ [originalHandleCodexConfigChange, debouncedValidate], ); - // Codex 新建模式:初始化时自动填充模板(支持国际化) + // Codex 新建模式:初始化时自动填充模板 useEffect(() => { if (appId === "codex" && !initialData && selectedPresetId === "custom") { - const locale = (i18n.language || "zh").startsWith("zh") ? "zh" : "en"; - const template = getCodexCustomTemplate(locale); + const template = getCodexCustomTemplate(); resetCodexConfig(template.auth, template.config); } - }, [appId, initialData, selectedPresetId, resetCodexConfig, i18n.language]); + }, [appId, initialData, selectedPresetId, resetCodexConfig]); useEffect(() => { form.reset(defaultValues); @@ -535,10 +534,9 @@ export function ProviderForm({ setActivePreset(null); form.reset(defaultValues); - // Codex 自定义模式:加载模板(支持国际化) + // Codex 自定义模式:加载模板 if (appId === "codex") { - const locale = (i18n.language || "zh").startsWith("zh") ? "zh" : "en"; - const template = getCodexCustomTemplate(locale); + const template = getCodexCustomTemplate(); resetCodexConfig(template.auth, template.config); } // Gemini 自定义模式:重置为空配置 diff --git a/src/config/codexTemplates.ts b/src/config/codexTemplates.ts index 1d1a9b0..f53704f 100644 --- a/src/config/codexTemplates.ts +++ b/src/config/codexTemplates.ts @@ -10,86 +10,21 @@ export interface CodexTemplate { /** * 获取 Codex 自定义模板 - * @param locale 语言环境 ('zh' | 'en') * @returns Codex 模板配置 */ -export function getCodexCustomTemplate( - locale: "zh" | "en" = "zh", -): CodexTemplate { - const templates = { - zh: `# ======================================== -# Codex 自定义供应商配置模板 -# ======================================== -# 快速上手: -# 1. 在上方 auth.json 中设置 API Key -# 2. 将下方 'custom' 替换为供应商名称(小写、无空格) -# 3. 替换 base_url 为实际的 API 端点 -# 4. 根据需要调整模型名称 -# -# 文档: https://docs.anthropic.com -# ======================================== +export function getCodexCustomTemplate(): CodexTemplate { + const config = `model_provider = "custom" +model = "gpt-5-codex" +model_reasoning_effort = "high" +disable_response_storage = true -# ========== 模型配置 ========== -model_provider = "custom" # 供应商唯一标识 -model = "gpt-5-codex" # 模型名称 -model_reasoning_effort = "high" # 推理强度:low, medium, high -disable_response_storage = true # 隐私:不本地存储响应 - -# ========== 供应商设置 ========== [model_providers.custom] -name = "custom" # 与上方 model_provider 保持一致 -base_url = "https://api.example.com/v1" # 👈 替换为实际端点 -wire_api = "responses" # API 响应格式 -requires_openai_auth = true # 使用 auth.json 中的 OPENAI_API_KEY - -# ========== 可选:自定义请求头 ========== -# 如果供应商需要自定义请求头,取消注释: -# [model_providers.custom.headers] -# X-Custom-Header = "value" - -# ========== 可选:模型覆盖 ========== -# 如果需要覆盖特定模型,取消注释: -# [model_overrides] -# "gpt-5-codex" = { model_provider = "custom", model = "your-model-name" }`, - - en: `# ======================================== -# Codex Custom Provider Configuration Template -# ======================================== -# Quick Start: -# 1. Set API Key in auth.json above -# 2. Replace 'custom' below with provider name (lowercase, no spaces) -# 3. Replace base_url with actual API endpoint -# 4. Adjust model name as needed -# -# Docs: https://docs.anthropic.com -# ======================================== - -# ========== Model Configuration ========== -model_provider = "custom" # Unique provider identifier -model = "gpt-5-codex" # Model name -model_reasoning_effort = "high" # Reasoning effort: low, medium, high -disable_response_storage = true # Privacy: do not store responses locally - -# ========== Provider Settings ========== -[model_providers.custom] -name = "custom" # Must match model_provider above -base_url = "https://api.example.com/v1" # 👈 Replace with actual endpoint -wire_api = "responses" # API response format -requires_openai_auth = true # Use OPENAI_API_KEY from auth.json - -# ========== Optional: Custom Headers ========== -# If provider requires custom headers, uncomment: -# [model_providers.custom.headers] -# X-Custom-Header = "value" - -# ========== Optional: Model Overrides ========== -# If you need to override specific models, uncomment: -# [model_overrides] -# "gpt-5-codex" = { model_provider = "custom", model = "your-model-name" }`, - }; +name = "custom" +wire_api = "responses" +requires_openai_auth = true`; return { auth: { OPENAI_API_KEY: "" }, - config: templates[locale] || templates.zh, + config, }; }