import type { ModuleConfig } from '@/types/module' import type { SearchIndexItem } from '@/stores/searchIndex' // Rust 端通过 tauri-specta 生成的命令绑定(bindings.ts) import { commands } from '@/lib/bindings' const searchItems: SearchIndexItem[] = [ { title: '快速面板', description: '全局快捷键唤起命令面板', keywords: ['快速面板', '快速启动', '搜索', '命令', 'quickpanel', 'launcher', 'spotlight'] }, { title: '唤起快捷键', description: '配置全局快捷键打开快速面板', keywords: ['快捷键', '热键', 'shortcut', 'hotkey', '唤起', '打开'] }, { title: '唤起位置', description: '设置面板弹出位置(屏幕中央 / 鼠标位置)', keywords: ['位置', '弹出', '光标', 'position', 'popup'] }, { title: '默认搜索引擎', description: '设置快速面板网页搜索的搜索引擎', keywords: ['搜索引擎', '搜索', '引擎', 'search', 'engine', 'bing', 'google'] }, { title: '文件索引', description: '构建与管理本地文件搜索索引', keywords: ['文件', '索引', '搜索', 'index', '目录', 'file'] }, { title: '自定义命令', description: '添加自定义启动命令', keywords: ['自定义', '命令', 'command', '启动'] } ] export const moduleConfig: ModuleConfig = { id: 'quickpanel', name: '快速面板', icon: 'quickpanel', description: '全局快捷键唤起的多源命令面板(命令/应用/文件/计算)', category: 'tool', defaultEnabled: true, loader: () => import('./QuickPanelModule.vue'), searchItems, lifecycle: { // 模块启用:读取设置并注册全局快捷键 onEnable: async () => { try { const settings = await commands.quickpanelGetSettings() if (settings.shortcut) { await commands.quickpanelRegisterShortcut(settings.shortcut) } } catch (e) { console.error('[quickpanel] onEnable 注册快捷键失败:', e) } }, // 模块禁用:注销全局快捷键 onDisable: async () => { try { await commands.quickpanelUnregisterShortcut() } catch (e) { console.error('[quickpanel] onDisable 注销快捷键失败:', e) } } }, order: 60 }