mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-07 21:46:12 +08:00
修复不显示文本 和 html 输出的 bug
This commit is contained in:
parent
6f05af1afd
commit
5126f414bf
@ -8,7 +8,7 @@ utools.onPluginEnter(({ code, type, payload }) => {
|
||||
showOptions();
|
||||
} else {
|
||||
$("#options").hide();
|
||||
$("#out").show();
|
||||
$("#out").show().text('');
|
||||
var db = utools.db.get('customFts').data[code],
|
||||
cmd = db.cmd;
|
||||
if (db.program == "custom") {
|
||||
@ -40,51 +40,50 @@ utools.onPluginEnter(({ code, type, payload }) => {
|
||||
setSubInput();
|
||||
document.addEventListener('keydown', handleEnter);
|
||||
} else {
|
||||
utools.setExpendHeight(0);
|
||||
utools.hideMainWindow();
|
||||
runCmd(cmd, option, db.codec, db.output);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
utools.onPluginOut(_ => {
|
||||
$("#out").text('');
|
||||
})
|
||||
|
||||
function runCmd(cmd, option, codec, output) {
|
||||
// 不需要输出的,提前关闭窗口
|
||||
if (['ignore', 'clip', 'send'].indexOf(output) !== -1){
|
||||
utools.outPlugin()
|
||||
utools.hideMainWindow()
|
||||
}
|
||||
// 运行脚本
|
||||
window.run(cmd, option, codec, (stdout, stderr) => {
|
||||
// 报错
|
||||
if (stderr) {
|
||||
// 报错
|
||||
window.messageBox({ type: 'error', icon: window.logo, message: stderr, buttons: ['纳尼?!'] })
|
||||
utools.outPlugin();
|
||||
return;
|
||||
}
|
||||
// 有输出
|
||||
if (stdout) {
|
||||
utools.outPlugin()
|
||||
} else if (stdout) {
|
||||
// 有输出
|
||||
switch (output) {
|
||||
case "ignore":
|
||||
utools.outPlugin();
|
||||
break;
|
||||
case "text":
|
||||
utools.showMainWindow();
|
||||
utools.setExpendHeight(600);
|
||||
$("#out").text(stdout);
|
||||
break;
|
||||
case "html":
|
||||
utools.showMainWindow();
|
||||
utools.setExpendHeight(600);
|
||||
$("#out").html(stdout);
|
||||
break;
|
||||
case "clip":
|
||||
copyTo(stdout);
|
||||
utools.outPlugin();
|
||||
break;
|
||||
case "send":
|
||||
copyTo(stdout);
|
||||
paste();
|
||||
utools.outPlugin();
|
||||
break;
|
||||
case "ignore":
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// 无输出
|
||||
} else {
|
||||
utools.outPlugin();
|
||||
// 无输出
|
||||
utools.outPlugin()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ const { shell } = require('electron');
|
||||
|
||||
pluginInfo = JSON.parse(fs.readFileSync(path.join(__dirname, 'plugin.json')));
|
||||
logo = nativeImage.createFromPath(path.join(__dirname, 'logo.png'));
|
||||
|
||||
// fix PATH
|
||||
process.env.PATH += ':/usr/local/bin:/usr/local/sbin'
|
||||
|
||||
messageBox = (options, callback) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user