From 75db995342c97ef754e9aabb7cd5c348693de7c4 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Sun, 12 Apr 2020 18:25:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=81=9A=E5=90=88=E7=83=AD?= =?UTF-8?q?=E9=97=A8=E6=90=9C=E7=B4=A2=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/store/modules/hotSearch.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/renderer/store/modules/hotSearch.js b/src/renderer/store/modules/hotSearch.js index 3368276e..b2f0ae69 100644 --- a/src/renderer/store/modules/hotSearch.js +++ b/src/renderer/store/modules/hotSearch.js @@ -61,16 +61,19 @@ const mutations = { state.list[source] = data ? data.list.slice(0, 20) : [] }, setLists(state, lists) { - let list = [] + let list = new Map() for (const source of lists) { if (!state.list[source.source].length) state.list[source.source] = source.list.slice(0, 20) const sourceList = source.list.slice(0, 10) - for (const item of sourceList) { - list.push(item.trim()) + for (let item of sourceList) { + item = item.trim() + list.set(item, (list.has(item) ? list.get(item) : 0) + 1) } } - list = Array.from(new Set(list)) - list.sort((a, b) => a.charCodeAt(0) - b.charCodeAt(0)) + list = Array.from(list) + list.sort((a, b) => a[0].charCodeAt(0) - b[0].charCodeAt(0)) + list.sort((a, b) => b[1] - a[1]) + list = list.map(item => item[0]) state.list.all = list }, clearList(state, source) {