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

350
pages/library/index.js Normal file
View File

@@ -0,0 +1,350 @@
const { ROUTES, openStaticRoute } = require('../../utils/static-ux/route-map')
const LIBRARY_CATEGORIES = Object.freeze([
{ id: 'featured', name: '精选' },
{ id: 'annotation', name: '注解' },
{ id: 'classic-theory', name: '经论' },
{ id: 'cold-damage', name: '伤寒金匮' },
{ id: 'formula', name: '医方' },
{ id: 'materia-medica', name: '本草' },
{ id: 'acupuncture', name: '针灸' },
{ id: 'medical-record', name: '医案' },
{ id: 'comprehensive', name: '综合' }
])
const LIBRARY_BOOKS = Object.freeze({
featured: [
{
id: 'huangdi-neijing-suwen',
coverText: '典',
title: '黄帝内经素问',
author: '王冰次',
dynasty: '唐',
period: '公元762年'
},
{
id: 'shang-han-lun',
coverText: '典',
title: '伤寒论',
author: '张仲景',
dynasty: '东汉',
period: '公元25-220年'
},
{
id: 'wen-bing-tiao-bian',
coverText: '典',
title: '温病条辨',
author: '吴鞠通',
dynasty: '清',
period: '公元1644-1911年'
},
{
id: 'bencao-gangmu-bieming-lu',
coverText: '典',
title: '本草纲目别名录',
author: '李时珍',
dynasty: '明',
period: '公元1368-1644年'
},
{
id: 'huangdi-neijing-jizhu',
coverText: '典',
title: '黄帝内经灵枢集注',
author: '张志聪',
dynasty: '清',
period: '公元1672年'
},
{
id: 'jingui-yaolue-fanglun',
coverText: '典',
title: '金匮要略方论',
author: '张仲景',
dynasty: '汉',
period: '公元219年'
}
],
annotation: [
{
id: 'huangdi-neijing-suwen-jizhu',
coverText: '典',
title: '黄帝内经素问集注',
author: '张志聪',
dynasty: '清',
period: '公元1672年'
},
{
id: 'shennong-bencao-jizhu',
coverText: '典',
title: '神农本草经辑注',
author: '孙星衍',
dynasty: '清',
period: '公元1796年'
},
{
id: 'nanjing-jizhu',
coverText: '典',
title: '难经集注',
author: '王九思',
dynasty: '明',
period: '公元1506年'
}
],
'classic-theory': [
{
id: 'nan-jing',
coverText: '典',
title: '难经',
author: '扁鹊',
dynasty: '战国',
period: '约公元前475-221年'
},
{
id: 'lei-jing',
coverText: '典',
title: '类经',
author: '张介宾',
dynasty: '明',
period: '公元1624年'
},
{
id: 'yi-zong-bi-du',
coverText: '典',
title: '医宗必读',
author: '李中梓',
dynasty: '明',
period: '公元1637年'
}
],
'cold-damage': [
{
id: 'jin-kui-yao-lve',
coverText: '典',
title: '金匮要略',
author: '张仲景',
dynasty: '东汉',
period: '公元219年'
},
{
id: 'zhu-jie-shang-han-lun',
coverText: '典',
title: '注解伤寒论',
author: '成无己',
dynasty: '金',
period: '公元1144年'
},
{
id: 'shang-han-ming-li-lun',
coverText: '典',
title: '伤寒明理论',
author: '成无己',
dynasty: '金',
period: '公元1156年'
}
],
formula: [
{
id: 'tai-ping-hui-min-he-ji-ju-fang',
coverText: '典',
title: '太平惠民和剂局方',
author: '陈师文',
dynasty: '宋',
period: '公元1107年'
},
{
id: 'pu-ji-fang',
coverText: '典',
title: '普济方',
author: '朱橚',
dynasty: '明',
period: '公元1406年'
},
{
id: 'yi-fang-kao',
coverText: '典',
title: '医方考',
author: '吴昆',
dynasty: '明',
period: '公元1584年'
}
],
'materia-medica': [
{
id: 'shennong-bencao-jing',
coverText: '典',
title: '神农本草经',
author: '佚名',
dynasty: '汉',
period: '约公元1-2世纪'
},
{
id: 'bencao-gangmu',
coverText: '典',
title: '本草纲目',
author: '李时珍',
dynasty: '明',
period: '公元1578年'
},
{
id: 'bencao-cong-xin',
coverText: '典',
title: '本草从新',
author: '吴仪洛',
dynasty: '清',
period: '公元1757年'
}
],
acupuncture: [
{
id: 'zhen-jiu-jia-yi-jing',
coverText: '典',
title: '针灸甲乙经',
author: '皇甫谧',
dynasty: '西晋',
period: '公元282年'
},
{
id: 'zhen-jiu-da-cheng',
coverText: '典',
title: '针灸大成',
author: '杨继洲',
dynasty: '明',
period: '公元1601年'
},
{
id: 'tong-ren-shu-xue-zhen-jiu-tu-jing',
coverText: '典',
title: '铜人腧穴针灸图经',
author: '王惟一',
dynasty: '宋',
period: '公元1026年'
}
],
'medical-record': [
{
id: 'lin-zheng-zhi-nan-yi-an',
coverText: '典',
title: '临证指南医案',
author: '叶天士',
dynasty: '清',
period: '公元1746年'
},
{
id: 'shi-an-de-xiao-fang',
coverText: '典',
title: '石案得效方',
author: '危亦林',
dynasty: '元',
period: '公元1337年'
},
{
id: 'wang-meng-ying-yi-an',
coverText: '典',
title: '王孟英医案',
author: '王孟英',
dynasty: '清',
period: '公元1862年'
}
],
comprehensive: [
{
id: 'yi-xue-ru-men',
coverText: '典',
title: '医学入门',
author: '李梴',
dynasty: '明',
period: '公元1575年'
},
{
id: 'jing-yue-quan-shu',
coverText: '典',
title: '景岳全书',
author: '张介宾',
dynasty: '明',
period: '公元1624年'
},
{
id: 'yi-zong-jin-jian',
coverText: '典',
title: '医宗金鉴',
author: '吴谦',
dynasty: '清',
period: '公元1742年'
}
]
})
function cloneItems(items) {
return items.map(item => ({ ...item }))
}
function getCategoryById(categoryId) {
return LIBRARY_CATEGORIES.find(item => item.id === categoryId) || LIBRARY_CATEGORIES[0]
}
function getBooksByCategory(categoryId) {
const activeCategory = getCategoryById(categoryId)
return cloneItems(LIBRARY_BOOKS[activeCategory.id] || [])
}
function createLibraryPageData(categoryId) {
const activeCategory = getCategoryById(categoryId)
return {
title: '典籍',
searchButtonText: '搜索',
domainBridge: {
title: '进入易学阁',
subtitle: '切换到命理与经典的静态学习入口',
route: ROUTES.mingli.hall
},
categories: cloneItems(LIBRARY_CATEGORIES),
activeCategoryId: activeCategory.id,
currentCategoryName: activeCategory.name,
visibleBooks: getBooksByCategory(activeCategory.id)
}
}
function showNavigate(route) {
if (openStaticRoute(route, wx)) {
return
}
if (typeof wx?.showToast === 'function') {
wx.showToast({
title: '页面暂不可达',
icon: 'none'
})
}
}
Page({
data: createLibraryPageData(),
handleCategoryTap(event) {
const categoryId = event.currentTarget.dataset.categoryId
this.setData(createLibraryPageData(categoryId))
},
handleSearchTap() {
if (!wx || typeof wx.showToast !== 'function') {
return
}
wx.showToast({
title: '搜索功能暂未开放',
icon: 'none'
})
},
handleDomainBridgeTap() {
showNavigate(ROUTES.mingli.hall)
}
})
module.exports = {
LIBRARY_CATEGORIES,
LIBRARY_BOOKS,
createLibraryPageData,
getBooksByCategory
}

