import { useTranslation } from "react-i18next"; import { Dialog, DialogContent, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; import { Label } from "@/components/ui/label"; import JsonEditor from "@/components/JsonEditor"; import { useTheme } from "@/components/theme-provider"; import { useMemo } from "react"; interface CommonConfigEditorProps { value: string; onChange: (value: string) => void; useCommonConfig: boolean; onCommonConfigToggle: (checked: boolean) => void; commonConfigSnippet: string; onCommonConfigSnippetChange: (value: string) => void; commonConfigError: string; onEditClick: () => void; isModalOpen: boolean; onModalClose: () => void; } export function CommonConfigEditor({ value, onChange, useCommonConfig, onCommonConfigToggle, commonConfigSnippet, onCommonConfigSnippetChange, commonConfigError, onEditClick, isModalOpen, onModalClose, }: CommonConfigEditorProps) { const { t } = useTranslation(); const { theme } = useTheme(); const isDarkMode = useMemo(() => { if (theme === "dark") return true; if (theme === "light") return false; return typeof window !== "undefined" ? window.document.documentElement.classList.contains("dark") : false; }, [theme]); return ( <>
{commonConfigError && !isModalOpen && (

{commonConfigError}

)}

{t("claudeConfig.fullSettingsHint", { defaultValue: "请填写完整的 Claude Code 配置", })}

!open && onModalClose()}> {t("claudeConfig.editCommonConfigTitle", { defaultValue: "编辑通用配置片段", })}

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

{commonConfigError && (

{commonConfigError}

)}
); }