From c87703df221c5d837ab645c32ceecbfda61cf8f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E4=BA=91=E8=8B=8D=E7=8B=97?= <31614024+MaLuns@users.noreply.github.com> Date: Thu, 6 Feb 2025 13:24:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E7=94=BB=E5=B8=83=E7=BC=A9=E6=94=BE?= =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E4=B8=8E=E6=96=87=E6=A1=A3=E8=AF=B4=E6=98=8E?= =?UTF-8?q?=E4=B8=8D=E4=B8=80=E8=87=B4=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useGlobalHotkey.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/hooks/useGlobalHotkey.ts b/src/hooks/useGlobalHotkey.ts index 607065f06..1976a29a1 100644 --- a/src/hooks/useGlobalHotkey.ts +++ b/src/hooks/useGlobalHotkey.ts @@ -158,7 +158,16 @@ export default () => { return } - if (!editorAreaFocus.value && !thumbnailsFocus.value) return + if (!editorAreaFocus.value && !thumbnailsFocus.value) { + if ( + !disableHotkeys.value && + ((ctrlOrMetaKeyActive && key === KEYS.MINUS) || (ctrlOrMetaKeyActive && key === KEYS.EQUAL)) + ) { + // 禁止浏览器默认缩放 + e.preventDefault() + } + return + } if (ctrlOrMetaKeyActive && key === KEYS.C) { if (disableHotkeys.value) return @@ -255,17 +264,17 @@ export default () => { e.preventDefault() create() } - if (key === KEYS.MINUS) { + if (ctrlOrMetaKeyActive && key === KEYS.MINUS) { if (disableHotkeys.value) return e.preventDefault() scaleCanvas('-') } - if (key === KEYS.EQUAL) { + if (ctrlOrMetaKeyActive && key === KEYS.EQUAL) { if (disableHotkeys.value) return e.preventDefault() scaleCanvas('+') } - if (key === KEYS.DIGIT_0) { + if (ctrlOrMetaKeyActive && key === KEYS.DIGIT_0) { if (disableHotkeys.value) return e.preventDefault() resetCanvas() @@ -317,4 +326,4 @@ export default () => { document.removeEventListener('keyup', keyupListener) window.removeEventListener('blur', keyupListener) }) -} \ No newline at end of file +} From 9e3031dccc5c9f21c9420afe2132a726f413578b Mon Sep 17 00:00:00 2001 From: pipipi-pikachu Date: Thu, 6 Feb 2025 19:58:40 +0800 Subject: [PATCH 2/2] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E7=94=BB?= =?UTF-8?q?=E5=B8=83=E7=BC=A9=E6=94=BE=E5=BF=AB=E6=8D=B7=E9=94=AE=E8=A1=8C?= =?UTF-8?q?=E4=B8=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useGlobalHotkey.ts | 39 ++++++++++++++---------------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/src/hooks/useGlobalHotkey.ts b/src/hooks/useGlobalHotkey.ts index 1976a29a1..f0e21a04b 100644 --- a/src/hooks/useGlobalHotkey.ts +++ b/src/hooks/useGlobalHotkey.ts @@ -157,17 +157,23 @@ export default () => { mainStore.setSearchPanelState(!showSearchPanel.value) return } - - if (!editorAreaFocus.value && !thumbnailsFocus.value) { - if ( - !disableHotkeys.value && - ((ctrlOrMetaKeyActive && key === KEYS.MINUS) || (ctrlOrMetaKeyActive && key === KEYS.EQUAL)) - ) { - // 禁止浏览器默认缩放 - e.preventDefault() - } + if (ctrlKey && key === KEYS.MINUS) { + e.preventDefault() + scaleCanvas('-') return } + if (ctrlKey && key === KEYS.EQUAL) { + e.preventDefault() + scaleCanvas('+') + return + } + if (ctrlKey && key === KEYS.DIGIT_0) { + e.preventDefault() + resetCanvas() + return + } + + if (!editorAreaFocus.value && !thumbnailsFocus.value) return if (ctrlOrMetaKeyActive && key === KEYS.C) { if (disableHotkeys.value) return @@ -264,21 +270,6 @@ export default () => { e.preventDefault() create() } - if (ctrlOrMetaKeyActive && key === KEYS.MINUS) { - if (disableHotkeys.value) return - e.preventDefault() - scaleCanvas('-') - } - if (ctrlOrMetaKeyActive && key === KEYS.EQUAL) { - if (disableHotkeys.value) return - e.preventDefault() - scaleCanvas('+') - } - if (ctrlOrMetaKeyActive && key === KEYS.DIGIT_0) { - if (disableHotkeys.value) return - e.preventDefault() - resetCanvas() - } if (key === KEYS.TAB) { if (disableHotkeys.value) return e.preventDefault()