关闭窗口自动杀进程

This commit is contained in:
fofolee
2022-04-22 22:28:24 +08:00
parent 76dd321ff6
commit 2b84ebdda3
5 changed files with 48 additions and 23 deletions

View File

@@ -59,6 +59,7 @@ export default {
history: [],
historyIdx: null,
enableHtml: false,
child: null,
};
},
props: {
@@ -122,7 +123,7 @@ export default {
: this.$root.programs[currentCommand.program];
option.scptarg = currentCommand.scptarg || "";
option.charset = currentCommand.charset || {};
window.runCodeFile(
this.child = window.runCodeFile(
currentCommand.cmd,
option,
currentCommand.output === "terminal",
@@ -237,6 +238,9 @@ export default {
},
stopRun() {
this.runResult = "";
if (!!this.child) {
quickcommand.kill(this.child.pid);
}
if (!!this.listener) {
this.subInputValue = "";
utools.removeSubInput();

View File

@@ -256,11 +256,15 @@ interface quickcommandApi {
loadRemoteScript(url: string): Promise<object>;
/**
* 将 signal 发送给 pid 标识的进程 , 默认为关闭进程同process.kill
* 将 signal 发送给 pid 标识的进程 , 默认为关闭进程
*
* 不同于process.kill会将该进程启用的所有子进程也杀死
*
* @param pid 进程 ID
* @param signal 进程信号默认为SIGTERM
* @param callback 失败时的回调
*/
kill(pid: number, signal?: number | string): void;
kill(pid: number, signal?: string | number, callback?: (error?: Error) => void): void;
/**
* windows 下运行 VBS 脚本并返回运行结果