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