import type { ModuleConfig } from '@/types/module' import type { SearchIndexItem } from '@/stores/searchIndex' const searchItems: SearchIndexItem[] = [ { title: 'DeepSeek Harness', description: '安装、更新与启动 dsh,管理 Node 运行环境与 AI 通道', keywords: ['dsh', 'deepseek', 'harness', 'agent', '智能体', '外壳', '安装'], tab: 'setup' }, { title: '安装 dsh 环境', description: '按步骤引导安装 Node 运行环境与 dsh 本体', keywords: ['安装', 'install', 'node', '环境', '引导', 'stepper', '更新'], tab: 'setup' }, { title: 'dsh 设置', description: '端口、工作区、Node 来源、镜像源与自动启动', keywords: ['设置', 'setting', '端口', 'port', '工作区', 'workspace', '镜像'], tab: 'settings' }, { title: 'dsh AI 通道', description: '把设置里的 AI 供应商(含 DeepSeek API Key)同步给 dsh', keywords: ['ai', 'api key', 'deepseek', '供应商', 'provider', '模型', 'model'], tab: 'settings' }, { title: 'dsh 运行日志', description: '查看 dsh 服务的输出日志', keywords: ['日志', 'log', '输出', '排查', 'debug'], tab: 'logs' } ] export const moduleConfig: ModuleConfig = { id: 'dsh', name: 'DeepSeek Harness', icon: 'dsh', description: 'DeepSeek Harness(dsh)外壳:环境安装引导、版本更新与 Web 服务生命周期管理', category: 'tool', defaultEnabled: true, loader: () => import('./DshModule.vue'), searchItems, lifecycle: { // 模块启用:先刷新设置再恢复全局快捷键(启动时模块若被禁用,设置从未加载过), // 并按 autoStart 决定是否拉起服务。 onEnable: async () => { try { const { useDshStore } = await import('@/stores/dshStore') const store = useDshStore() await store.refresh() await store.registerShortcut() if (store.settings?.autoStart && !store.running) await store.start() } catch (e) { console.error('[dsh] onEnable 恢复失败:', e) } }, // 模块禁用:停服务 + 注销快捷键(服务停了快捷键也没意义,且组合键不该被占着) onDisable: async () => { // 动态导入避免 index.ts 直接依赖 store(会形成循环依赖,参见 terminal / music 的处理) try { const { useDshStore } = await import('@/stores/dshStore') const store = useDshStore() if (store.running) await store.stop() await store.unregisterShortcut() store.stopListeners() } catch (e) { console.error('[dsh] onDisable 停止服务失败:', e) } } }, // 排在开发工具之后:音乐 / 代理 / 下载 / 终端 / 翻译 / 监控 / 截图 / 剪贴板 / 快捷面板 / 开发工具 / dsh order: 110 }