mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-07 21:46:12 +08:00
修复子输入框多次运行脚本BUG,发送文本时不再覆盖剪贴板
This commit is contained in:
parent
46a133804f
commit
1b65fafc95
@ -39,6 +39,10 @@ utools.onPluginEnter(({ code, type, payload }) => {
|
|||||||
};
|
};
|
||||||
setSubInput();
|
setSubInput();
|
||||||
document.addEventListener('keydown', handleEnter);
|
document.addEventListener('keydown', handleEnter);
|
||||||
|
// 移除监听
|
||||||
|
utools.onPluginOut(() => {
|
||||||
|
document.removeEventListener('keydown', handleEnter);
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
runCmd(cmd, option, db.codec, db.output);
|
runCmd(cmd, option, db.codec, db.output);
|
||||||
}
|
}
|
||||||
@ -47,15 +51,17 @@ utools.onPluginEnter(({ code, type, payload }) => {
|
|||||||
|
|
||||||
function runCmd(cmd, option, codec, output) {
|
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.outPlugin()
|
||||||
utools.hideMainWindow()
|
utools.hideMainWindow()
|
||||||
}
|
}
|
||||||
// 运行脚本
|
var terminal = false;
|
||||||
window.run(cmd, option, codec, (stdout, stderr) => {
|
if(output == 'terminal') terminal = true;
|
||||||
|
// 运行脚本
|
||||||
|
window.run(cmd, option, codec, terminal, (stdout, stderr) => {
|
||||||
if (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()
|
utools.outPlugin()
|
||||||
} else if (stdout) {
|
} else if (stdout) {
|
||||||
// 有输出
|
// 有输出
|
||||||
@ -70,8 +76,11 @@ function runCmd(cmd, option, codec, output) {
|
|||||||
copyTo(stdout);
|
copyTo(stdout);
|
||||||
break;
|
break;
|
||||||
case "send":
|
case "send":
|
||||||
|
// 暂存用户剪贴板
|
||||||
|
var historyData = storeClip();
|
||||||
copyTo(stdout);
|
copyTo(stdout);
|
||||||
paste();
|
paste();
|
||||||
|
restoreClip(historyData);
|
||||||
break;
|
break;
|
||||||
case "notice":
|
case "notice":
|
||||||
// 发送系统通知
|
// 发送系统通知
|
||||||
|
Loading…
x
Reference in New Issue
Block a user