import { useTranslation } from "react-i18next"; import { FormLabel } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import ApiKeyInput from "@/components/ProviderForm/ApiKeyInput"; import EndpointSpeedTest from "@/components/ProviderForm/EndpointSpeedTest"; import { Zap } from "lucide-react"; import type { ProviderCategory } from "@/types"; interface CodexFormFieldsProps { // API Key codexApiKey: string; onApiKeyChange: (key: string) => void; category?: ProviderCategory; shouldShowApiKeyLink: boolean; websiteUrl: string; // Base URL shouldShowSpeedTest: boolean; codexBaseUrl: string; onBaseUrlChange: (url: string) => void; isEndpointModalOpen: boolean; onEndpointModalToggle: (open: boolean) => void; onCustomEndpointsChange: (endpoints: string[]) => void; } export function CodexFormFields({ codexApiKey, onApiKeyChange, category, shouldShowApiKeyLink, websiteUrl, shouldShowSpeedTest, codexBaseUrl, onBaseUrlChange, isEndpointModalOpen, onEndpointModalToggle, onCustomEndpointsChange, }: CodexFormFieldsProps) { const { t } = useTranslation(); return ( <> {/* Codex API Key 输入框 */}
{/* Codex API Key 获取链接 */} {shouldShowApiKeyLink && websiteUrl && (
{t("providerForm.getApiKey", { defaultValue: "获取 API Key", })}
)}
{/* Codex Base URL 输入框 */} {shouldShowSpeedTest && (
{t("codexConfig.apiUrlLabel", { defaultValue: "API 端点" })}
onBaseUrlChange(e.target.value)} placeholder={t("providerForm.codexApiEndpointPlaceholder", { defaultValue: "https://api.example.com/v1", })} autoComplete="off" />

{t("providerForm.codexApiHint", { defaultValue: "Codex API 端点地址", })}

)} {/* 端点测速弹窗 - Codex */} {shouldShowSpeedTest && isEndpointModalOpen && ( onEndpointModalToggle(false)} onCustomEndpointsChange={onCustomEndpointsChange} /> )} ); }