mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-09 15:04:06 +08:00
结构调整
This commit is contained in:
parent
5c85e86b80
commit
7676441678
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user