Skip to content

Commit

Permalink
✨ add new keyboard events
Browse files Browse the repository at this point in the history
  • Loading branch information
layyback committed Jul 18, 2024
1 parent b9f4333 commit a2c5bcc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
18 changes: 4 additions & 14 deletions src/renderer/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
13 changes: 9 additions & 4 deletions src/renderer/components/search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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')"
Expand All @@ -41,10 +43,7 @@
>
<template #suffix>
<div class="suffix-tool">
<MoreOutlined
@click="showSeparate()"
class="icon-more"
/>
<MoreOutlined @click="showSeparate()" class="icon-more" />
</div>
</template>
</a-input>
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit a2c5bcc

Please sign in to comment.