From 1b65fafc95595b627838981ef7117e4dcd325f91 Mon Sep 17 00:00:00 2001 From: fofolee Date: Thu, 9 Apr 2020 18:07:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AD=90=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=A1=86=E5=A4=9A=E6=AC=A1=E8=BF=90=E8=A1=8C=E8=84=9A=E6=9C=AC?= =?UTF-8?q?BUG=EF=BC=8C=E5=8F=91=E9=80=81=E6=96=87=E6=9C=AC=E6=97=B6?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E8=A6=86=E7=9B=96=E5=89=AA=E8=B4=B4=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/index.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/assets/index.js b/assets/index.js index bb7934a..ac2e9f7 100644 --- a/assets/index.js +++ b/assets/index.js @@ -39,6 +39,10 @@ utools.onPluginEnter(({ code, type, payload }) => { }; setSubInput(); document.addEventListener('keydown', handleEnter); + // 移除监听 + utools.onPluginOut(() => { + document.removeEventListener('keydown', handleEnter); + }) } else { runCmd(cmd, option, db.codec, db.output); } @@ -47,15 +51,17 @@ utools.onPluginEnter(({ code, type, payload }) => { function runCmd(cmd, option, codec, output) { // 不需要输出的,提前关闭窗口 - if (['ignore', 'clip', 'send', 'notice'].indexOf(output) !== -1){ + if (['ignore', 'clip', 'send', 'notice', 'terminal'].indexOf(output) !== -1){ utools.outPlugin() utools.hideMainWindow() } - // 运行脚本 - window.run(cmd, option, codec, (stdout, stderr) => { + var terminal = false; + if(output == 'terminal') terminal = true; + // 运行脚本 + window.run(cmd, option, codec, terminal, (stdout, stderr) => { if (stderr) { // 报错 - window.messageBox({ type: 'error', icon: window.logo, message: stderr, buttons: ['纳尼?!'] }) + window.messageBox({ type: 'error', icon: window.logo, message: stderr, buttons: ['啊嘞?!'] }) utools.outPlugin() } else if (stdout) { // 有输出 @@ -70,8 +76,11 @@ function runCmd(cmd, option, codec, output) { copyTo(stdout); break; case "send": + // 暂存用户剪贴板 + var historyData = storeClip(); copyTo(stdout); paste(); + restoreClip(historyData); break; case "notice": // 发送系统通知