import { ipcMain } from 'electron' import { IPC } from '../../../shared/ipc-channels' import type { ActionId } from '../../../shared/types' import { ShortcutManager } from '../shortcuts/manager' import { wrap } from '../result' export function registerShortcutHandlers(shortcuts: ShortcutManager): void { ipcMain.handle(IPC.SHORTCUT_GET_ALL, () => wrap(() => shortcuts.getAll())) ipcMain.handle( IPC.SHORTCUT_REGISTER, (_event, { action, accelerator }: { action: ActionId; accelerator: string }) => wrap(() => { const ok = shortcuts.save(action, accelerator) if (!ok) throw new Error('快捷键注册失败,可能与其他应用冲突') }) ) }