5
pages/library/index.json Normal file
View File

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

43
pages/library/index.wxml Normal file
View File

@@ -0,0 +1,43 @@
<view class="library-page">
<view class="library-page__header">
<text class="library-page__title">{{title}}</text>
<view class="library-page__search" bindtap="handleSearchTap">{{searchButtonText}}</view>
</view>
<view class="library-page__content">
<view class="library-page__sidebar">
<view
class="library-page__category {{activeCategoryId === item.id ? 'library-page__category--active' : ''}}"
wx:for="{{categories}}"
wx:key="id"
data-category-id="{{item.id}}"
bindtap="handleCategoryTap"
>
<text class="library-page__category-label">{{item.name}}</text>
</view>
</view>
<view class="library-page__main">
<view class="library-page__bridge" bindtap="handleDomainBridgeTap">
<text class="library-page__bridge-title">{{domainBridge.title}}</text>
<text class="library-page__bridge-subtitle">{{domainBridge.subtitle}}</text>
</view>
<view class="library-page__current">当前分类: {{currentCategoryName}}</view>
<view class="library-page__book-list">
<view class="book-card" wx:for="{{visibleBooks}}" wx:key="id">
<view class="book-card__cover">
<view class="book-card__cover-spine"></view>
<text class="book-card__cover-char">{{item.coverText}}</text>
</view>
<view class="book-card__body">
<text class="book-card__title">{{item.title}}</text>
<text class="book-card__meta">{{item.author}} / {{item.dynasty}} / {{item.period}}</text>
</view>
</view>
</view>
</view>
</view>
</view>

205
pages/library/index.wxss Normal file
View File

