import React, { useEffect, useState } from "react"; import JsonEditor from "../JsonEditor"; interface ClaudeConfigEditorProps { value: string; onChange: (value: string) => void; useCommonConfig: boolean; onCommonConfigToggle: (checked: boolean) => void; commonConfigSnippet: string; onCommonConfigSnippetChange: (value: string) => void; commonConfigError: string; } const ClaudeConfigEditor: React.FC = ({ value, onChange, useCommonConfig, onCommonConfigToggle, commonConfigSnippet, onCommonConfigSnippetChange, commonConfigError, }) => { const [isDarkMode, setIsDarkMode] = useState(false); const [isCommonConfigModalOpen, setIsCommonConfigModalOpen] = useState(false); useEffect(() => { // 检测暗色模式 const checkDarkMode = () => { setIsDarkMode(document.documentElement.classList.contains("dark")); }; checkDarkMode(); // 监听暗色模式变化 const observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { if (mutation.attributeName === "class") { checkDarkMode(); } }); }); observer.observe(document.documentElement, { attributes: true, attributeFilter: ["class"], }); return () => observer.disconnect(); }, []); useEffect(() => { if (commonConfigError && !isCommonConfigModalOpen) { setIsCommonConfigModalOpen(true); } }, [commonConfigError, isCommonConfigModalOpen]); const closeModal = () => { setIsCommonConfigModalOpen(false); }; return (
{commonConfigError && !isCommonConfigModalOpen && (

{commonConfigError}

)}

完整的 Claude Code settings.json 配置内容

{isCommonConfigModalOpen && (

编辑通用配置片段

该片段会在勾选“写入通用配置”时合并到 settings.json 中

{commonConfigError && (

{commonConfigError}

)}
)}
); }; export default ClaudeConfigEditor;