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' }) } })