M0-M11 狩夜人笔记初始实现:11里程碑+86测试

This commit is contained in:
hunter-dev
2026-08-24 20:35:22 +08:00
commit 3ebd33536b
106 changed files with 10490 additions and 0 deletions
@@ -0,0 +1,13 @@
import { useEffect } from 'react';
import hotkeys from 'hotkeys-js';
export function useGlobalHotkeys(opts: { onNewDoc: () => void; onSave: () => void; onFocusSearch: () => void; onToggleOutline: () => void; onCheat: () => void; onSettings: () => void }) {
useEffect(() => {
hotkeys('ctrl+n', e => { e.preventDefault(); opts.onNewDoc(); });
hotkeys('ctrl+s', e => { e.preventDefault(); opts.onSave(); });
hotkeys('ctrl+shift+f', e => { e.preventDefault(); opts.onFocusSearch(); });
hotkeys('ctrl+shift+l', e => { e.preventDefault(); opts.onToggleOutline(); });
hotkeys('?', e => { if (document.activeElement?.tagName !== 'INPUT' && document.activeElement?.tagName !== 'TEXTAREA') { e.preventDefault(); opts.onCheat(); } });
return () => { hotkeys.unbind('ctrl+n'); hotkeys.unbind('ctrl+s'); hotkeys.unbind('ctrl+shift+f'); hotkeys.unbind('ctrl+shift+l'); hotkeys.unbind('?'); };
}, [opts.onNewDoc, opts.onSave, opts.onFocusSearch, opts.onToggleOutline, opts.onCheat, opts.onSettings]);
}