This commit is contained in:
2024-12-16 12:03:32 +08:00
parent a9b6a2c7fd
commit 5f127098cf

View File

@@ -35,14 +35,15 @@ export function get_views(name, ids = []) {
// 获取当日热门搜索词
export function get_search(n = 10) {
const ex = new Map()
const 全部 = new Map()
const all = { 文章, 作品, 游戏, 截图, 收藏, 综合 }
for (const key in all) {
all[key].搜索词..forEach((value, key) => {
ex.set(key, (ex.get(key) || 0) + value)
console.log(key, value)
全部.set(key, (全部.get(key) || 0) + value)
})
}
return [...ex.entries()].sort((a, b) => b[1] - a[1]).slice(0, n).map(([text, count]) => {
return [...全部.entries()].sort((a, b) => b[1] - a[1]).slice(0, n).map(([text, count]) => {
return { text, count }
})
}