Files
Thing/src/modules/quickpanel/index.ts
T
2026-08-11 17:19:36 +08:00

71 lines
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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
}