From a2c5bcc90cafbe30e66f1dbfb372c6400358d790 Mon Sep 17 00:00:00 2001 From: layyback <505187749@qq.com> Date: Thu, 18 Jul 2024 18:58:34 +0800 Subject: [PATCH] :sparkles: add new keyboard events --- src/renderer/App.vue | 18 ++++-------------- src/renderer/components/search.vue | 13 +++++++++---- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 01d0c3b..ba57984 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -103,22 +103,12 @@ watch( ); const changeIndex = (index) => { - if (!options.value.length) { - if (!pluginHistory.value.length) return; - if ( - currentSelect.value + index > pluginHistory.value.length - 1 || - currentSelect.value + index < 0 - ) { - currentSelect.value = 0; - return; - } - currentSelect.value = currentSelect.value + index; - return; - } - if (currentSelect.value + index > options.value.length - 1) { + const len = options.value.length || pluginHistory.value.length; + if (!len) return; + if (currentSelect.value + index > len - 1) { currentSelect.value = 0; } else if (currentSelect.value + index < 0) { - currentSelect.value = options.value.length - 1; + currentSelect.value = len - 1; } else { currentSelect.value = currentSelect.value + index; } diff --git a/src/renderer/components/search.vue b/src/renderer/components/search.vue index 83c5a51..9e424c9 100644 --- a/src/renderer/components/search.vue +++ b/src/renderer/components/search.vue @@ -25,6 +25,8 @@ ref="mainInput" class="main-input" @input="(e) => changeValue(e)" + @keydown.left="(e) => keydownEvent(e, 'left')" + @keydown.right="(e) => keydownEvent(e, 'right')" @keydown.down="(e) => keydownEvent(e, 'down')" @keydown.tab="(e) => keydownEvent(e, 'down')" @keydown.up="(e) => keydownEvent(e, 'up')" @@ -41,10 +43,7 @@ > @@ -120,6 +119,12 @@ const keydownEvent = (e, key: string) => { case 'down': emit('changeCurrent', 1); break; + case 'left': + emit('changeCurrent', -1); + break; + case 'right': + emit('changeCurrent', 1); + break; case 'enter': if (runPluginDisable) return; emit('choosePlugin');