chore: 新增 .gitignore 排除开发文档,同步代码与构建产物
Made-with: Cursor
This commit is contained in:
@@ -13,8 +13,8 @@ Page({
|
||||
loading: false,
|
||||
searched: false,
|
||||
total: 0,
|
||||
// 热门搜索关键词
|
||||
hotKeywords: ['私域', '电商', '流量', '赚钱', '创业', 'Soul', '抖音', '变现'],
|
||||
// 热门搜索关键词(运行时根据热门章节/目录动态生成)
|
||||
hotKeywords: [],
|
||||
// 热门章节推荐
|
||||
hotChapters: [
|
||||
{ id: '1.1', title: '荷包:电动车出租的被动收入模式', tag: '免费', part: '真实的人' },
|
||||
@@ -47,13 +47,36 @@ Page({
|
||||
part: c.part_title || c.partTitle || c.part || '',
|
||||
tag: ['免费', '热门', '推荐', '最新'][i % 4] || '热门'
|
||||
}))
|
||||
this.setData({ hotChapters })
|
||||
this.setData({
|
||||
hotChapters,
|
||||
hotKeywords: this.buildHotKeywords(hotChapters)
|
||||
})
|
||||
} else {
|
||||
this.setData({ hotKeywords: this.buildHotKeywords(app.globalData.bookData || []) })
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('加载热门章节失败,使用默认数据')
|
||||
this.setData({ hotKeywords: this.buildHotKeywords(app.globalData.bookData || []) })
|
||||
}
|
||||
},
|
||||
|
||||
buildHotKeywords(sourceList) {
|
||||
const words = []
|
||||
const pushWord = (word) => {
|
||||
const w = (word || '').trim()
|
||||
if (!w || w.length < 2 || words.includes(w)) return
|
||||
words.push(w)
|
||||
}
|
||||
|
||||
;(sourceList || []).forEach((item) => {
|
||||
const title = String(item.title || '').replace(/[||::,.,。!!??]/g, ' ')
|
||||
const part = String(item.part || '').replace(/[||::,.,。!!??]/g, ' ')
|
||||
title.split(/\s+/).forEach(pushWord)
|
||||
part.split(/\s+/).forEach(pushWord)
|
||||
})
|
||||
|
||||
return words.slice(0, 8)
|
||||
},
|
||||
|
||||
// 输入关键词
|
||||
onInput(e) {
|
||||
this.setData({ keyword: e.detail.value })
|
||||
@@ -99,7 +122,6 @@ Page({
|
||||
this.setData({ results: [], total: 0 })
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('搜索失败:', e)
|
||||
wx.showToast({ title: '搜索失败', icon: 'none' })
|
||||
this.setData({ results: [], total: 0 })
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user