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 (
匯入會自動辨識檔案類型:完整備份、設定、單一專案、單一對話(也相容舊版匯出的對話 JSON)。單一專案 / 對話也可在「專案」「對話」頁匯出。
{msg &&{msg}
}