import { useTranslation } from "react-i18next"; import ApiKeyInput from "../ApiKeyInput"; import type { ProviderCategory } from "@/types"; interface ApiKeySectionProps { id?: string; label?: string; value: string; onChange: (value: string) => void; category?: ProviderCategory; shouldShowLink: boolean; websiteUrl: string; placeholder?: { official: string; thirdParty: string; }; disabled?: boolean; isPartner?: boolean; partnerPromotionKey?: string; } export function ApiKeySection({ id, label, value, onChange, category, shouldShowLink, websiteUrl, placeholder, disabled, isPartner, partnerPromotionKey, }: ApiKeySectionProps) { const { t } = useTranslation(); const defaultPlaceholder = { official: t("providerForm.officialNoApiKey", { defaultValue: "官方供应商无需 API Key", }), thirdParty: t("providerForm.apiKeyAutoFill", { defaultValue: "输入 API Key,将自动填充到配置", }), }; const finalPlaceholder = placeholder || defaultPlaceholder; return (
{/* API Key 获取链接 */} {shouldShowLink && websiteUrl && (
{t("providerForm.getApiKey", { defaultValue: "获取 API Key", })} {/* 合作伙伴促销信息 */} {isPartner && partnerPromotionKey && (

💡{" "} {t(`providerForm.partnerPromotion.${partnerPromotionKey}`, { defaultValue: "", })}

)}
)}
); }