mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 14:34:13 +08:00
feat: 新增专业模式
This commit is contained in:
parent
6948ffcbbc
commit
07635d68c0
@ -102,8 +102,8 @@
|
||||
let Matched = cmd.match(/\{\{MatchedFiles(\[\d+\]){0,1}(\.\w{1,11}){0,1}\}\}/g)
|
||||
Matched && Matched.forEach(m => {
|
||||
repl = eval(m.slice(2, -2))
|
||||
typeof repl == 'object' && (repl = JSON.stringify(repl))
|
||||
cmd = cmd.replace(m, repl)
|
||||
typeof repl == 'object' ? (repl = JSON.stringify(repl)) : (repl = repl.replace('\\', '\\\\'))
|
||||
cmd = cmd.replace(m, repl.replace('$','$$$'))
|
||||
})
|
||||
}
|
||||
// 窗口
|
||||
@ -117,7 +117,9 @@
|
||||
// 获取资源管理器或访达当前目录
|
||||
if (cmd.includes('{{pwd}}')) {
|
||||
repl = getCurrentFolderPathFix();
|
||||
console.log(repl);
|
||||
cmd = cmd.replace(/\{\{pwd\}\}/mg, repl)
|
||||
console.log(cmd)
|
||||
}
|
||||
// 获取窗口信息
|
||||
if (cmd.includes('{{WindowInfo')) {
|
||||
@ -235,6 +237,7 @@
|
||||
message(stdout)
|
||||
break;
|
||||
case "ignore":
|
||||
case "nothing":
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -466,12 +469,35 @@
|
||||
}
|
||||
}
|
||||
|
||||
let getCmdsType = cmds => {
|
||||
try {
|
||||
JSON.stringify(cmds)
|
||||
} catch (error) {
|
||||
return 'illegal'
|
||||
}
|
||||
if (cmds.length == 0) return 'null'
|
||||
if (cmds.length == 1) {
|
||||
let type = cmds[0].type
|
||||
if (!type) return 'key'
|
||||
if (type == 'window' || cmds[0].minNum) return type
|
||||
return 'professional'
|
||||
}
|
||||
let counts = cmds.filter(x => typeof x == 'string').length
|
||||
return counts == cmds.length ? 'key' : 'professional'
|
||||
}
|
||||
|
||||
let showCommandByType = features => {
|
||||
let qcType = '', rules = features.cmds[0].match
|
||||
if (features.cmds[0].type == 'regex') {
|
||||
let qcType = ''
|
||||
let cmds = features.cmds
|
||||
let type = getCmdsType(cmds)
|
||||
if (type == 'professional') {
|
||||
qcType = `<div class="topchild">专业模式</div><div><span class="keyword">[{...}]</span></div>`;
|
||||
} else {
|
||||
let rules = cmds[0].match
|
||||
if (type == 'regex') {
|
||||
if (rules.length > 14) rules = rules.slice(0, 14) + '...';
|
||||
qcType = `<div class="topchild">正则</div><div><span class="keyword re">${rules}</span></div>`;
|
||||
} else if (features.cmds[0].type == 'window') {
|
||||
} else if (type == 'window') {
|
||||
qcType += `<div class="topchild">窗口</div><div>`
|
||||
if (!rules) {
|
||||
qcType += `<span class="keyword win">所有窗口</span>`
|
||||
@ -485,7 +511,7 @@
|
||||
});
|
||||
}
|
||||
qcType += `</div>`
|
||||
} else if (features.cmds[0].type == 'files') {
|
||||
} else if (type == 'files') {
|
||||
if (rules.length > 14) rules = rules.slice(0, 14) + '...';
|
||||
qcType = `<div class="topchild">文件</div><div><span class="keyword fil">${rules}</span></div>`;
|
||||
} else {
|
||||
@ -497,6 +523,7 @@
|
||||
});
|
||||
qcType += `</div>`
|
||||
}
|
||||
}
|
||||
return qcType
|
||||
}
|
||||
|
||||
@ -628,7 +655,8 @@
|
||||
</select>
|
||||
<span class="word">输 出</span>
|
||||
<select id="output">
|
||||
<option value="ignore">隐藏并忽略输出</option>
|
||||
<option value="ignore">忽略输出并隐藏</option>
|
||||
<option value="nothing">忽略输出并保留窗口</option>
|
||||
<option value="text">显示纯文本输出</option>
|
||||
<option value="html">显示html格式的输出</option>
|
||||
<option value="terminal" id="showInTerm" disabled>在终端显示输出</option>
|
||||
@ -722,6 +750,11 @@
|
||||
id: "files",
|
||||
text: "复制/选中文件",
|
||||
html: "<img src='img/file.svg'><span>复制/选中文件</span><div>匹配拖入主输入框的文件或唤出超级面板时选中的文件,可以获取复制及选中的文件信息作为变量</div>"
|
||||
},
|
||||
{
|
||||
id: "professional",
|
||||
text: "专业模式",
|
||||
html: "<img src='img/professional.svg'><span>专业模式</span><div>通过json格式的配置实现同时匹配关键字、窗口、文件甚至图片,或者指定文件数量、窗口类等</div>"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -834,6 +867,10 @@
|
||||
$(".var.window").prop("disabled", false)
|
||||
$("#rule").prop("placeholder", '多个窗口进程逗号隔开,留空匹配所有窗口');
|
||||
break;
|
||||
case 'professional':
|
||||
$("#ruleWord").html("配 置");
|
||||
$(".var.regex, .var.window, .var.files").prop("disabled", false)
|
||||
$("#rule").prop("placeholder", '等效于 features.cmds');
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -961,7 +998,6 @@
|
||||
|
||||
let editCurrentCommand = data => {
|
||||
let code = data.features.code
|
||||
let cmds = data.features.cmds[0]
|
||||
let platform = data.features.platform
|
||||
let readonly = false
|
||||
let extraInfo = {
|
||||
@ -974,10 +1010,16 @@
|
||||
$('#customize').data('extraInfo', extraInfo)
|
||||
data.tags && $('#tags').val(data.tags).trigger('change')
|
||||
platform && ["win32", "darwin", "linux"].map(x => (!platform.includes(x) && $(`#${x}`).addClass('disabled')))
|
||||
$('#type').val(cmds.type).trigger("change")
|
||||
if (cmds.type == 'regex' || cmds.type == 'files') {
|
||||
let cmds = data.features.cmds
|
||||
let type = getCmdsType(cmds)
|
||||
$('#type').val(type).trigger("change")
|
||||
if (type == 'professional') {
|
||||
$('#rule').val(JSON.stringify(cmds))
|
||||
} else {
|
||||
cmds = cmds[0]
|
||||
if (type == 'regex' || type == 'files') {
|
||||
$('#rule').val(cmds.match);
|
||||
} else if (cmds.type == 'window') {
|
||||
} else if (type == 'window') {
|
||||
if (!cmds.match) $('#rule').val('');
|
||||
else if (cmds.match.title || cmds.match.class) $('#rule').val(JSON.stringify(cmds.match));
|
||||
else $('#rule').val(cmds.match.app);
|
||||
@ -985,6 +1027,7 @@
|
||||
$('#type').val('key').trigger("change")
|
||||
$('#rule').val(data.features.cmds.toString());
|
||||
}
|
||||
}
|
||||
$('#code').val(code);
|
||||
$('#program').val(data.program).trigger("change");
|
||||
$('#output').val(data.output).trigger("change");
|
||||
@ -1235,7 +1278,9 @@
|
||||
.filter(d => {
|
||||
try {
|
||||
return JSON.parse(d.custom_description).platform.includes(platform)
|
||||
} catch (error) { }
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
})
|
||||
.sort((x, y) => {
|
||||
if (y.updated_at > x.updated_at) return 1
|
||||
@ -1377,6 +1422,12 @@
|
||||
"match": rule,
|
||||
"minNum": 1
|
||||
}];
|
||||
} else if (type == 'professional') {
|
||||
try {
|
||||
cmds = JSON.parse(rule)
|
||||
} catch (error) {
|
||||
return quickcommand.showMessageBox(`配置的格式有误,请核查!`, 'error')
|
||||
}
|
||||
}
|
||||
// 需要子输入框
|
||||
if (cmd.includes('{{subinput')) {
|
||||
|
@ -224,6 +224,7 @@ body {
|
||||
|
||||
#options .logo {
|
||||
max-width: 40px;
|
||||
max-height: 40px;
|
||||
}
|
||||
|
||||
#options .info {
|
||||
@ -538,7 +539,8 @@ input::-webkit-input-placeholder {
|
||||
|
||||
#options #customize #icon {
|
||||
float: right;
|
||||
width: 40px;
|
||||
max-width: 40px;
|
||||
max-height: 40px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@ -730,7 +732,7 @@ li.CodeMirror-hint {
|
||||
}
|
||||
|
||||
#options #customize .select2-results>.select2-results__options {
|
||||
max-height: 300px;
|
||||
max-height: 360px;
|
||||
}
|
||||
|
||||
#options #customize .select2-selection--single:hover,
|
||||
|
1
src/img/professional.svg
Normal file
1
src/img/professional.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><path fill="#ffe57f" d="M44,24c0,11.045-8.955,20-20,20S4,35.045,4,24S12.955,4,24,4S44,12.955,44,24"/><path fill="#546e7a" d="M28.941,26.801c0,0-2.582,0-5.164-2.582s-2.582-5.164-2.582-5.164l8.66-8.656c-4.875-1.223-10.762,0.434-14.363,4.035c-5.363,5.367-0.563,12.266-2.039,13.742c-2.24,2.24-4.472,4.326-6.535,6.186c1.668,2.744,3.972,5.049,6.716,6.718c1.932-2.151,4.09-4.472,6.374-6.756c1.398-1.398,8.02,3.719,13.559-1.816c3.602-3.602,5.258-9.488,4.035-14.363L28.941,26.801z"/></svg>
|
After Width: | Height: | Size: 540 B |
Loading…
x
Reference in New Issue
Block a user