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