结构调整

This commit is contained in:
fofolee 2022-04-29 17:43:40 +08:00
parent 5c85e86b80
commit 7676441678

View File

@ -109,8 +109,8 @@ export default {
hideWindow && utools.hideMainWindow();
// 退
// 退
let quitBeforeShowResult = this.fromUtools && outPlugin;
quitBeforeShowResult &&
let earlyExit = this.fromUtools && outPlugin;
earlyExit &&
setTimeout(() => {
utools.outPlugin();
}, 500);
@ -118,14 +118,7 @@ export default {
window.runCodeInSandbox(
currentCommand.cmd,
(stdout, stderr) => {
if (stderr) {
return quitBeforeShowResult
? alert(stderr)
: this.showRunResult(stderr, false, action);
}
outPlugin
? action(stdout.toString())
: this.showRunResult(stdout, true);
this.handleResult(stdout, stderr, { outPlugin, action, earlyExit });
},
{ enterData: this.$root.enterData }
);
@ -143,14 +136,7 @@ export default {
option,
currentCommand.output === "terminal",
(stdout, stderr) => {
if (stderr) {
return quitBeforeShowResult
? alert(stderr)
: this.showRunResult(stderr, false, action);
}
outPlugin
? action(stdout.toString())
: this.showRunResult(stdout, true);
this.handleResult(stdout, stderr, { outPlugin, action, earlyExit });
}
);
// ctrl c
@ -235,6 +221,16 @@ export default {
payload: await commandTypes[type]?.tempPayload?.(),
};
},
handleResult(stdout, stderr, options) {
if (stderr) {
return options.earlyExit
? alert(stderr)
: this.showRunResult(stderr, false);
}
options.outPlugin
? options.action(stdout.toString())
: this.showRunResult(stdout, true);
},
//
showRunResult(content, isSuccess) {
this.isResultShow = true;