Files
c/miniprogram/pages/home/index.js
刘正航 f7fdc635c7 feat: 小程序UI重构为Apple设计系统并添加tabBar
- 全局样式重构为Apple Design System风格
- 添加底部tabBar导航(首页/发布/历史/私信/我的)
- 更紧凑的spacing和更小的字体尺寸
- pill圆角按钮和状态标签
- Action Blue (#0066cc) 单一accent色
- 添加tabBar图标资源

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-01 12:06:37 +08:00

64 lines
1.9 KiB
JavaScript

const { request } = require('../../utils/request')
const USER_MODULES = [
{ name: '批量识别', desc: '多条文本批量检测并给出风险汇总', tag: '批量筛查', path: '/pages/batch/index' }
]
const ADMIN_MODULES = [
{ name: '运营看板', desc: '监控发布、拦截、样本和模型状态', tag: '数据概览', path: '/pages/admin-dashboard/index' },
{ name: '复核与申诉', desc: '处理拦截复核和用户申诉', tag: '审核处理', path: '/pages/admin-review/index' },
{ name: '样本管理', desc: '维护训练样本并触发模型重训', tag: '模型迭代', path: '/pages/admin-samples/index' },
{ name: '用户管理', desc: '编辑用户信息和权限', tag: '权限管理', path: '/pages/admin-users/index' }
]
Page({
data: {
loading: true,
user: null,
modelInfo: null,
threshold: null,
thresholdText: '--',
userModules: USER_MODULES,
adminModules: ADMIN_MODULES
},
onShow() {
this.bootstrap()
},
async bootstrap() {
const app = getApp()
if (!app.globalData.token) {
wx.reLaunch({ url: '/pages/login/index' })
return
}
this.setData({ loading: true })
try {
const [user, modelInfo] = await Promise.all([
request({ url: '/auth/me' }),
request({ url: '/spam/model/info' })
])
app.globalData.user = user
wx.setStorageSync('user', user)
const threshold = modelInfo.threshold || null
const thresholdText = threshold === null || threshold === undefined ? '--' : `${(Number(threshold) * 100).toFixed(1)}%`
this.setData({ user, modelInfo, threshold, thresholdText })
} finally {
this.setData({ loading: false })
}
},
goto(e) {
const path = e.currentTarget.dataset.path
if (!path) return
wx.navigateTo({ url: path })
},
logout() {
getApp().clearAuth()
wx.reLaunch({ url: '/pages/login/index' })
}
})