import React from "react"; import { useTranslation } from "react-i18next"; import { Wand2 } from "lucide-react"; import { toast } from "sonner"; import { formatJSON } from "@/utils/formatters"; interface GeminiEnvSectionProps { value: string; onChange: (value: string) => void; onBlur?: () => void; error?: string; } /** * GeminiEnvSection - .env editor section for Gemini environment variables */ export const GeminiEnvSection: React.FC = ({ value, onChange, onBlur, error, }) => { const { t } = useTranslation(); const handleFormat = () => { if (!value.trim()) return; try { // 重新格式化 .env 内容 const formatted = value .split("\n") .filter((line) => line.trim()) .join("\n"); onChange(formatted); toast.success(t("common.formatSuccess", { defaultValue: "格式化成功" })); } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); toast.error( t("common.formatError", { defaultValue: "格式化失败:{{error}}", error: errorMessage, }), ); } }; return (