import { useState } from 'react' import { Sun, Moon, Download, Upload, RotateCcw } from 'lucide-react' import { useStore } from '../../store/useStore' import { Btn, Field, Section, inputCls, download, pickJsonFile, stamp } from '../ui' export default function SettingsPanel() { const settings = useStore((s) => s.settings) const st = useStore.getState() const [includeKeys, setIncludeKeys] = useState(true) const [msg, setMsg] = useState('') const up = (patch) => st.updateSettings(patch) const doExport = (scope) => { const data = st.exportData(scope, { includeKeys }) download(`agent-studio-${scope === 'all' ? 'backup' : 'settings'}-${stamp()}.json`, JSON.stringify(data, null, 2)) setMsg(scope === 'all' ? '已匯出全部(設定 + 專案 + 對話)' : '已匯出設定') } const doImport = async () => { setMsg('') try { const json = await pickJsonFile() let mode = 'merge' if (json?.type === 'all') { mode = confirm('這是完整備份。\n按「確定」= 完全取代目前資料\n按「取消」= 合併(同 id 覆蓋,其餘保留)') ? 'replace' : 'merge' } setMsg(st.importData(json, mode)) } catch (e) { setMsg(`匯入失敗:${e.message}`) } } return (
doExport('all')}> 匯出全部 匯入 doExport('settings')}> 只匯出設定(供應商、Agent、工具)

匯入會自動辨識檔案類型:完整備份、設定、單一專案、單一對話(也相容舊版匯出的對話 JSON)。單一專案 / 對話也可在「專案」「對話」頁匯出。

{msg &&

{msg}

}
up({ theme: 'dark' })}> 深色 up({ theme: 'light' })}> 亮色
up({ maxSteps: e.target.value })} /> up({ temperature: e.target.value })} placeholder="預設" />
up({ tavilyKey: e.target.value })} placeholder="tvly-..." /> up({ jinaKey: e.target.value })} placeholder="jina_..." />
{ if (confirm('清除所有專案、對話與設定?建議先「匯出全部」備份。')) st.resetAll() }}> 重設所有資料
) }