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,15 @@
function createLearningCenterPageData() {
return {
title: '学习中心',
summaryCards: [
{ key: 'qa', value: 8, label: '问答' },
{ key: 'analysis', value: 5, label: '辨证' },
{ key: 'interpret', value: 6, label: '解读' },
{ key: 'bazi', value: 4, label: '排盘' }
]
}
}
module.exports = {
createLearningCenterPageData
}

48
utils/static-ux/mingli.js Normal file
View File

@@ -0,0 +1,48 @@
const { cloneList, resolveScene } = require('./shared')
const { ROUTES } = require('./route-map')
const MINGLI_QUICK_CARDS = Object.freeze([
{
key: 'hall',
title: '易学阁',
subtitle: '总览入口',
route: ROUTES.mingli.hall,
icon: '阁'
},
{
key: 'bazi',
title: '八字排盘',
subtitle: '静态排盘结果',
route: ROUTES.mingli.bazi,
icon: '盘'
},
{
key: 'interpret',
title: '命理解读',
subtitle: '问题与解读',
route: ROUTES.mingli.interpret,
icon: '解'
}
])
function createMingliHallPageData() {
return {
title: '易学阁',
quickCards: cloneList(MINGLI_QUICK_CARDS)
}
}
function createBaziPageData(rawScene) {
const scene = resolveScene(rawScene, ['default', 'result'], 'default')
return {
title: '八字排盘',
scene,
quickCards: cloneList(MINGLI_QUICK_CARDS)
}
}
module.exports = {
createMingliHallPageData,
createBaziPageData
}

View File

@@ -0,0 +1,81 @@
const ROUTES = Object.freeze({
tabs: {
home: '/pages/home/index',
library: '/pages/library/index',
ai: '/pages/ai/index',
profile: '/pages/profile/index',
login: '/pages/login/index'
},
tcm: {
aiHistory: '/packages/tcm/pages/ai-history/index',
assets: '/packages/tcm/pages/assets/index',
bianzheng: '/packages/tcm/pages/bianzheng/index',
bookDetail: '/packages/tcm/pages/book-detail/index',
searchBooks: '/packages/tcm/pages/search-books/index',
section: '/packages/tcm/pages/section/index',
placeholder: '/packages/tcm/pages/placeholder/index'
},
mingli: {
hall: '/packages/mingli/pages/hall/index',
bazi: '/packages/mingli/pages/bazi/index',
bookDetail: '/packages/mingli/pages/book-detail/index',
searchBooks: '/packages/mingli/pages/search-books/index',
section: '/packages/mingli/pages/section/index',
interpret: '/packages/mingli/pages/interpret/index'
},
learning: {
center: '/packages/learning/pages/center/index'
}
})
const TAB_PAGE_ROUTES = Object.freeze([
ROUTES.tabs.home,
ROUTES.tabs.library,
ROUTES.tabs.ai,
ROUTES.tabs.profile
])
function normalizeRoute(route) {
if (typeof route !== 'string') {
return ''
}
return route.split('?')[0]
}
function isTabRoute(route) {
return TAB_PAGE_ROUTES.includes(normalizeRoute(route))
}
function openStaticRoute(route, wxApi) {
if (!route || !wxApi) {
return false
}
if (isTabRoute(route)) {
if (typeof wxApi.switchTab !== 'function') {
return false
}
wxApi.switchTab({
url: normalizeRoute(route)
})
return true
}
if (typeof wxApi.navigateTo !== 'function') {
return false
}
wxApi.navigateTo({
url: route
})
return true
}
module.exports = {
ROUTES,
TAB_PAGE_ROUTES,
isTabRoute,
openStaticRoute
}

22
utils/static-ux/shared.js Normal file
View File

@@ -0,0 +1,22 @@
function cloneItem(item) {
return { ...item }
}
function cloneList(items) {
return items.map(cloneItem)
}
function resolveScene(rawScene, allowedScenes, fallbackScene) {
return allowedScenes.includes(rawScene) ? rawScene : fallbackScene
}
function resolveKind(rawKind, allowedKinds, fallbackKind) {
return allowedKinds.includes(rawKind) ? rawKind : fallbackKind
}
module.exports = {
cloneItem,
cloneList,
resolveScene,
resolveKind
}

74
utils/static-ux/tcm.js Normal file
View File

@@ -0,0 +1,74 @@
const { cloneList, resolveKind } = require('./shared')
const { ROUTES } = require('./route-map')
const TCM_HOME_HUB_CARDS = Object.freeze([
{
key: 'tcm-library',
title: '中医馆',
subtitle: '典籍与目录',
route: ROUTES.tabs.library,
badge: 'TCM'
},
{
key: 'mingli-hall',
title: '易学阁',
subtitle: '命理与经典',
route: ROUTES.mingli.hall,
badge: 'NEW'
},
{
key: 'bazi',
title: '八字排盘',
subtitle: '静态排盘结果',
route: ROUTES.mingli.bazi,
badge: 'BETA'
},
{
key: 'learning-center',
title: '学习中心',
subtitle: '继续学习与回顾',
route: ROUTES.learning.center,
badge: 'GO'
}
])
const TCM_ASSET_SURFACES = Object.freeze({
notes: {
title: '学习资产',
activeKind: 'notes',
kinds: ['notes', 'bookshelf', 'favorites', 'history']
},
bookshelf: {
title: '学习资产',
activeKind: 'bookshelf',
kinds: ['notes', 'bookshelf', 'favorites', 'history']
},
favorites: {
title: '学习资产',
activeKind: 'favorites',
kinds: ['notes', 'bookshelf', 'favorites', 'history']
},
history: {
title: '学习资产',
activeKind: 'history',
kinds: ['notes', 'bookshelf', 'favorites', 'history']
}
})
function createTcmHomeHubCards() {
return cloneList(TCM_HOME_HUB_CARDS)
}
function createTcmAssetPageData(rawKind) {
const activeKind = resolveKind(rawKind, ['notes', 'bookshelf', 'favorites', 'history'], 'notes')
return {
...TCM_ASSET_SURFACES[activeKind],
cards: createTcmHomeHubCards()
}
}
module.exports = {
createTcmHomeHubCards,
createTcmAssetPageData
}