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 KimiModelSelector from "@/components/ProviderForm/KimiModelSelector"; import { Zap } from "lucide-react"; import type { ProviderCategory } from "@/types"; import type { TemplateValueConfig } from "@/config/providerPresets"; interface ClaudeFormFieldsProps { // API Key shouldShowApiKey: boolean; apiKey: string; onApiKeyChange: (key: string) => void; category?: ProviderCategory; shouldShowApiKeyLink: boolean; websiteUrl: string; // Template Values templateValueEntries: Array<[string, TemplateValueConfig]>; templateValues: Record; templatePresetName: string; onTemplateValueChange: (key: string, value: string) => void; // Base URL shouldShowSpeedTest: boolean; baseUrl: string; onBaseUrlChange: (url: string) => void; isEndpointModalOpen: boolean; onEndpointModalToggle: (open: boolean) => void; onCustomEndpointsChange: (endpoints: string[]) => void; // Model Selector shouldShowKimiSelector: boolean; shouldShowModelSelector: boolean; claudeModel: string; claudeSmallFastModel: string; onModelChange: ( field: "ANTHROPIC_MODEL" | "ANTHROPIC_SMALL_FAST_MODEL", value: string ) => void; // Kimi Model Selector kimiAnthropicModel: string; kimiAnthropicSmallFastModel: string; onKimiModelChange: ( field: "ANTHROPIC_MODEL" | "ANTHROPIC_SMALL_FAST_MODEL", value: string ) => void; } export function ClaudeFormFields({ shouldShowApiKey, apiKey, onApiKeyChange, category, shouldShowApiKeyLink, websiteUrl, templateValueEntries, templateValues, templatePresetName, onTemplateValueChange, shouldShowSpeedTest, baseUrl, onBaseUrlChange, isEndpointModalOpen, onEndpointModalToggle, onCustomEndpointsChange, shouldShowKimiSelector, shouldShowModelSelector, claudeModel, claudeSmallFastModel, onModelChange, kimiAnthropicModel, kimiAnthropicSmallFastModel, onKimiModelChange, }: ClaudeFormFieldsProps) { const { t } = useTranslation(); return ( <> {/* API Key 输入框 */} {shouldShowApiKey && (
{/* API Key 获取链接 */} {shouldShowApiKeyLink && websiteUrl && (
{t("providerForm.getApiKey", { defaultValue: "获取 API Key", })}
)}
)} {/* 模板变量输入 */} {templateValueEntries.length > 0 && (
{t("providerForm.parameterConfig", { name: templatePresetName, defaultValue: `${templatePresetName} 参数配置`, })}
{templateValueEntries.map(([key, config]) => (
{config.label} onTemplateValueChange(key, e.target.value)} placeholder={config.placeholder || config.label} autoComplete="off" />
))}
)} {/* Base URL 输入框 */} {shouldShowSpeedTest && (
{t("providerForm.apiEndpoint", { defaultValue: "API 端点" })}
onBaseUrlChange(e.target.value)} placeholder={t("providerForm.apiEndpointPlaceholder", { defaultValue: "https://api.example.com", })} autoComplete="off" />

{t("providerForm.apiHint", { defaultValue: "API 端点地址用于连接服务器", })}

)} {/* 端点测速弹窗 */} {shouldShowSpeedTest && isEndpointModalOpen && ( onEndpointModalToggle(false)} onCustomEndpointsChange={onCustomEndpointsChange} /> )} {/* 模型选择器 */} {shouldShowModelSelector && (
{/* ANTHROPIC_MODEL */}
{t("providerForm.anthropicModel", { defaultValue: "主模型", })} onModelChange("ANTHROPIC_MODEL", e.target.value) } placeholder={t("providerForm.modelPlaceholder", { defaultValue: "claude-3-7-sonnet-20250219", })} autoComplete="off" />
{/* ANTHROPIC_SMALL_FAST_MODEL */}
{t("providerForm.anthropicSmallFastModel", { defaultValue: "快速模型", })} onModelChange("ANTHROPIC_SMALL_FAST_MODEL", e.target.value) } placeholder={t("providerForm.smallModelPlaceholder", { defaultValue: "claude-3-5-haiku-20241022", })} autoComplete="off" />

{t("providerForm.modelHelper", { defaultValue: "可选:指定默认使用的 Claude 模型,留空则使用系统默认。", })}

)} {/* Kimi 模型选择器 */} {shouldShowKimiSelector && ( )} ); }