import { useTranslation } from "react-i18next"; import EndpointSpeedTest from "./EndpointSpeedTest"; import { ApiKeySection, EndpointField } from "./shared"; import type { ProviderCategory } from "@/types"; interface EndpointCandidate { url: string; } interface CodexFormFieldsProps { providerId?: string; // API Key codexApiKey: string; onApiKeyChange: (key: string) => void; category?: ProviderCategory; shouldShowApiKeyLink: boolean; websiteUrl: string; isPartner?: boolean; partnerPromotionKey?: string; // Base URL shouldShowSpeedTest: boolean; codexBaseUrl: string; onBaseUrlChange: (url: string) => void; isEndpointModalOpen: boolean; onEndpointModalToggle: (open: boolean) => void; onCustomEndpointsChange?: (endpoints: string[]) => void; // Model Name shouldShowModelField?: boolean; modelName?: string; onModelNameChange?: (model: string) => void; // Speed Test Endpoints speedTestEndpoints: EndpointCandidate[]; } export function CodexFormFields({ providerId, codexApiKey, onApiKeyChange, category, shouldShowApiKeyLink, websiteUrl, isPartner, partnerPromotionKey, shouldShowSpeedTest, codexBaseUrl, onBaseUrlChange, isEndpointModalOpen, onEndpointModalToggle, onCustomEndpointsChange, shouldShowModelField = true, modelName = "", onModelNameChange, speedTestEndpoints, }: CodexFormFieldsProps) { const { t } = useTranslation(); return ( <> {/* Codex API Key 输入框 */} {/* Codex Base URL 输入框 */} {shouldShowSpeedTest && ( onEndpointModalToggle(true)} /> )} {/* Codex Model Name 输入框 */} {shouldShowModelField && onModelNameChange && ( {t("codexConfig.modelName", { defaultValue: "模型名称" })} onModelNameChange(e.target.value)} placeholder={t("codexConfig.modelNamePlaceholder", { defaultValue: "例如: gpt-5-codex", })} className="w-full px-3 py-2 border border-border-default dark:bg-gray-800 dark:text-gray-100 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:focus:ring-blue-400/20 transition-colors" /> {t("codexConfig.modelNameHint", { defaultValue: "指定使用的模型,将自动更新到 config.toml 中", })} )} {/* 端点测速弹窗 - Codex */} {shouldShowSpeedTest && isEndpointModalOpen && ( onEndpointModalToggle(false)} onCustomEndpointsChange={onCustomEndpointsChange} /> )} > ); }
{t("codexConfig.modelNameHint", { defaultValue: "指定使用的模型,将自动更新到 config.toml 中", })}