diff --git a/apps/web/src-election/main/index.ts b/apps/web/src-election/main/index.ts index 146cf95..626fd45 100644 --- a/apps/web/src-election/main/index.ts +++ b/apps/web/src-election/main/index.ts @@ -251,13 +251,6 @@ function regShortcut() { ); screenshots.startCapture(); }); - - globalShortcut.register("esc", () => { - if (screenshots.$win?.isFocused()) { - screenshots.endCapture(); - } - }); - // 打开所有窗口控制台 globalShortcut.register("ctrl+shift+i", () => { let windows = BrowserWindow.getAllWindows(); @@ -383,6 +376,21 @@ app.on("ready", () => { } }; + // 截图添加快捷键esc + screenshots.on('windowCreated', ($win) => { + $win.on('focus', () => { + globalShortcut.register('esc', () => { + if ($win?.isFocused()) { + screenshots.endCapture(); + } + }); + }); + + $win.on('blur', () => { + globalShortcut.unregister('esc'); + }); + }); + // 点击确定按钮回调事件 screenshots.on("ok", (e, buffer, bounds) => { let filename = tmp.tmpNameSync() + '.png'; diff --git a/packages/tsdaodaobase/src/Components/UserInfo/vm.tsx b/packages/tsdaodaobase/src/Components/UserInfo/vm.tsx index 608c8d4..58d44e7 100644 --- a/packages/tsdaodaobase/src/Components/UserInfo/vm.tsx +++ b/packages/tsdaodaobase/src/Components/UserInfo/vm.tsx @@ -242,4 +242,4 @@ export class UserInfoVM extends ProviderListener { this.notifyListener(); } } -} +} \ No newline at end of file