From 700c3875c1e9250873bdbadc088e3cd47aa6dd55 Mon Sep 17 00:00:00 2001 From: fofolee Date: Sat, 21 May 2022 19:47:08 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=E5=BF=BD=E7=95=A5=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E4=B8=94=E4=B8=8D=E9=9A=90=E8=97=8F=20=E3=80=8D=E4=B8=8D?= =?UTF-8?q?=E9=80=80=E5=87=BA=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CommandRunResult.vue | 19 +++++++------------ src/js/options/outputTypes.js | 10 ++-------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/components/CommandRunResult.vue b/src/components/CommandRunResult.vue index 7552c44..c06fc41 100644 --- a/src/components/CommandRunResult.vue +++ b/src/components/CommandRunResult.vue @@ -134,17 +134,14 @@ export default { async fire(currentCommand) { currentCommand.cmd = this.assignSpecialVars(currentCommand.cmd); this.enableHtml = currentCommand.output === "html"; - let { hideWindow, outPlugin, action } = - outputTypes[currentCommand.output]; - // 需要隐藏的提前隐藏窗口 - hideWindow && utools.hideMainWindow(); + let { outPlugin, action } = outputTypes[currentCommand.output]; + let earlyExit = this.fromUtools && outPlugin; // 对于本身就没有输出的命令,无法确认命令是否执行完成,所以干脆提前退出插件 // 弊端就是如果勾选了隐藏后台就完全退出的话,会造成命令直接中断 - let earlyExit = this.fromUtools && outPlugin; - earlyExit && - setTimeout(() => { - utools.outPlugin(); - }, 500); + if (outPlugin) { + utools.hideMainWindow(); + !earlyExit || setTimeout(utools.outPlugin, 500); + } let resultOpts = { outPlugin, action, earlyExit }; switch (currentCommand.program) { case "quickcommand": @@ -268,9 +265,7 @@ export default { ? alert(stderr) : this.showRunResult(stderr, false); } - options.outPlugin - ? options.action(stdout.toString()) - : this.showRunResult(stdout, true); + !options.action(stdout.toString()) || this.showRunResult(stdout, true); }, // 显示运行结果 async showRunResult(content, isSuccess) { diff --git a/src/js/options/outputTypes.js b/src/js/options/outputTypes.js index cdbe74f..7fe5f70 100644 --- a/src/js/options/outputTypes.js +++ b/src/js/options/outputTypes.js @@ -7,7 +7,6 @@ const outputTypes = { name: "ignore", label: "忽略输出并隐藏", icon: "more_horiz", - hideWindow: true, outPlugin: true, action: result => null }, @@ -15,26 +14,24 @@ const outputTypes = { name: "nothing", label: "忽略输出且不隐藏", icon: "blur_linear", - outPlugin: true, action: result => null }, text: { name: "text", label: "纯文本输出", icon: "text_snippet", - action: result => result + action: result => true }, html: { name: "html", label: "html格式输出", icon: "html", - action: result => result + action: result => true }, terminal: { name: "terminal", label: "在终端显示", icon: "terminal", - hideWindow: true, outPlugin: true, action: result => null @@ -43,7 +40,6 @@ const outputTypes = { name: "clip", label: "复制到剪贴板", icon: "content_paste", - hideWindow: true, outPlugin: true, action: result => window.copyTo(result) }, @@ -51,7 +47,6 @@ const outputTypes = { name: "send", label: "发送到活动窗口", icon: "web_asset", - hideWindow: true, outPlugin: true, action: result => window.send(result) }, @@ -59,7 +54,6 @@ const outputTypes = { name: "notice", label: "发送系统通知", icon: "sms", - hideWindow: true, outPlugin: true, action: result => window.message(result) },