ctrlC 终止命令

This commit is contained in:
fofolee 2022-04-28 23:21:59 +08:00
parent 01276cb61b
commit 39444201a3

View File

@ -61,6 +61,7 @@ export default {
runResultStatus: true,
subInputValue: "",
subInputListener: null,
ctrlCListener: null,
quickcommandListener: null,
history: [],
historyIdx: null,
@ -152,6 +153,15 @@ export default {
: this.showRunResult(stdout, true);
}
);
// ctrl c
this.ctrlCListener = (e) => {
if (e.key === "c" && e.ctrlKey) {
quickcommand.kill(this.childProcess.pid);
quickcommand.showMessageBox("命令已终止");
document.removeEventListener("keydown", this.ctrlCListener);
}
};
document.addEventListener("keydown", this.ctrlCListener);
}
},
//
@ -260,9 +270,8 @@ export default {
this.clear();
},
clear() {
if (!!this.childProcess) {
quickcommand.kill(this.childProcess.pid);
}
!!this.ctrlCListener &&
document.removeEventListener("keydown", this.ctrlCListener);
quickcommand.removeListener();
quickcommand.closeWaitButton();
},