Update: 更新Mixly.Electron.Shell

This commit is contained in:
王立帮
2024-08-24 02:38:37 +08:00
parent e1246aee3f
commit 8c598e50b7

View File

@@ -21,6 +21,7 @@ class Shell {
} }
#shell_ = null; #shell_ = null;
#killed_ = false;
constructor() {} constructor() {}
#addEventsListener_() { #addEventsListener_() {
@@ -60,6 +61,10 @@ class Shell {
}); });
this.#addEventsListener_(); this.#addEventsListener_();
this.#shell_.on('close', (code) => { this.#shell_.on('close', (code) => {
this.#killed_ = true;
if (code === null) {
code = 1;
}
const endTime = Number(new Date()); const endTime = Number(new Date());
const duration = dayjs.duration(endTime - startTime).format('HH:mm:ss.SSS'); const duration = dayjs.duration(endTime - startTime).format('HH:mm:ss.SSS');
const info = { code, time: duration }; const info = { code, time: duration };
@@ -69,6 +74,9 @@ class Shell {
} }
kill() { kill() {
if (this.#killed_) {
return;
}
this.#shell_.stdin.end(); this.#shell_.stdin.end();
this.#shell_.stdout.end(); this.#shell_.stdout.end();
if (Env.currentPlatform === 'win32') { if (Env.currentPlatform === 'win32') {