From ace6f282d0f3d022f574eb48307f0d7e1403c9be Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 13 Jan 2024 09:46:06 +0800 Subject: [PATCH] fix the abnormal BUG that occurs when using Alt + F4 shortcut keys. --- src/App.vue | 5 ++++- src/utils/common.ts | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/App.vue b/src/App.vue index 0dfb2f4..517d57b 100644 --- a/src/App.vue +++ b/src/App.vue @@ -271,7 +271,10 @@ function keydown(e: any) { e.preventDefault(); } // 禁止关闭页面 - if (shortcutKey.toLowerCase() === "ctrl + w") { + if ( + shortcutKey.toLowerCase() === "ctrl + w" || + shortcutKey.toLowerCase() === "alt + f4" + ) { e.preventDefault(); } } diff --git a/src/utils/common.ts b/src/utils/common.ts index b4d9b23..a01fcc8 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -105,6 +105,7 @@ function checkKeyCode(e: any) { // e.keyCode == 16 Shift // e.keyCode == 17 Control // e.keyCode == 18 Alt + // e.keyCode == 91 Mate(Win) // e.keyCode == 20 Cape Lock 大小写 // e.keyCode == 27 Esc // (e.keyCode >= 32 && e.keyCode <= 40) 控制键盘区 @@ -125,6 +126,7 @@ function checkKeyCode(e: any) { e.keyCode === 16 || e.keyCode === 17 || e.keyCode === 18 || + e.keyCode === 91 || e.keyCode === 20 || e.keyCode === 27 || (e.keyCode >= 32 && e.keyCode <= 40) ||