fix: 当某个命令在新版本不兼容时,导致所有命令无法显示

This commit is contained in:
fofolee 2020-07-28 18:58:21 +08:00
parent e4ab1081ca
commit 495829cf0c
6 changed files with 103 additions and 78 deletions

View File

@ -1,6 +1,6 @@
# 快捷命令 V2.0.0 # 快捷命令 V2.0.1
[![GitHub stars](https://img.shields.io/github/stars/fofolee/uTools-QuickerCommand?style=flat-square)](https://github.com/fofolee/uTools-QuickerCommand/stargazers) [![GitHub forks](https://img.shields.io/github/forks/fofolee/uTools-QuickerCommand?style=flat-square)](https://github.com/fofolee/uTools-QuickerCommand/network/members) [![GitHub license](https://img.shields.io/github/license/fofolee/uTools-QuickerCommand?style=flat-square)](https://github.com/fofolee/uTools-QuickerCommand/blob/master/LICENSE) [![version]( https://img.shields.io/badge/dynamic/json?color=f58142&label=version&query=%24.version&url=https%3A%2F%2Fraw.githubusercontent.com%2Ffofolee%2FuTools-QuickerCommand%2Fmaster%2Fsrc%2Fplugin.json&style=flat-square)](https://github.com/fofolee/uTools-QuickerCommand/blob/master/src/helps/CHANGELOG.md) [![猿料](https://img.shields.io/badge/%E7%8C%BF%E6%96%99-%2Fd%2F424-red?style=flat-square)](https://yuanliao.info/d/424) [![评论](https://img.shields.io/badge/dynamic/json?color=%2350e3c2&label=%E8%AF%84%E8%AE%BA&query=%24.data.attributes.commentsCount&url=https%3A%2F%2Fyuanliao.info%2Fapi%2Fdiscussions%2F424&style=flat-square)](https://yuanliao.info/d/424) [![下载](https://img.shields.io/badge/dynamic/json?label=%E4%B8%8B%E8%BD%BD&query=quickcommand&url=http%3A%2F%2F45.77.122.164%3A8888%2FdownloadsStatistics.php&style=flat-square)](https://yuanliao.info/d/424) [![GitHub stars](https://img.shields.io/github/stars/fofolee/uTools-QuickerCommand?style=flat-square)](https://github.com/fofolee/uTools-QuickerCommand/stargazers) [![GitHub forks](https://img.shields.io/github/forks/fofolee/uTools-QuickerCommand?style=flat-square)](https://github.com/fofolee/uTools-QuickerCommand/network/members) [![GitHub license](https://img.shields.io/github/license/fofolee/uTools-QuickerCommand?style=flat-square)](https://github.com/fofolee/uTools-QuickerCommand/blob/master/LICENSE) [![version]( https://img.shields.io/badge/dynamic/json?color=f58142&label=version&query=%24.version&url=https%3A%2F%2Fraw.githubusercontent.com%2Ffofolee%2FuTools-QuickerCommand%2Fmaster%2Fsrc%2Fplugin.json&style=flat-square)](https://github.com/fofolee/uTools-QuickerCommand/blob/master/src/helps/CHANGELOG.md) [![猿料](https://img.shields.io/badge/%E7%8C%BF%E6%96%99-%2Fd%2F424-red?style=flat-square)](https://yuanliao.info/d/424) [![评论](https://img.shields.io/badge/dynamic/json?color=%2350e3c2&label=%E8%AF%84%E8%AE%BA&query=%24.data.attributes.commentsCount&url=https%3A%2F%2Fyuanliao.info%2Fapi%2Fdiscussions%2F424&style=flat-square)](https://yuanliao.info/d/424) [![下载](https://img.shields.io/badge/dynamic/json?label=%E4%B8%8B%E8%BD%BD&query=quickcommand&url=http%3A%2F%2F45.77.122.164%3A8888%2FdownloadsStatistics.php&style=flat-square)](https://yuanliao.info/d/424)

View File

@ -1,6 +1,6 @@
# 快捷命令 V2.0.0 # 快捷命令 V2.0.1
[![GitHub stars](https://img.shields.io/github/stars/fofolee/uTools-QuickerCommand?style=flat-square)](https://github.com/fofolee/uTools-QuickerCommand/stargazers) [![GitHub forks](https://img.shields.io/github/forks/fofolee/uTools-QuickerCommand?style=flat-square)](https://github.com/fofolee/uTools-QuickerCommand/network/members) [![GitHub license](https://img.shields.io/github/license/fofolee/uTools-QuickerCommand?style=flat-square)](https://github.com/fofolee/uTools-QuickerCommand/blob/master/LICENSE) [![version]( https://img.shields.io/badge/dynamic/json?color=f58142&label=version&query=%24.version&url=https%3A%2F%2Fraw.githubusercontent.com%2Ffofolee%2FuTools-QuickerCommand%2Fmaster%2Fsrc%2Fplugin.json&style=flat-square)](https://github.com/fofolee/uTools-QuickerCommand/blob/master/src/helps/CHANGELOG.md) [![猿料](https://img.shields.io/badge/%E7%8C%BF%E6%96%99-%2Fd%2F424-red?style=flat-square)](https://yuanliao.info/d/424) [![评论](https://img.shields.io/badge/dynamic/json?color=%2350e3c2&label=%E8%AF%84%E8%AE%BA&query=%24.data.attributes.commentsCount&url=https%3A%2F%2Fyuanliao.info%2Fapi%2Fdiscussions%2F424&style=flat-square)](https://yuanliao.info/d/424) [![下载](https://img.shields.io/badge/dynamic/json?label=%E4%B8%8B%E8%BD%BD&query=quickcommand&url=http%3A%2F%2F45.77.122.164%3A8888%2FdownloadsStatistics.php&style=flat-square)](https://yuanliao.info/d/424) [![GitHub stars](https://img.shields.io/github/stars/fofolee/uTools-QuickerCommand?style=flat-square)](https://github.com/fofolee/uTools-QuickerCommand/stargazers) [![GitHub forks](https://img.shields.io/github/forks/fofolee/uTools-QuickerCommand?style=flat-square)](https://github.com/fofolee/uTools-QuickerCommand/network/members) [![GitHub license](https://img.shields.io/github/license/fofolee/uTools-QuickerCommand?style=flat-square)](https://github.com/fofolee/uTools-QuickerCommand/blob/master/LICENSE) [![version]( https://img.shields.io/badge/dynamic/json?color=f58142&label=version&query=%24.version&url=https%3A%2F%2Fraw.githubusercontent.com%2Ffofolee%2FuTools-QuickerCommand%2Fmaster%2Fsrc%2Fplugin.json&style=flat-square)](https://github.com/fofolee/uTools-QuickerCommand/blob/master/src/helps/CHANGELOG.md) [![猿料](https://img.shields.io/badge/%E7%8C%BF%E6%96%99-%2Fd%2F424-red?style=flat-square)](https://yuanliao.info/d/424) [![评论](https://img.shields.io/badge/dynamic/json?color=%2350e3c2&label=%E8%AF%84%E8%AE%BA&query=%24.data.attributes.commentsCount&url=https%3A%2F%2Fyuanliao.info%2Fapi%2Fdiscussions%2F424&style=flat-square)](https://yuanliao.info/d/424) [![下载](https://img.shields.io/badge/dynamic/json?label=%E4%B8%8B%E8%BD%BD&query=quickcommand&url=http%3A%2F%2F45.77.122.164%3A8888%2FdownloadsStatistics.php&style=flat-square)](https://yuanliao.info/d/424)

View File

@ -257,13 +257,22 @@
if (fts.program == 'simulation') fts.program = 'quickcommand'; if (fts.program == 'simulation') fts.program = 'quickcommand';
// 旧版的 sleep // 旧版的 sleep
if (fts.cmd.includes('await sleep')) fts.cmd = fts.cmd.replace(/await sleep/g, 'quickcommand.sleep') if (fts.cmd.includes('await sleep')) fts.cmd = fts.cmd.replace(/await sleep/g, 'quickcommand.sleep')
// 旧版的 match.app
let type = fts.features.cmds[0].type || 'key'
if (type == 'window') {
let windowMatch = fts.features.cmds[0].match
console.log(windowMatch)
if (windowMatch && (typeof windowMatch.app == 'string')) {
console.log(fts);
fts.features.cmds[0].match.app = windowMatch.app.split(',')
}
}
// 不规范的 code // 不规范的 code
let code = fts.features.code let code = fts.features.code
if (!/^(window|key|regex|files|default)_/.test(code)) { if (!/^(window|key|regex|files|default)_/.test(code)) {
console.log(code); console.log(code);
utoolsFull.removeFeature(code) utoolsFull.removeFeature(code)
let uid = Number(Math.random().toString().substr(3, 3) + (Date.now() + i * 10000)).toString(36) let uid = Number(Math.random().toString().substr(3, 3) + (Date.now() + i * 10000)).toString(36)
let type = fts.features.cmds[0].type || 'key'
code = type + '_' + uid code = type + '_' + uid
fts.features.code = code fts.features.code = code
} }
@ -457,56 +466,49 @@
} }
} }
// 显示设置界面 let showCommandByType = features => {
let showOptions = (tag = "默认") => { let qcType = '', rules = features.cmds[0].match
$("#options").empty().fadeIn();
var currentFts = utools.getFeatures(),
customFts = getAllQuickCommands();
var allTags = ["默认"]
var featureList = `
<div id="featureList">
<table>`;
Object.values(customFts).some(fts => {
var features = fts.features;
if (fts.tags) {
fts.tags.map(t => !allTags.includes(t) && allTags.push(t))
}
if (tag == "未分类") {
if (fts.tags && fts.tags.length) return false
} else {
if (!fts.tags) return false
if (!fts.tags.includes(tag)) return false
}
var cmds = '', rules = features.cmds[0].match;
if (features.cmds[0].type == 'regex') { if (features.cmds[0].type == 'regex') {
if (rules.length > 14) rules = rules.slice(0, 14) + '...'; if (rules.length > 14) rules = rules.slice(0, 14) + '...';
cmds = `<div class="topchild">正则</div><div><span class="keyword re">${rules}</span></div>`; qcType = `<div class="topchild">正则</div><div><span class="keyword re">${rules}</span></div>`;
} else if (features.cmds[0].type == 'window') { } else if (features.cmds[0].type == 'window') {
cmds += `<div class="topchild">窗口</div><div>` qcType += `<div class="topchild">窗口</div><div>`
if (!rules) { if (!rules) {
cmds += `<span class="keyword win">所有窗口</span>` qcType += `<span class="keyword win">所有窗口</span>`
} else if (rules.title || rules.class) { } else if (rules.title || rules.class) {
cmds += `<span class="keyword win">${JSON.stringify(rules).slice(0, 14) + '...'}</span>`; qcType += `<span class="keyword win">${JSON.stringify(rules).slice(0, 14) + '...'}</span>`;
} else if (rules.app) { } else if (rules.app) {
rules = rules.app.join(",") rules = rules.app.join(",")
if(rules.length > 14) rules = rules.slice(0, 14) + '...'; if (rules.length > 14) rules = rules.slice(0, 14) + '...';
rules.split(',').forEach(r => { rules.split(',').forEach(r => {
cmds += `<span class="keyword win">${r}</span>`; qcType += `<span class="keyword win">${r}</span>`;
}); });
} }
cmds += `</div>` qcType += `</div>`
} else if (features.cmds[0].type == 'files') { } else if (features.cmds[0].type == 'files') {
if (rules.length > 14) rules = rules.slice(0, 14) + '...'; if (rules.length > 14) rules = rules.slice(0, 14) + '...';
cmds = `<div class="topchild">文件</div><div><span class="keyword fil">${rules}</span></div>`; qcType = `<div class="topchild">文件</div><div><span class="keyword fil">${rules}</span></div>`;
} else { } else {
rules = features.cmds.join(",") rules = features.cmds.join(",")
if(rules.length > 14) rules = rules.slice(0, 14) + '...'; if (rules.length > 14) rules = rules.slice(0, 14) + '...';
cmds += `<div class="topchild">关键字</div><div>` qcType += `<div class="topchild">关键字</div><div>`
rules.split(',').forEach(r => { rules.split(',').forEach(r => {
cmds += `<span class="keyword">${r}</span>`; qcType += `<span class="keyword">${r}</span>`;
}); });
cmds += `</div>` qcType += `</div>`
} }
return qcType
}
let getEveryFeature = (fts, currentFts, tag) => {
if (tag == "未分类") {
if (fts.tags && fts.tags.length) return ''
} else {
if (!fts.tags) return ''
if (!fts.tags.includes(tag)) return ''
}
var features = fts.features;
var qcType = showCommandByType(features);
var isChecked = ''; var isChecked = '';
for(var c of currentFts){ for(var c of currentFts){
if (c.code == features.code) { if (c.code == features.code) {
@ -517,7 +519,7 @@
var platformIcons var platformIcons
if (features.platform) platformIcons = features.platform.map(x => `<img src="img/${x}.svg">`) if (features.platform) platformIcons = features.platform.map(x => `<img src="img/${x}.svg">`)
else platformIcons = ['<img src="img/win32.svg">', '<img src="img/darwin.svg">', '<img src="img/linux.svg">'] else platformIcons = ['<img src="img/win32.svg">', '<img src="img/darwin.svg">', '<img src="img/linux.svg">']
featureList += `<tr id="${features.code}"> return `<tr id="${features.code}">
<td><img class="logo" src="${features.icon}"></td> <td><img class="logo" src="${features.icon}"></td>
<td> <td>
<div class="topchild">${features.explain}</div> <div class="topchild">${features.explain}</div>
@ -527,7 +529,7 @@
${fts.program} | ${platformIcons.join('')} ${fts.program} | ${platformIcons.join('')}
</div> </div>
</td> </td>
<td>${cmds}</td> <td>${qcType}</td>
<td> <td>
<label class="switch-btn"> <label class="switch-btn">
<input class="checked-switch" type="checkbox" ${isChecked}> <input class="checked-switch" type="checkbox" ${isChecked}>
@ -539,6 +541,25 @@
<span class="Btn editBtn"><img src="img/${tag == "默认" ? "view" : "edit"}.svg"></span> <span class="Btn editBtn"><img src="img/${tag == "默认" ? "view" : "edit"}.svg"></span>
${(tag == "默认" && !isDev()) ? "" : `<span class="Btn exportBtn"><img src="img/export.svg"> </span><span class="Btn delBtn"><img src="img/del.svg"></span>`} ${(tag == "默认" && !isDev()) ? "" : `<span class="Btn exportBtn"><img src="img/export.svg"> </span><span class="Btn delBtn"><img src="img/del.svg"></span>`}
</td>` </td>`
}
// 显示设置界面
let showOptions = (tag = "默认") => {
$("#options").empty().fadeIn();
var currentFts = utools.getFeatures(),
customFts = getAllQuickCommands();
var allTags = ["默认"]
var featureList = `
<div id="featureList">
<table>`;
Object.values(customFts).forEach(fts => {
// 跳过有问题的命令
try {
if (fts.tags) fts.tags.map(t => !allTags.includes(t) && allTags.push(t))
featureList += getEveryFeature(fts, currentFts, tag)
} catch (e) {
console.log(e)
}
}) })
featureList += `</tr></table></div>` featureList += `</tr></table></div>`
var sidebar = ` var sidebar = `
@ -1418,7 +1439,7 @@
let redirectTag let redirectTag
let currentTag = $('.currentTag').text() let currentTag = $('.currentTag').text()
// let AllTags = Array.from($('.sidebar li')).map(x => x.innerText) // let AllTags = Array.from($('.sidebar li')).map(x => x.innerText)
if (tags.length) { if (tags && tags.length) {
if (tags.includes(currentTag)) { if (tags.includes(currentTag)) {
redirectTag = currentTag redirectTag = currentTag
} else { } else {

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,7 @@
## v2.0.1
- 修复当某个命令在新版本不兼容时,导致所有命令无法显示的 bug
## v2.0.0 ## v2.0.0
本次带来了 海量更新,请仔细看完更新日志~ 本次带来了 海量更新,请仔细看完更新日志~

View File

@ -4,7 +4,7 @@
"main": "index.html", "main": "index.html",
"homepage": "https://github.com/fofolee/uTools-QuickerCommand", "homepage": "https://github.com/fofolee/uTools-QuickerCommand",
"publishPage": "https://yuanliao.info/d/424", "publishPage": "https://yuanliao.info/d/424",
"version": "2.0.0", "version": "2.0.1",
"author": "云之轩", "author": "云之轩",
"unpack":"autopep8.py", "unpack":"autopep8.py",
"logo": "logo.png", "logo": "logo.png",