import { useTranslation } from "react-i18next"; import { useEffect, useState } from "react"; import { FullScreenPanel } from "@/components/common/FullScreenPanel"; import { Label } from "@/components/ui/label"; import { Button } from "@/components/ui/button"; import { Save } from "lucide-react"; import JsonEditor from "@/components/JsonEditor"; 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 [isDarkMode, setIsDarkMode] = useState(false); useEffect(() => { setIsDarkMode(document.documentElement.classList.contains("dark")); const observer = new MutationObserver(() => { setIsDarkMode(document.documentElement.classList.contains("dark")); }); observer.observe(document.documentElement, { attributes: true, attributeFilter: ["class"], }); return () => observer.disconnect(); }, []); return ( <>
{commonConfigError && !isModalOpen && (

{commonConfigError}

)}
} >

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

{commonConfigError && (

{commonConfigError}

)}
); }