init
This commit is contained in:
48
packages/demo/pages/workbench/index.js
Normal file
48
packages/demo/pages/workbench/index.js
Normal file
@@ -0,0 +1,48 @@
|
||||
const { sessionStore } = require('../../../../stores')
|
||||
|
||||
const MODULES = [
|
||||
{
|
||||
title: 'Request Layer',
|
||||
description: '统一超时、重试、鉴权失效和重复提交控制,页面不直接碰 wx.request。',
|
||||
badge: 'service',
|
||||
actionText: '查看首页',
|
||||
actionPath: '/pages/home/index'
|
||||
},
|
||||
{
|
||||
title: 'Session Store',
|
||||
description: '跨页共享的登录态只保留在 store,本页的筛选和列表状态仍然是页面本地状态。',
|
||||
badge: 'store',
|
||||
actionText: '打开登录页',
|
||||
actionPath: '/pages/login/index'
|
||||
}
|
||||
]
|
||||
|
||||
Page({
|
||||
data: {
|
||||
modules: MODULES,
|
||||
currentUser: '访客',
|
||||
localTodos: [
|
||||
'把 /services/api 替换成真实后端接口',
|
||||
'按业务域继续拆 packages/<domain>',
|
||||
'接入 miniprogram-ci 上传非生产环境'
|
||||
]
|
||||
},
|
||||
onLoad() {
|
||||
const state = sessionStore.getState()
|
||||
|
||||
this.setData({
|
||||
currentUser: state.userInfo?.nickname || state.userInfo?.name || '访客'
|
||||
})
|
||||
},
|
||||
handleEntryAction(event) {
|
||||
const { path } = event.detail
|
||||
|
||||
if (!path) {
|
||||
return
|
||||
}
|
||||
|
||||
wx.navigateTo({
|
||||
url: path
|
||||
})
|
||||
}
|
||||
})
|
||||
7
packages/demo/pages/workbench/index.json
Normal file
7
packages/demo/pages/workbench/index.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"navigationBarTitleText": "工作台",
|
||||
"usingComponents": {
|
||||
"entry-card": "../../../../components/biz/entry-card/index",
|
||||
"t-tag": "tdesign-miniprogram/tag/tag"
|
||||
}
|
||||
}
|
||||
29
packages/demo/pages/workbench/index.wxml
Normal file
29
packages/demo/pages/workbench/index.wxml
Normal file
@@ -0,0 +1,29 @@
|
||||
<view class="page-shell">
|
||||
<view class="panel workbench-hero">
|
||||
<t-tag theme="success" variant="light">Subpackage</t-tag>
|
||||
<text class="workbench-hero__title">业务工作台示例</text>
|
||||
<text class="section-copy">
|
||||
当前用户:{{currentUser}}。这个页面位于分包中,用来承接持续增长的业务,而不是继续把主包做胖。
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view class="entry-list">
|
||||
<entry-card
|
||||
wx:for="{{modules}}"
|
||||
wx:key="title"
|
||||
title="{{item.title}}"
|
||||
description="{{item.description}}"
|
||||
badge="{{item.badge}}"
|
||||
actionText="{{item.actionText}}"
|
||||
actionPath="{{item.actionPath}}"
|
||||
bind:action="handleEntryAction"
|
||||
></entry-card>
|
||||
</view>
|
||||
|
||||
<view class="panel todo-panel">
|
||||
<text class="section-title">下一步扩展</text>
|
||||
<view class="todo-list">
|
||||
<text wx:for="{{localTodos}}" wx:key="*this" class="todo-item">{{index + 1}}. {{item}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
37
packages/demo/pages/workbench/index.wxss
Normal file
37
packages/demo/pages/workbench/index.wxss
Normal file
@@ -0,0 +1,37 @@
|
||||
.workbench-hero {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20rpx;
|
||||
padding: 32rpx;
|
||||
}
|
||||
|
||||
.workbench-hero__title {
|
||||
font-size: 40rpx;
|
||||
font-weight: 700;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.entry-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24rpx;
|
||||
}
|
||||
|
||||
.todo-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24rpx;
|
||||
padding: 32rpx;
|
||||
}
|
||||
|
||||
.todo-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.todo-item {
|
||||
font-size: 24rpx;
|
||||
line-height: 1.7;
|
||||
color: #475569;
|
||||
}
|
||||
Reference in New Issue
Block a user