性能优化
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
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[] = [
|
||||
{
|
||||
@@ -21,11 +23,10 @@ export const moduleConfig: ModuleConfig = {
|
||||
lifecycle: {
|
||||
// 模块启用:读取设置并注册全局快捷键
|
||||
onEnable: async () => {
|
||||
const { invoke } = await import('@tauri-apps/api/core')
|
||||
try {
|
||||
const settings = await invoke<{ shortcut: string }>('quickpanel_get_settings')
|
||||
const settings = await commands.quickpanelGetSettings()
|
||||
if (settings.shortcut) {
|
||||
await invoke('quickpanel_register_shortcut', { shortcut: settings.shortcut })
|
||||
await commands.quickpanelRegisterShortcut(settings.shortcut)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[quickpanel] onEnable 注册快捷键失败:', e)
|
||||
@@ -33,9 +34,8 @@ export const moduleConfig: ModuleConfig = {
|
||||
},
|
||||
// 模块禁用:注销全局快捷键
|
||||
onDisable: async () => {
|
||||
const { invoke } = await import('@tauri-apps/api/core')
|
||||
try {
|
||||
await invoke('quickpanel_unregister_shortcut')
|
||||
await commands.quickpanelUnregisterShortcut()
|
||||
} catch (e) {
|
||||
console.error('[quickpanel] onDisable 注销快捷键失败:', e)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user