import { useTranslation } from "react-i18next"; import { FormLabel } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { Zap, Link2 } from "lucide-react"; interface EndpointFieldProps { id: string; label: string; value: string; onChange: (value: string) => void; placeholder: string; hint?: string; showManageButton?: boolean; onManageClick?: () => void; manageButtonLabel?: string; showFullUrlToggle?: boolean; isFullUrl?: boolean; onFullUrlChange?: (value: boolean) => void; } export function EndpointField({ id, label, value, onChange, placeholder, hint, showManageButton = true, onManageClick, manageButtonLabel, showFullUrlToggle = false, isFullUrl = false, onFullUrlChange, }: EndpointFieldProps) { const { t } = useTranslation(); const defaultManageLabel = t("providerForm.manageAndTest", { defaultValue: "管理和测速", }); return (
{label} {showManageButton && onManageClick && ( )}
onChange(e.target.value)} placeholder={placeholder} autoComplete="off" /> {showFullUrlToggle && onFullUrlChange && (
{isFullUrl && ( {t("providerForm.fullUrlHint", { defaultValue: "代理将直接使用此 URL,不拼接路径", })} )}
)} {hint ? (

{hint}

) : null}
); }