011bd6d4ca
交付写作核心(TipTap、自动保存、分卷分章)、Onboarding、7 主题与双语 i18n、快捷键设置;主进程使用 node:sqlite;补全 Vitest 与 Playwright E2E;统一 design/ 目录并移除 desigin 拼写错误路径。 Co-authored-by: Cursor <cursoragent@cursor.com>
19 lines
690 B
TypeScript
19 lines
690 B
TypeScript
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('快捷键注册失败,可能与其他应用冲突')
|
|
})
|
|
)
|
|
}
|