Skip to content

Commit 9d14f31

Browse files
committed
修复: 优化命令提示与原生的上下键搜索的兼容 #45
1 parent f891b40 commit 9d14f31

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

ui/src/views/shell/terminal/index.vue

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ const handleContextRightClickMenu = e => {
217217
/* 下拉菜单 */
218218
const showSearchDropdownRef = ref(false);
219219
const searchDropdownOptions = ref([]);
220-
let isInMenuSelection = false;
221220
222221
const getCurrentCursorIndex = () => {
223222
return term.buffer.normal.cursorX;
@@ -317,7 +316,6 @@ const handleSearchSelect = (key, option) => {
317316
}
318317
319318
showSearchDropdownRef.value = false;
320-
isInMenuSelection = false;
321319
};
322320
323321
async function initConnect() {
@@ -376,7 +374,6 @@ const hideDropdownMenu = e => {
376374
if (e?.toElement?.className.indexOf('n-dropdown') !== -1) {
377375
return;
378376
}
379-
isInMenuSelection = false;
380377
showSearchDropdownRef.value = false;
381378
searchDropdownOptions.value = [];
382379
};
@@ -588,7 +585,7 @@ onMounted(() => {
588585
};
589586
590587
const onUpAndDownKeysHandle = () => {
591-
if (showSearchDropdownRef.value) {
588+
if (showSearchDropdownRef.value===true) {
592589
return;
593590
}
594591
isOnInputData = false;
@@ -611,23 +608,15 @@ onMounted(() => {
611608
case '40':
612609
case '\u001bOB':
613610
case '\u001bOA':
614-
onUpAndDownKeysHandle();
611+
isOnInputData = false;
615612
break;
616613
default:
617614
isOnInputData = true;
618615
}
619616
620617
webSocket?.sendJsonMessage(new Msg(channelId, data, MessageType.CMD));
621618
});
622-
watch(
623-
() => showSearchDropdownRef.value,
624-
() => {
625-
if (!showSearchDropdownRef.value) {
626-
isInMenuSelection = false;
627-
}
628-
},
629-
{ immediate: true }
630-
);
619+
631620
632621
term.attachCustomKeyEventHandler(e => {
633622
const { keyCode, ctrlKey,shiftKey } = e;
@@ -655,11 +644,8 @@ onMounted(() => {
655644
return true;
656645
}
657646
658-
if (moveKey.includes(keyCode) && showSearchDropdownRef.value) {
659-
isInMenuSelection = true;
660-
}
661647
662-
if (isInMenuSelection && menuKeyCodes.includes(keyCode)) {
648+
if (showSearchDropdownRef.value === true && menuKeyCodes.includes(keyCode)) {
663649
if (keyCode === 27) {
664650
showSearchDropdownRef.value = false;
665651
}

0 commit comments

Comments
 (0)