feat: migrate static pages to native tabbar

This commit is contained in:
2026-04-23 21:25:24 +08:00
parent f3cd0c3a98
commit cd30f57f2c
116 changed files with 7143 additions and 311 deletions

View File

@@ -0,0 +1,90 @@
const { ROUTES, openStaticRoute } = require('../../../../utils/static-ux/route-map')
const SEARCH_CATALOG = Object.freeze([
{
key: 'classic-a',
title: '黄帝内经素问',
subtitle: '书名命中',
aliases: ['黄帝内经', '素问'],
route: `${ROUTES.tcm.bookDetail}?scene=classic-a`
},
{
key: 'classic-b',
title: '伤寒论',
subtitle: '经典结果',
aliases: ['伤寒', '仲景'],
route: `${ROUTES.tcm.bookDetail}?scene=classic-b`
}
])
const SEARCH_HISTORY = Object.freeze(['黄帝内经', '伤寒论', '温病条辨'])
function createResults(keyword) {
const normalizedKeyword = (keyword || '').trim()
if (!normalizedKeyword) {
return []
}
return SEARCH_CATALOG.filter(item => {
return (
item.title.includes(normalizedKeyword) ||
item.aliases.some(alias => alias.includes(normalizedKeyword))
)
}).map(item => ({ ...item }))
}
function createTcmSearchBooksPageData(keyword) {
const normalizedKeyword = (keyword || '').trim()
return {
title: '搜索典籍',
keyword: normalizedKeyword,
draftKeyword: normalizedKeyword,
summary: '只保留静态搜索 UI 和结果列表,不接旧项目的检索接口与搜索历史存储。',
placeholder: '搜索书名或常见别名',
historyTitle: '最近搜索',
history: SEARCH_HISTORY.map(item => ({
key: item,
label: item
})),
results: createResults(normalizedKeyword),
searched: Boolean(normalizedKeyword)
}
}
function showNavigate(route) {
openStaticRoute(route, wx)
}
Page({
data: createTcmSearchBooksPageData(''),
onLoad(options) {
this.setData(createTcmSearchBooksPageData(options.keyword || options.q))
},
handleKeywordInput(event) {
this.setData({
draftKeyword: event.detail.value
})
},
handleSearchTap() {
this.setData(createTcmSearchBooksPageData(this.data.draftKeyword))
},
handleHistoryTap(event) {
const keyword = event.currentTarget.dataset.keyword
this.setData(createTcmSearchBooksPageData(keyword))
},
handleResultTap(event) {
showNavigate(event.currentTarget.dataset.route)
}
})
module.exports = {
createTcmSearchBooksPageData
}