diff --git a/src/assets/js/qcfeatures.js b/src/assets/js/qcfeatures.js index afe3f12..f5b4c88 100644 --- a/src/assets/js/qcfeatures.js +++ b/src/assets/js/qcfeatures.js @@ -11,7 +11,7 @@ import qcpanel from "./qcpanel.js" // ************************************************** let showFeatureList = (tag = "默认") => { $("#options").empty().fadeIn(); - var currentFts = getCurrentFts().currentFts + var currentFtsCode = getCurrentFts().currentFts.map(x => x.code) var customFts = getAllQuickCommands() var allTags = ["默认"] var featureList = ` @@ -21,7 +21,7 @@ let showFeatureList = (tag = "默认") => { // 跳过有问题的命令 try { if (fts.tags) fts.tags.map(t => !allTags.includes(t) && allTags.push(t)) - featureList += getEveryFeature(fts, currentFts, tag) + featureList += getEveryFeature(fts, currentFtsCode, tag) } catch (e) { console.log(e) } @@ -76,7 +76,7 @@ let getCurrentFts = () => { } } -let getEveryFeature = (fts, currentFts, tag) => { +let getEveryFeature = (fts, currentFtsCode, tag) => { if (tag == "未分类") { if (fts.tags && fts.tags.length) return '' } else { @@ -84,14 +84,8 @@ let getEveryFeature = (fts, currentFts, tag) => { if (!fts.tags.includes(tag)) return '' } var features = fts.features; - var qcType = showCommandByType(features); - var isChecked = ''; - for (var c of currentFts) { - if (c.code == features.code) { - isChecked = 'checked'; - break; - } - } + var isChecked = currentFtsCode.includes(features.code) ? 'checked' : '' + var qcType = showCommandByType(features, isChecked == 'checked'); var platformIcons if (features.platform) platformIcons = features.platform.map(x => ``) else platformIcons = ['', '', ''] @@ -119,7 +113,7 @@ let getEveryFeature = (fts, currentFts, tag) => { ` } -let showCommandByType = features => { +let showCommandByType = (features, isActivated) => { let qcType = '' let cmds = features.cmds let type = qccommands.getCommandType(cmds) @@ -157,9 +151,12 @@ let showCommandByType = features => { rules = features.cmds.join(",") if (rules.length > 14) rules = rules.slice(0, 14) + '...'; qcType += `
关键字
` + let he, kws rules.split(',').forEach(r => { - // qcType += `${window.htmlEncode(r, true)}`; - qcType += `${window.htmlEncode(r, true)}`; + he = window.htmlEncode(r, true) + // 关键词可以点击跳转 + kws = `${he}` + qcType += `${kws}`; }); qcType += `
` } @@ -167,12 +164,6 @@ let showCommandByType = features => { return qcType } -// let linkKeywords = features => { -// if ($(`#${features.code} .checked-switch`).prop('checked')) { - -// } -// } - // ************************************************** // *********************功能按钮********************** @@ -471,7 +462,7 @@ let locateToFeature = (tags, code) => { } showFeatureList(redirectTag); location.href = '#' + code; - $(`#${code}`).fadeOut(function(){ + $(`#${code}`).fadeOut(function () { $(this).fadeIn(); }); }