feat: migrate static pages to native tabbar
This commit is contained in:
80
packages/tcm/pages/ai-history/index.js
Normal file
80
packages/tcm/pages/ai-history/index.js
Normal file
@@ -0,0 +1,80 @@
|
||||
const { resolveScene } = require('../../../../utils/static-ux/shared')
|
||||
const { ROUTES, openStaticRoute } = require('../../../../utils/static-ux/route-map')
|
||||
|
||||
const HISTORY_GROUPS = Object.freeze([
|
||||
{
|
||||
key: 'today',
|
||||
label: '今天',
|
||||
items: [
|
||||
{
|
||||
key: 'qa-1',
|
||||
tag: 'AI答疑',
|
||||
title: '什么是阴阳?',
|
||||
summary: '从基础概念切回到静态 AI 答疑面板。',
|
||||
route: ROUTES.tabs.ai
|
||||
},
|
||||
{
|
||||
key: 'analysis-1',
|
||||
tag: '辨证分析',
|
||||
title: '脾虚湿困的学习型分析',
|
||||
summary: '查看静态辨证结果展示页。',
|
||||
route: `${ROUTES.tcm.bianzheng}?scene=result`
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
key: 'week',
|
||||
label: '近七天',
|
||||
items: [
|
||||
{
|
||||
key: 'qa-2',
|
||||
tag: 'AI答疑',
|
||||
title: '肝主疏泄如何理解?',
|
||||
summary: '保留历史列表样式,不保留旧问答记录模型。',
|
||||
route: ROUTES.tabs.ai
|
||||
}
|
||||
]
|
||||
}
|
||||
])
|
||||
|
||||
function cloneGroups(groups) {
|
||||
return groups.map(group => ({
|
||||
...group,
|
||||
items: group.items.map(item => ({ ...item }))
|
||||
}))
|
||||
}
|
||||
|
||||
function createTcmAiHistoryPageData(rawScene) {
|
||||
const scene = resolveScene(rawScene, ['default', 'empty'], 'default')
|
||||
|
||||
return {
|
||||
title: 'AI对话历史',
|
||||
scene,
|
||||
emptyTitle: '还没有 AI 记录',
|
||||
emptyDescription: '去 AI 页先完成一次答疑或辨证分析。',
|
||||
actionText: '返回 AI',
|
||||
groups: scene === 'empty' ? [] : cloneGroups(HISTORY_GROUPS)
|
||||
}
|
||||
}
|
||||
|
||||
Page({
|
||||
data: createTcmAiHistoryPageData('default'),
|
||||
|
||||
onLoad(options) {
|
||||
this.setData(createTcmAiHistoryPageData(options.scene))
|
||||
},
|
||||
|
||||
handlePrimaryTap() {
|
||||
openStaticRoute(ROUTES.tabs.ai, wx)
|
||||
},
|
||||
|
||||
handleHistoryTap(event) {
|
||||
const { route } = event.currentTarget.dataset
|
||||
|
||||
openStaticRoute(route, wx)
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = {
|
||||
createTcmAiHistoryPageData
|
||||
}
|
||||
5
packages/tcm/pages/ai-history/index.json
Normal file
5
packages/tcm/pages/ai-history/index.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"navigationBarTitleText": "AI对话历史",
|
||||
"navigationBarBackgroundColor": "#f8ecd8",
|
||||
"navigationBarTextStyle": "black"
|
||||
}
|
||||
27
packages/tcm/pages/ai-history/index.wxml
Normal file
27
packages/tcm/pages/ai-history/index.wxml
Normal file
@@ -0,0 +1,27 @@
|
||||
<view class="ai-history-page">
|
||||
<text class="ai-history-page__title">{{title}}</text>
|
||||
|
||||
<view wx:if="{{scene === 'empty'}}" class="empty-card">
|
||||
<text class="empty-card__title">{{emptyTitle}}</text>
|
||||
<text class="empty-card__description">{{emptyDescription}}</text>
|
||||
<view class="empty-card__action" bindtap="handlePrimaryTap">{{actionText}}</view>
|
||||
</view>
|
||||
|
||||
<view wx:else class="history-groups">
|
||||
<view class="history-group" wx:for="{{groups}}" wx:key="key">
|
||||
<text class="history-group__label">{{item.label}}</text>
|
||||
<view
|
||||
class="history-item"
|
||||
wx:for="{{item.items}}"
|
||||
wx:for-item="historyItem"
|
||||
wx:key="key"
|
||||
data-route="{{historyItem.route}}"
|
||||
bindtap="handleHistoryTap"
|
||||
>
|
||||
<text class="history-item__tag">{{historyItem.tag}}</text>
|
||||
<text class="history-item__title">{{historyItem.title}}</text>
|
||||
<text class="history-item__description">{{historyItem.summary}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
82
packages/tcm/pages/ai-history/index.wxss
Normal file
82
packages/tcm/pages/ai-history/index.wxss
Normal file
@@ -0,0 +1,82 @@
|
||||
page {
|
||||
min-height: 100%;
|
||||
background: linear-gradient(180deg, #faf3e8 0%, #f1e9dd 100%);
|
||||
}
|
||||
|
||||
.ai-history-page {
|
||||
box-sizing: border-box;
|
||||
min-height: 100vh;
|
||||
padding: 28rpx 20rpx 72rpx;
|
||||
}
|
||||
|
||||
.ai-history-page__title {
|
||||
display: block;
|
||||
color: #2f1f12;
|
||||
font-family: 'STSong', 'Songti SC', serif;
|
||||
font-size: 56rpx;
|
||||
font-weight: 700;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.empty-card,
|
||||
.history-group {
|
||||
margin-top: 18rpx;
|
||||
padding: 26rpx;
|
||||
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);
|
||||
}
|
||||
|
||||
.empty-card__title,
|
||||
.history-group__label,
|
||||
.history-item__title {
|
||||
display: block;
|
||||
color: #2c2419;
|
||||
font-family: 'STSong', 'Songti SC', serif;
|
||||
font-size: 34rpx;
|
||||
font-weight: 700;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.empty-card__description,
|
||||
.history-item__description {
|
||||
display: block;
|
||||
margin-top: 10rpx;
|
||||
color: #7c705e;
|
||||
font-size: 26rpx;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.empty-card__action {
|
||||
display: inline-block;
|
||||
margin-top: 20rpx;
|
||||
padding: 18rpx 24rpx;
|
||||
border-radius: 999rpx;
|
||||
background: linear-gradient(135deg, #9e652f 0%, #75441a 100%);
|
||||
color: #fff7eb;
|
||||
font-size: 26rpx;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.history-item {
|
||||
margin-top: 14rpx;
|
||||
padding: 22rpx;
|
||||
border-radius: 24rpx;
|
||||
background: rgba(255, 254, 250, 0.94);
|
||||
border: 1rpx solid rgba(118, 83, 42, 0.06);
|
||||
}
|
||||
|
||||
.history-item__tag {
|
||||
display: inline-block;
|
||||
padding: 8rpx 14rpx;
|
||||
border-radius: 999rpx;
|
||||
background: rgba(111, 66, 22, 0.08);
|
||||
color: #6f4216;
|
||||
font-size: 22rpx;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.history-item__title {
|
||||
margin-top: 12rpx;
|
||||
}
|
||||
Reference in New Issue
Block a user