Files
c/miniprogram/pages/home/index.js
刘正航 49c946dd55 feat: 小程序移除管理后台入口,新增admin-web前端项目
将管理后台功能从微信小程序中剥离,独立为Vue.js前端项目admin-web

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 13:49:07 +08:00

56 lines
1.3 KiB
JavaScript

const { request } = require('../../utils/request')
const USER_MODULES = [
{ name: '批量识别', desc: '多条文本批量检测并给出风险汇总', tag: '批量筛查', path: '/pages/batch/index' }
]
Page({
data: {
loading: true,
user: null,
modelInfo: null,
threshold: null,
thresholdText: '--',
userModules: USER_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' })
}
})