结构调整

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