快速面板模块
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import type { ModuleConfig } from '@/types/module'
|
||||
import type { SearchIndexItem } from '@/stores/searchIndex'
|
||||
|
||||
const searchItems: SearchIndexItem[] = [
|
||||
{
|
||||
title: '快速面板',
|
||||
description: '全局快捷键唤起命令面板',
|
||||
keywords: ['快速面板', '快速启动', '搜索', '命令', 'quickpanel', 'launcher', 'spotlight']
|
||||
}
|
||||
]
|
||||
|
||||
export const moduleConfig: ModuleConfig = {
|
||||
id: 'quickpanel',
|
||||
name: '快速面板',
|
||||
icon: 'quickpanel',
|
||||
description: '全局快捷键唤起的多源命令面板(命令/应用/文件/计算)',
|
||||
category: 'tool',
|
||||
defaultEnabled: true,
|
||||
loader: () => import('./QuickPanelModule.vue'),
|
||||
searchItems,
|
||||
lifecycle: {
|
||||
// 模块启用:读取设置并注册全局快捷键
|
||||
onEnable: async () => {
|
||||
const { invoke } = await import('@tauri-apps/api/core')
|
||||
try {
|
||||
const settings = await invoke<{ shortcut: string }>('quickpanel_get_settings')
|
||||
if (settings.shortcut) {
|
||||
await invoke('quickpanel_register_shortcut', { shortcut: settings.shortcut })
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[quickpanel] onEnable 注册快捷键失败:', e)
|
||||
}
|
||||
},
|
||||
// 模块禁用:注销全局快捷键
|
||||
onDisable: async () => {
|
||||
const { invoke } = await import('@tauri-apps/api/core')
|
||||
try {
|
||||
await invoke('quickpanel_unregister_shortcut')
|
||||
} catch (e) {
|
||||
console.error('[quickpanel] onDisable 注销快捷键失败:', e)
|
||||
}
|
||||
}
|
||||
},
|
||||
order: 60
|
||||
}
|
||||
Reference in New Issue
Block a user