From 3f342d59a9bbc498facd2354138fd4fadef2f03c Mon Sep 17 00:00:00 2001 From: fofolee Date: Sat, 1 Jan 2022 14:45:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=BE=E7=BD=AE=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E5=85=B3=E9=94=AE=E5=AD=97=E5=8F=AF=E4=BB=A5=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/js/qcfeatures.js | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) 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(); }); }