From 7802d359c4969050a41f19044a66c949b82b76ee Mon Sep 17 00:00:00 2001 From: sunyuqiang <1129921824@qq.com> Date: Sat, 24 Jun 2023 11:35:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96-=E5=85=A8=E5=B1=80=E5=BF=AB?= =?UTF-8?q?=E6=8D=B7=E9=94=AE=E4=BC=98=E5=8C=96=E5=8F=8A=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=9B=B4=E6=AD=A3=E9=94=99=E5=88=AB=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feature/src/views/settings/index.vue | 62 ++++++++++++++-------------- src/main/common/registerHotKey.ts | 2 +- 2 files changed, 31 insertions(+), 33 deletions(-) diff --git a/feature/src/views/settings/index.vue b/feature/src/views/settings/index.vue index 72f5b47..c47534a 100644 --- a/feature/src/views/settings/index.vue +++ b/feature/src/views/settings/index.vue @@ -213,6 +213,10 @@ const examples = [ title: '快捷键 「 Alt + Q」 关键字 「 取色」', desc: '按下Alt + Q 直接打开屏幕取色功能', }, + { + title: '快捷键 「 Ctrl + Alt + Q」 关键字 「 截屏」', + desc: '按下 Ctrl + Alt + Q 进行截屏', + }, ]; const state = reactive({ @@ -255,43 +259,29 @@ const setConfig = debounce(() => { watch(state, setConfig); -const changeShortCutOld = (e, key) => { - if (e.altKey && e.keyCode !== 18) { - const compose = `Option+${keycodes[e.keyCode].toUpperCase()}`; - state.shortCut[key] = compose; - } - if (e.ctrlKey && e.keyCode !== 17) { - const compose = `Ctrl+${keycodes[e.keyCode].toUpperCase()}`; - state.shortCut[key] = compose; - } - if (e.shiftKey && e.keyCode !== 16) { - const compose = `Shift+${keycodes[e.keyCode].toUpperCase()}`; - state.shortCut[key] = compose; - } - if (e.metaKey && e.keyCode !== 93) { - const compose = `Command+${keycodes[e.keyCode].toUpperCase()}`; - state.shortCut[key] = compose; - } -}; - const changeShortCut = (e, key) => { let compose = ''; + // 添加是否包含功能键的判断 + let incluFuncKeys = false; if (e.ctrlKey && e.keyCode !== 17) { compose += '+Ctrl'; + incluFuncKeys = true; } if (e.shiftKey && e.keyCode !== 16) { compose += '+Shift'; + incluFuncKeys = true; } if (e.altKey && e.keyCode !== 18) { compose += '+Option'; + incluFuncKeys = true; } if (e.metaKey && e.keyCode !== 93) { compose += '+Command'; + incluFuncKeys = true; } compose += '+'+keycodes[e.keyCode].toUpperCase(); compose = compose.substring(1) - console.log(compose); - if(e.keyCode !== 16 && e.keyCode !== 17 && e.keyCode !== 18 && e.keyCode !== 93){ + if(incluFuncKeys && e.keyCode !== 16 && e.keyCode !== 17 && e.keyCode !== 18 && e.keyCode !== 93){ state.shortCut[key] = compose; }else{ // 不做处理 @@ -299,27 +289,35 @@ const changeShortCut = (e, key) => { }; const changeGlobalKey = (e, index) => { - let compose; - if (e.altKey && e.keyCode !== 18) { - compose = `Alt+${keycodes[e.keyCode].toUpperCase()}`; - } + let compose = ''; + // 添加是否包含功能键的判断 + let incluFuncKeys = false; if (e.ctrlKey && e.keyCode !== 17) { - compose = `Ctrl+${keycodes[e.keyCode].toUpperCase()}`; + compose += '+Ctrl'; + incluFuncKeys = true; } if (e.shiftKey && e.keyCode !== 16) { - compose = `Shift+${keycodes[e.keyCode].toUpperCase()}`; + compose += '+Shift'; + incluFuncKeys = true; + } + if (e.altKey && e.keyCode !== 18) { + compose += '+Option'; + incluFuncKeys = true; } if (e.metaKey && e.keyCode !== 93) { - compose = `Command+${keycodes[e.keyCode].toUpperCase()}`; + compose += '+Command'; + incluFuncKeys = true; } - if (compose) { + compose += '+' + keycodes[e.keyCode].toUpperCase(); + compose = compose.substring(1) + if (incluFuncKeys && e.keyCode !== 16 && e.keyCode !== 17 && e.keyCode !== 18 && e.keyCode !== 93) { state.global[index].key = compose; + } else { + // 不做处理 } // f1 - f12 - if (e.keyCode >= 112 && e.keyCode <= 123) { + if (!incluFuncKeys && e.keyCode >= 112 && e.keyCode <= 123) { compose = keycodes[e.keyCode].toUpperCase(); - } - if (compose) { state.global[index].key = compose; } }; diff --git a/src/main/common/registerHotKey.ts b/src/main/common/registerHotKey.ts index a3d6160..48d7064 100644 --- a/src/main/common/registerHotKey.ts +++ b/src/main/common/registerHotKey.ts @@ -84,7 +84,7 @@ const registerHotKey = (mainWindow: BrowserWindow): void => { data && new Notification({ title: '截图完成', - body: '截图以存储到系统剪贴板中', + body: '截图已存储到系统剪贴板中', }).show(); }); });