增加窗口信息变量

This commit is contained in:
fofolee 2020-04-10 03:04:08 +08:00
parent 85f206ad00
commit 52719bb0b8

View File

@ -1,4 +1,4 @@
utools.onPluginEnter(({ code, type, payload }) => { utools.onPluginEnter( async ({ code, type, payload }) => {
// checkUpdate(); // checkUpdate();
// 配置页面 // 配置页面
if (code == 'options') { if (code == 'options') {
@ -16,10 +16,28 @@ utools.onPluginEnter(({ code, type, payload }) => {
} else { } else {
option = programs[db.program]; option = programs[db.program];
} }
// 通过主输入框直接进入 // 正则
if (type == 'over') cmd = cmd.replace(/\{\{input\}\}/mg, payload); if (type == 'regex') cmd = cmd.replace(/\{\{input\}\}/mg, payload);
// 窗口
if (type == 'window') {
// 获取选中的文件
if (cmd.includes('{{SelectFile}}')) {
let repl = await getSelectFile(payload.id);
cmd = cmd.replace(/\{\{SelectFile\}\}/mg, repl)
}
// 获取资源管理器或访达当前目录
if (cmd.includes('{{pwd}}')) {
let repl = await pwd(payload.id);
cmd = cmd.replace(/\{\{pwd\}\}/mg, repl)
}
// 获取窗口信息
if (cmd.includes('{{WindowInfo}}')) {
let repl = JSON.stringify(payload);
cmd = cmd.replace(/\{\{WindowInfo\}\}/mg, repl)
}
}
// 无输出的批处理 // 无输出的批处理
if (db.output == 'ignore' && option.ext == 'bat') option.bin = 'explorer'; // if (db.output == 'ignore' && option.ext == 'bat') option.bin = 'explorer';
if (db.hasSubInput) { if (db.hasSubInput) {
// 启动子命令输入 // 启动子命令输入
// 清空输出 // 清空输出
@ -52,8 +70,8 @@ utools.onPluginEnter(({ code, type, payload }) => {
function runCmd(cmd, option, codec, output) { function runCmd(cmd, option, codec, output) {
// 不需要输出的,提前关闭窗口 // 不需要输出的,提前关闭窗口
if (['ignore', 'clip', 'send', 'notice', 'terminal'].indexOf(output) !== -1){ if (['ignore', 'clip', 'send', 'notice', 'terminal'].indexOf(output) !== -1){
utools.outPlugin()
utools.hideMainWindow() utools.hideMainWindow()
utools.outPlugin()
} }
var terminal = false; var terminal = false;
if(output == 'terminal') terminal = true; if(output == 'terminal') terminal = true;