From 3588abc85e110efa718f65693fac85a9e46bc104 Mon Sep 17 00:00:00 2001 From: fofolee Date: Fri, 10 Apr 2020 03:03:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=80=9A=E8=BF=87uTools?= =?UTF-8?q?=E5=91=BC=E5=87=BA=E5=89=8D=E7=9A=84=E7=AA=97=E5=8F=A3=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E7=9A=84=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/options.js | 199 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 152 insertions(+), 47 deletions(-) diff --git a/assets/options.js b/assets/options.js index 1940fbf..16ea3ce 100644 --- a/assets/options.js +++ b/assets/options.js @@ -18,6 +18,7 @@ putCustomFts = (code, pushData) => { } } +// 导入 importCommand = () => { var options = { filters: [{ name: 'json', extensions: ['json'] }, ] @@ -31,20 +32,16 @@ importCommand = () => { window.messageBox({ type: 'error', icon: window.logo, message: "格式错误!", buttons: ['朕知道了'] }) return } + // 单个命令导入 if (typeof(pushData.features)=='object') { - var code = basename(file, '.json'); - if (code in customFts) { - window.messageBox({ type: 'error', icon: window.logo, message: "命令名称重复, 请先修改文件名再导入!", buttons: ['朕知道了'] }) - } else { - putCustomFts(code, pushData); - showOptions(); - } + var code = pushData.features.code; + putCustomFts(code, pushData); + showOptions(); + // 多个命令导入 } else { if (typeof (Object.values(pushData)[0].features) == 'object') { for (var code of Object.keys(pushData)){ - if (!(code in customFts)) { - putCustomFts(code, pushData[code]); - } + putCustomFts(code, pushData[code]); } showOptions(); } else { @@ -137,12 +134,14 @@ programs = { showOptions = () => { var currentFts = utools.getFeatures(), customFts = getCustomFts(); - let featureList = ''; + let featureList = '
关键字说明启用
'; for (var fts in customFts) { let features = customFts[fts].features; var cmds = ''; - if (customFts[fts].noKeyword) { - cmds = '匹配主输入框文本进入'; + if (features.cmds[0].type == 'regex') { + cmds = `正则: ${features.cmds[0].match}`; + } else if (features.cmds[0].type == 'window') { + cmds = `窗口: ${features.cmds[0].match.app}`; } else { features.cmds.forEach(cmd => { cmds += `${cmd}`; @@ -161,7 +160,7 @@ showOptions = () => { window.messageBox({ type: 'error', icon: window.logo, message: e.toString(), buttons: ['啊嘞?!'] }) } featureList += ` -
模式说明启用
${cmds}${features.explain} +
${cmds}
${features.explain}