@@ -0,0 +1,205 @@
page {
min-height: 100%;
background:
linear-gradient(180deg, #f8edd6 0%, #f9f0de 24%, #f6ead4 100%);
}
.library-page {
box-sizing: border-box;
min-height: 100vh;
padding: 36rpx 20rpx 80rpx;
background:
linear-gradient(135deg, rgba(255, 255, 255, 0.58) 0%, rgba(255, 248, 236, 0) 36%),
linear-gradient(225deg, rgba(255, 245, 227, 0.68) 0%, rgba(255, 245, 227, 0) 48%);
}
.library-page__header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 18rpx 2rpx 30rpx;
}
.library-page__title {
font-family: 'STSong', 'Songti SC', serif;
font-size: 60rpx;
font-weight: 700;
line-height: 1.2;
color: #2f1f12;
}
.library-page__search {
min-width: 112rpx;
padding: 18rpx 26rpx;
border-radius: 999rpx;
background: rgba(240, 225, 201, 0.9);
box-shadow: 0 12rpx 24rpx rgba(173, 120, 56, 0.08);
color: #a56d2d;
font-family: 'STSong', 'Songti SC', serif;
font-size: 30rpx;
line-height: 1;
text-align: center;
}
.library-page__content {
display: flex;
align-items: stretch;
}
.library-page__sidebar {
box-sizing: border-box;
width: 168rpx;
flex-shrink: 0;
padding: 16rpx 14rpx;
border: 1rpx solid rgba(189, 155, 105, 0.12);
border-radius: 34rpx;
background: rgba(255, 250, 243, 0.86);
box-shadow: 0 16rpx 32rpx rgba(178, 144, 99, 0.08);
}
.library-page__category {
padding: 22rpx 16rpx;
border-radius: 24rpx;
}
.library-page__category + .library-page__category {
margin-top: 14rpx;
}
.library-page__category--active {
background: linear-gradient(180deg, rgba(240, 228, 207, 0.98) 0%, rgba(236, 221, 197, 0.98) 100%);
box-shadow: inset 0 -8rpx 18rpx rgba(186, 149, 99, 0.08);
}
.library-page__category-label {
display: block;
color: #8f6a42;
font-family: 'STSong', 'Songti SC', serif;
font-size: 32rpx;
line-height: 1.5;
}
.library-page__category--active .library-page__category-label {
color: #7b501f;
font-weight: 700;
}
.library-page__main {
flex: 1;
margin-left: 16rpx;
}
.library-page__bridge {
padding: 26rpx 26rpx 24rpx;
border: 1rpx solid rgba(191, 154, 103, 0.2);
border-radius: 34rpx;
background: linear-gradient(135deg, rgba(255, 249, 239, 0.96) 0%, rgba(245, 233, 214, 0.98) 100%);
box-shadow: 0 16rpx 28rpx rgba(176, 136, 84, 0.1);
}
.library-page__bridge-title {
display: block;
color: #6f451c;
font-family: 'STSong', 'Songti SC', serif;
font-size: 36rpx;
font-weight: 700;
line-height: 1.35;
}
.library-page__bridge-subtitle {
display: block;
margin-top: 10rpx;
color: #97714a;
font-size: 26rpx;
line-height: 1.7;
}
.library-page__current {
margin-top: 16rpx;
padding: 30rpx 26rpx;
border: 1rpx solid rgba(189, 155, 105, 0.12);
border-radius: 34rpx 34rpx 0 0;
background: rgba(255, 250, 243, 0.88);
color: #9c6d35;
font-family: 'STSong', 'Songti SC', serif;
font-size: 30rpx;
line-height: 1.4;
}
.library-page__book-list {
padding: 0 0 8rpx;
border: 1rpx solid rgba(189, 155, 105, 0.08);
border-top: 0;
border-radius: 0 0 34rpx 34rpx;
background: rgba(255, 250, 243, 0.72);
}
.book-card {
display: flex;
align-items: center;
margin: 18rpx;
padding: 22rpx 20rpx;
border: 1rpx solid rgba(192, 159, 117, 0.14);
border-radius: 28rpx;
background: rgba(255, 252, 247, 0.96);
box-shadow: 0 12rpx 24rpx rgba(181, 145, 97, 0.08);
}
.book-card__cover {
position: relative;
width: 100rpx;
height: 136rpx;
flex-shrink: 0;
border-radius: 22rpx;
background: linear-gradient(180deg, #d5b07b 0%, #c99f67 100%);
box-shadow: 0 10rpx 18rpx rgba(173, 128, 70, 0.14);
}
.book-card__cover-spine {
position: absolute;
top: 0;
left: 0;
width: 12rpx;
height: 100%;
border-top-left-radius: 22rpx;
border-bottom-left-radius: 22rpx;
background: rgba(138, 93, 48, 0.4);
}
.book-card__cover-char {
position: absolute;
top: 50%;
left: 12rpx;
right: 0;
transform: translateY(-50%);
color: #fff7eb;
font-family: 'STSong', 'Songti SC', serif;
font-size: 42rpx;
font-weight: 700;
line-height: 1;
text-align: center;
}
.book-card__body {
min-width: 0;
flex: 1;
margin-left: 18rpx;
}
.book-card__title {
display: block;
color: #2f1f12;
font-family: 'STSong', 'Songti SC', serif;
font-size: 42rpx;
font-weight: 700;
line-height: 1.35;
}
.book-card__meta {
display: block;
margin-top: 14rpx;
color: #8f6a42;
font-family: 'STSong', 'Songti SC', serif;
font-size: 28rpx;
line-height: 1.6;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB