mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 06:16:27 +08:00
commit
a891952283
@ -7,8 +7,6 @@ utools.onPluginEnter(({ code, type, payload }) => {
|
||||
$("#options").show();
|
||||
showOptions();
|
||||
} else {
|
||||
utools.setExpendHeight(0);
|
||||
utools.hideMainWindow();
|
||||
$("#options").hide();
|
||||
$("#out").show();
|
||||
var db = utools.db.get('customFts').data[code],
|
||||
@ -22,8 +20,36 @@ utools.onPluginEnter(({ code, type, payload }) => {
|
||||
if (type == 'over') cmd = cmd.replace(/\{\{input\}\}/mg, payload);
|
||||
// 无输出的批处理
|
||||
if (db.output == 'ignore' && option.ext == 'bat') option.bin = 'explorer';
|
||||
if (db.hasSubInput) {
|
||||
// 启动子命令输入
|
||||
// 清空输出
|
||||
$("#out").text('');
|
||||
var subinput = '';
|
||||
var setSubInput = () => {
|
||||
utools.setSubInput(({text}) => {
|
||||
subinput = text;
|
||||
}, '');
|
||||
}
|
||||
var handleEnter = (event) => {
|
||||
if (event.keyCode == 13) {
|
||||
$("#out").text('');
|
||||
var execmd = cmd.replace(/\{\{subinput\}\}/mg, subinput);
|
||||
runCmd(execmd, option, db.codec, db.output);
|
||||
}
|
||||
};
|
||||
setSubInput();
|
||||
document.addEventListener('keydown', handleEnter);
|
||||
} else {
|
||||
utools.setExpendHeight(0);
|
||||
utools.hideMainWindow();
|
||||
runCmd(cmd, option, db.codec, db.output);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function runCmd(cmd, option, codec, output) {
|
||||
// 运行脚本
|
||||
window.run(cmd, option, db.codec, (stdout, stderr) => {
|
||||
window.run(cmd, option, codec, (stdout, stderr) => {
|
||||
// 报错
|
||||
if (stderr) {
|
||||
window.messageBox({ type: 'error', icon: window.logo, message: stderr, buttons: ['纳尼?!'] })
|
||||
@ -32,7 +58,7 @@ utools.onPluginEnter(({ code, type, payload }) => {
|
||||
}
|
||||
// 有输出
|
||||
if (stdout) {
|
||||
switch (db.output) {
|
||||
switch (output) {
|
||||
case "ignore":
|
||||
utools.outPlugin();
|
||||
break;
|
||||
@ -62,4 +88,3 @@ utools.onPluginEnter(({ code, type, payload }) => {
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
@ -204,6 +204,7 @@ showCustomize = () => {
|
||||
<option value="{{isWin}}">是否Window系统</option>
|
||||
<option value="{{HostName}}">本计算机名</option>
|
||||
<option value="{{input}}">主输入框的文本</option>
|
||||
<option value="{{subinput}}">子输入框的文本</option>
|
||||
<option value="{{pwd}}">文件管理器当前目录</option>
|
||||
<option value="{{ChromeUrl}}">Chrome当前链接</option>
|
||||
<option value="{{ClipText}}">剪切板的文本</option>
|
||||
@ -372,7 +373,8 @@ $("#options").on('click', '.saveBtn', function () {
|
||||
iconpath = $("#icon").attr('src'),
|
||||
cmd = window.editor.getValue(),
|
||||
icon,
|
||||
base64ico;
|
||||
base64ico,
|
||||
hasSubInput;
|
||||
if (!desc) desc = ' ';
|
||||
// 自定义了图标的情况下
|
||||
if (iconame) {
|
||||
@ -398,6 +400,12 @@ $("#options").on('click', '.saveBtn', function () {
|
||||
} else {
|
||||
noKeyword = false;
|
||||
}
|
||||
// 需要子输入框
|
||||
if (cmd.includes('{{subinput}}')) {
|
||||
hasSubInput = true;
|
||||
} else {
|
||||
hasSubInput = false;
|
||||
}
|
||||
$("#customize").animate({ top: '100%' });
|
||||
// 添加特性
|
||||
pushData = {
|
||||
@ -412,7 +420,8 @@ $("#options").on('click', '.saveBtn', function () {
|
||||
output: output,
|
||||
codec: codec,
|
||||
base64Ico: base64ico,
|
||||
noKeyword: noKeyword
|
||||
noKeyword: noKeyword,
|
||||
hasSubInput: hasSubInput
|
||||
}
|
||||
if (program == 'custom') {
|
||||
pushData.customOptions = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user