mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 14:34:13 +08:00
windowinfo和matchedfiles支持直接获取属性值
This commit is contained in:
parent
71b7589e54
commit
b4ebd2be31
@ -53,23 +53,37 @@
|
|||||||
// 正则
|
// 正则
|
||||||
if (type == 'regex') cmd = cmd.replace(/\{\{input\}\}/mg, payload);
|
if (type == 'regex') cmd = cmd.replace(/\{\{input\}\}/mg, payload);
|
||||||
// 文件
|
// 文件
|
||||||
if (type == 'files') cmd = cmd.replace(/\{\{MatchedFiles\}\}/mg, JSON.stringify(payload));
|
if (type == 'files') {
|
||||||
|
let MatchedFiles = payload
|
||||||
|
let Matched = cmd.match(/\{\{MatchedFiles.*?\}\}/g)
|
||||||
|
Matched && Matched.forEach(m => {
|
||||||
|
repl = eval(m.slice(2, -2))
|
||||||
|
typeof repl == 'object' && (repl = JSON.stringify(repl))
|
||||||
|
cmd = cmd.replace(m, repl)
|
||||||
|
})
|
||||||
|
}
|
||||||
// 窗口
|
// 窗口
|
||||||
|
var repl
|
||||||
if (type == 'window') {
|
if (type == 'window') {
|
||||||
// 获取选中的文件
|
// 获取选中的文件
|
||||||
if (cmd.includes('{{SelectFile}}')) {
|
if (cmd.includes('{{SelectFile}}')) {
|
||||||
let repl = await getSelectFile(payload.id);
|
repl = await getSelectFile(payload.id);
|
||||||
cmd = cmd.replace(/\{\{SelectFile\}\}/mg, repl)
|
cmd = cmd.replace(/\{\{SelectFile\}\}/mg, repl)
|
||||||
}
|
}
|
||||||
// 获取资源管理器或访达当前目录
|
// 获取资源管理器或访达当前目录
|
||||||
if (cmd.includes('{{pwd}}')) {
|
if (cmd.includes('{{pwd}}')) {
|
||||||
let repl = getCurrentFolderPathFix();
|
repl = getCurrentFolderPathFix();
|
||||||
cmd = cmd.replace(/\{\{pwd\}\}/mg, repl)
|
cmd = cmd.replace(/\{\{pwd\}\}/mg, repl)
|
||||||
}
|
}
|
||||||
// 获取窗口信息
|
// 获取窗口信息
|
||||||
if (cmd.includes('{{WindowInfo}}')) {
|
if (cmd.includes('{{WindowInfo')) {
|
||||||
let repl = JSON.stringify(payload);
|
let WindowInfo = payload
|
||||||
cmd = cmd.replace(/\{\{WindowInfo\}\}/mg, repl)
|
let Matched = cmd.match(/\{\{WindowInfo.*?\}\}/g)
|
||||||
|
Matched && Matched.forEach(m => {
|
||||||
|
repl = eval(m.slice(2, -2))
|
||||||
|
typeof repl == 'Object' && (repl = JSON.stringify(repl))
|
||||||
|
cmd = cmd.replace(m, repl)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 无输出的批处理
|
// 无输出的批处理
|
||||||
@ -179,9 +193,9 @@
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
// } else {
|
||||||
// 无输出
|
// // 无输出
|
||||||
utools.outPlugin()
|
// utools.outPlugin()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user