修复 subinput 和 selectList 的冲突

This commit is contained in:
fofolee 2022-05-17 21:50:30 +08:00
parent 2c6076c5ee
commit b0a9f07e3c
3 changed files with 11 additions and 7 deletions

View File

@ -28,6 +28,7 @@ export default defineComponent({
utools: UTOOLS, utools: UTOOLS,
cronJobs: {}, cronJobs: {},
enterData: {}, enterData: {},
subInputEvent: null,
}; };
}, },
created: function () { created: function () {

View File

@ -84,7 +84,6 @@ export default {
runResult: [], runResult: [],
runResultStatus: true, runResultStatus: true,
subInputValue: "", subInputValue: "",
subInputListener: null,
ctrlCListener: null, ctrlCListener: null,
quickcommandListener: null, quickcommandListener: null,
history: [], history: [],
@ -226,7 +225,7 @@ export default {
setTimeout(() => { setTimeout(() => {
if (this.subInputValue) querySubInput(); if (this.subInputValue) querySubInput();
}, 100); }, 100);
this.subInputListener = (event) => { let listener = (event) => {
event.preventDefault(); event.preventDefault();
switch (event.keyCode) { switch (event.keyCode) {
case 13: case 13:
@ -248,7 +247,8 @@ export default {
break; break;
} }
}; };
document.addEventListener("keydown", this.subInputListener, true); this.$root.subInputEvent = ["keydown", listener, true];
document.addEventListener(...this.$root.subInputEvent);
}, },
// payload // payload
async getTempPayload(currentCommand) { async getTempPayload(currentCommand) {
@ -308,10 +308,10 @@ export default {
}, },
stopRun() { stopRun() {
this.runResult = []; this.runResult = [];
if (!!this.subInputListener) { if (!!this.$root.subInputEvent) {
this.subInputValue = ""; this.subInputValue = "";
utools.removeSubInput(); utools.removeSubInput();
document.removeEventListener("keydown", this.subInputListener, true); document.removeEventListener(...this.$root.subInputEvent);
} }
this.clear(); this.clear();
this.frameInitHeight = 0; this.frameInitHeight = 0;

View File

@ -205,12 +205,15 @@ export default {
clear() { clear() {
utools.removeSubInput(); utools.removeSubInput();
document.removeEventListener("keydown", this.keyHandler); document.removeEventListener("keydown", this.keyHandler, true);
this.setUtoolsHeight(this.listMaxHeight); this.setUtoolsHeight(this.listMaxHeight);
}, },
addListeners() { addListeners() {
document.addEventListener("keydown", this.keyHandler); //
if (this.$root.subInputEvent)
document.removeEventListener(...this.$root.subInputEvent);
document.addEventListener("keydown", this.keyHandler, true);
}, },
}, },
}; };