diff --git a/src/components/providers/forms/GeminiCommonConfigModal.tsx b/src/components/providers/forms/GeminiCommonConfigModal.tsx new file mode 100644 index 0000000..76696b7 --- /dev/null +++ b/src/components/providers/forms/GeminiCommonConfigModal.tsx @@ -0,0 +1,122 @@ +import React from "react"; +import { Save, Wand2 } from "lucide-react"; +import { useTranslation } from "react-i18next"; +import { toast } from "sonner"; +import { + Dialog, + DialogContent, + DialogHeader, + DialogTitle, + DialogFooter, +} from "@/components/ui/dialog"; +import { Button } from "@/components/ui/button"; +import { formatJSON } from "@/utils/formatters"; + +interface GeminiCommonConfigModalProps { + isOpen: boolean; + onClose: () => void; + value: string; + onChange: (value: string) => void; + error?: string; +} + +/** + * GeminiCommonConfigModal - Common Gemini configuration editor modal + * Allows editing of common JSON configuration shared across Gemini providers + */ +export const GeminiCommonConfigModal: React.FC< + GeminiCommonConfigModalProps +> = ({ isOpen, onClose, value, onChange, error }) => { + const { t } = useTranslation(); + + const handleFormat = () => { + if (!value.trim()) return; + + try { + const formatted = formatJSON(value); + 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 ( + !open && onClose()}> + + + + {t("geminiConfig.editCommonConfigTitle", { + defaultValue: "编辑 Gemini 通用配置片段", + })} + + + +
+

+ {t("geminiConfig.commonConfigHint", { + defaultValue: + "通用配置片段将合并到所有启用它的 Gemini 供应商配置中", + })} +

+ +