From 9e3031dccc5c9f21c9420afe2132a726f413578b Mon Sep 17 00:00:00 2001 From: pipipi-pikachu Date: Thu, 6 Feb 2025 19:58:40 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E7=94=BB=E5=B8=83?= =?UTF-8?q?=E7=BC=A9=E6=94=BE=E5=BF=AB=E6=8D=B7=E9=94=AE=E8=A1=8C=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 1976a29a..f0e21a04 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()