import { useEffect, useState } from 'react'; import { getMindSearchConfig, updateMindSearchConfig } from '../../api/client'; import type { MindSearchConfig } from '../../types'; const initial: MindSearchConfig = { enabled: false, mode: 'off', providers: { searxng: false, github: false, reader: false }, settings: { searxngEndpoint: '', maxResults: 10, timeoutMs: 8000, readerMaxChars: 12000 }, }; export function MindSearchPage() { const [config, setConfig] = useState(initial); const [meta, setMeta] = useState<{ source?: string; updatedAt?: number | null; updatedBy?: string | null }>({}); const [message, setMessage] = useState('加载配置中…'); useEffect(() => { getMindSearchConfig() .then((result) => { setConfig({ ...initial, ...result.config, settings: { ...initial.settings, ...result.config.settings } }); setMeta(result); setMessage(''); }) .catch((error) => setMessage(error instanceof Error ? error.message : '配置加载失败')); }, []); const save = async () => { setMessage('保存中…'); try { const result = await updateMindSearchConfig(config); setConfig({ ...initial, ...result.config, settings: { ...initial.settings, ...result.config.settings } }); setMeta(result); setMessage('已保存到数据库;新会话生效,旧会话不受影响'); } catch (error) { setMessage(error instanceof Error ? error.message : '保存失败'); } }; const toggleProvider = (key: keyof MindSearchConfig['providers']) => setConfig((current) => ({ ...current, providers: { ...current.providers, [key]: !current.providers[key] } })); const updateSetting = (key: keyof MindSearchConfig['settings'], value: string | number) => setConfig((current) => ({ ...current, settings: { ...current.settings, [key]: value } })); return (

MindSearch

可插拔外部搜索增强。关闭时完全保持原有搜索、记忆和上下文链路。

总开关与模式

Provider

可用 Provider

运行参数

{message &&

{message}

}

配置来源:{meta.source === 'admin' ? '数据库' : '环境变量默认值'};最后更新:{meta.updatedAt ? new Date(meta.updatedAt).toLocaleString() : '尚未保存'}{meta.updatedBy ? `;操作人:${meta.updatedBy}` : ''}

); }