mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-09 06:54:11 +08:00
fix: 修复匹配所有文本
This commit is contained in:
parent
427037a031
commit
438140b91b
@ -131,6 +131,7 @@ let getCommandType = cmds => {
|
||||
if (cmds.length == 1) {
|
||||
let type = cmds[0].type
|
||||
if (!type) return 'key'
|
||||
if (type == 'over') return 'regex'
|
||||
if (type == 'window' || cmds[0].minNum) return type
|
||||
return 'professional'
|
||||
}
|
||||
@ -438,7 +439,8 @@ let SaveCurrentCommand = async () => {
|
||||
charset = $('#charset').data()
|
||||
var cmd = window.editor.getValue();
|
||||
if (tags && tags.includes("默认") && !isDev()) return
|
||||
if (!rule) return quickcommand.showMessageBox(`${$('#ruleWord').text().replace(" ", "")} 不能留空!`, 'error')
|
||||
// 留空检测
|
||||
if (type != "regex" && !rule) return quickcommand.showMessageBox(`${$('#ruleWord').text().replace(" ", "")} 不能留空!`, 'error')
|
||||
if (!cmdCheck(type, cmd)) return
|
||||
if (!code) {
|
||||
// 生成唯一code
|
||||
@ -456,15 +458,24 @@ let SaveCurrentCommand = async () => {
|
||||
if (type == 'key') {
|
||||
cmds = rule.split(",").map(x => x.trim())
|
||||
} else if (type == 'regex') {
|
||||
if (!/^\/.*?\/[igm]*$/.test(rule)) {
|
||||
rule = "/" + rule + "/"
|
||||
// 留空匹配所有文本
|
||||
if (!rule) {
|
||||
cmds = [{
|
||||
"label": desc,
|
||||
"type": "over",
|
||||
"minNum": 1
|
||||
}];
|
||||
} else {
|
||||
if (!/^\/.*?\/[igm]*$/.test(rule)) {
|
||||
rule = "/" + rule + "/"
|
||||
}
|
||||
cmds = [{
|
||||
"label": desc,
|
||||
"type": "regex",
|
||||
"match": rule,
|
||||
"minNum": 1
|
||||
}];
|
||||
}
|
||||
cmds = [{
|
||||
"label": desc,
|
||||
"type": "regex",
|
||||
"match": rule,
|
||||
"minNum": 1
|
||||
}];
|
||||
} else if (type == 'window') {
|
||||
var cmdOfWin = {
|
||||
"label": desc,
|
||||
@ -866,25 +877,25 @@ let typeCheck = () => {
|
||||
case 'key':
|
||||
$("#ruleWord").html("关键字");
|
||||
$(".var.regex, .var.window, .var.files").prop("disabled", true)
|
||||
$("#rule").prop("placeholder", '多个关键字用逗号隔开');
|
||||
$("#rule").prop("placeholder", '例:mycommand,cs');
|
||||
break;
|
||||
case 'regex':
|
||||
$("#ruleWord").html("正 则");
|
||||
$(".var.window, .var.files").prop("disabled", true)
|
||||
$(".var.regex").prop("disabled", false)
|
||||
$("#rule").prop("placeholder", '匹配文本的正则,如 /.*?\\.exe$/i');
|
||||
$("#rule").prop("placeholder", '例:/\\d{18}/,留空匹配所有文本');
|
||||
break;
|
||||
case 'files':
|
||||
$("#ruleWord").html("正 则");
|
||||
$(".var.regex, .var.window").prop("disabled", true)
|
||||
$(".var.files").prop("disabled", false)
|
||||
$("#rule").prop("placeholder", '匹配文件的正则,如 /.*?\\.exe$/i');
|
||||
$("#rule").prop("placeholder", '例:/.*?\\.exe$/i');
|
||||
break;
|
||||
case 'window':
|
||||
$("#ruleWord").html("进 程");
|
||||
$(".var.regex, .var.files").prop("disabled", true)
|
||||
$(".var.window").prop("disabled", false)
|
||||
$("#rule").prop("placeholder", '多个窗口进程逗号隔开');
|
||||
$("#rule").prop("placeholder", '例:word.exe,excel.exe');
|
||||
break;
|
||||
case 'professional':
|
||||
$("#ruleWord").html("配 置");
|
||||
|
@ -128,8 +128,13 @@ let showCommandByType = features => {
|
||||
} 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">${window.htmlEncode(rules, true)}</span></div>`;
|
||||
qcType += `<div class="topchild">文本</div><div>`
|
||||
if (!rules) {
|
||||
qcType += `<span class="keyword win">所有文本</span>`
|
||||
} else {
|
||||
if (rules.length > 14) rules = rules.slice(0, 14) + '...';
|
||||
qcType += `<span class="keyword re">${window.htmlEncode(rules, true)}</span></div>`;
|
||||
}
|
||||
} else if (type == 'window') {
|
||||
qcType += `<div class="topchild">窗口</div><div>`
|
||||
// if (!rules) {
|
||||
|
@ -20,7 +20,7 @@ let command = {
|
||||
<p><input type="text" id="code" style="display: none">
|
||||
<span class="word">匹 配</span>
|
||||
<select id="type"></select>
|
||||
<span class="word" id="ruleWord">关键字</span><input class="customize" type="text" id="rule" placeholder="多个关键字用逗号隔开"><img id="expandBtn" src="./img/expand.svg"></p>
|
||||
<span class="word" id="ruleWord">关键字</span><input class="customize" type="text" id="rule" placeholder="例:mycommand,cs"><img id="expandBtn" src="./img/expand.svg"></p>
|
||||
<p><span class="word">说 明</span><input class="customize" type="text" id="desc" placeholder="命令功能的描述">
|
||||
<img id="icon" src="">
|
||||
</p>
|
||||
|
@ -5,8 +5,7 @@
|
||||
"cmds": [
|
||||
{
|
||||
"label": "文本处理",
|
||||
"type": "regex",
|
||||
"match": "/.*?/",
|
||||
"type": "over",
|
||||
"minNum": 1
|
||||
}
|
||||
],
|
||||
@ -25,4 +24,4 @@
|
||||
"tags": [
|
||||
"默认"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user