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
}

View File

@@ -0,0 +1,5 @@
{
"navigationBarTitleText": "搜索典籍",
"navigationBarBackgroundColor": "#f8ecd8",
"navigationBarTextStyle": "black"
}

View File

@@ -0,0 +1,50 @@
<view class="search-books-page">
<view class="hero-card">
<text class="hero-card__title">{{title}}</text>
<text class="hero-card__description">{{summary}}</text>
<view class="search-row">
<input
class="search-row__input"
value="{{draftKeyword}}"
placeholder="{{placeholder}}"
bindinput="handleKeywordInput"
/>
<view class="search-row__button" bindtap="handleSearchTap">搜索</view>
</view>
</view>
<view class="section-card">
<text class="section-card__title">{{historyTitle}}</text>
<view class="history-list">
<view
class="history-chip"
wx:for="{{history}}"
wx:key="key"
data-keyword="{{item.label}}"
bindtap="handleHistoryTap"
>
{{item.label}}
</view>
</view>
</view>
<view wx:if="{{results.length}}" class="section-card">
<text class="section-card__title">搜索结果</text>
<view
class="result-card"
wx:for="{{results}}"
wx:key="key"
data-route="{{item.route}}"
bindtap="handleResultTap"
>
<text class="result-card__title">{{item.title}}</text>
<text class="result-card__subtitle">{{item.subtitle}}</text>
</view>
</view>
<view wx:elif="{{searched}}" class="section-card">
<text class="section-card__title">没有找到相关典籍</text>
<text class="section-card__description">换一个书名或常见别名再试试。</text>
</view>
</view>

View File

@@ -0,0 +1,96 @@
page {
min-height: 100%;
background: linear-gradient(180deg, #fbf4e9 0%, #f3eadf 100%);
}
.search-books-page {
box-sizing: border-box;
min-height: 100vh;
padding: 28rpx 20rpx 72rpx;
}
.hero-card,
.section-card {
margin-top: 18rpx;
padding: 28rpx;
border: 1rpx solid rgba(118, 83, 42, 0.08);
border-radius: 32rpx;
background: rgba(255, 250, 242, 0.92);
box-shadow: 0 18rpx 42rpx rgba(86, 58, 25, 0.08);
}
.hero-card {
margin-top: 0;
}
.hero-card__title,
.section-card__title,
.result-card__title {
display: block;
color: #2c2419;
font-family: 'STSong', 'Songti SC', serif;
font-size: 36rpx;
font-weight: 700;
line-height: 1.3;
}
.hero-card__description,
.section-card__description,
.result-card__subtitle {
display: block;
margin-top: 10rpx;
color: #7d705d;
font-size: 26rpx;
line-height: 1.7;
}
.search-row {
display: flex;
align-items: center;
margin-top: 18rpx;
}
.search-row__input {
flex: 1;
height: 84rpx;
padding: 0 20rpx;
border-radius: 22rpx;
background: rgba(255, 254, 250, 0.92);
color: #3f2e1f;
font-size: 26rpx;
}
.search-row__button {
margin-left: 12rpx;
padding: 20rpx 24rpx;
border-radius: 22rpx;
background: linear-gradient(135deg, #9a622d 0%, #6f4216 100%);
color: #fff8ef;
font-size: 26rpx;
line-height: 1;
}
.history-list {
margin: 14rpx -6rpx 0;
}
.history-chip {
display: inline-block;
margin: 6rpx;
padding: 12rpx 18rpx;
border-radius: 999rpx;
background: rgba(111, 66, 22, 0.08);
color: #6f4216;
font-size: 22rpx;
line-height: 1;
}
.result-card {
margin-top: 16rpx;
padding: 22rpx 0;
border-bottom: 1rpx solid rgba(118, 83, 42, 0.08);
}
.result-card:last-child {
border-bottom: 0;
}