This commit is contained in:
刘正航
2026-04-21 22:45:19 +08:00
commit b5237f9038
159 changed files with 7769 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
const { request } = require('../../utils/request')
const USER_MODULES = [
{ name: '信息发布', desc: '发布公开 / 私有 / 私信文本并实时检测', tag: '发布检测', path: '/pages/detect/index' },
{ name: '批量识别', desc: '多条文本批量检测并给出风险汇总', tag: '批量筛查', path: '/pages/batch/index' },
{ name: '发布历史', desc: '查看发布状态、概率和申诉进度', tag: '历史追踪', path: '/pages/history/index' },
{ name: '私信收件箱', desc: '查看通过检测后成功送达的私信', tag: '私信查看', path: '/pages/inbox/index' },
{ name: '个人中心', desc: '维护个人资料与密码设置', tag: '账号设置', path: '/pages/profile/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' })
}
})

View File

@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "工作台"
}

View File

@@ -0,0 +1,60 @@
<view class="container">
<view class="hero fade-up">
<view class="hero-badge">CONTROL CENTER</view>
<view class="hero-title">{{user ? ('欢迎,' + user.nickname) : '社区内容风控工作台'}}</view>
<view class="hero-sub">发布内容将实时进入朴素贝叶斯识别流程,疑似垃圾信息自动拦截并支持申诉。</view>
<view class="hero-meta" wx:if="{{modelInfo}}">
<text class="hero-metric">版本 {{modelInfo.version || '未训练'}}</text>
<text class="hero-metric">阈值 {{thresholdText}}</text>
<text class="hero-metric">样本 {{modelInfo.sample_count || 0}}</text>
</view>
</view>
<view class="card fade-up fade-up-delay-1" wx:if="{{modelInfo}}">
<view class="card-title">检测引擎状态</view>
<view class="grid-2">
<view class="kpi">
<view class="kpi-label">模型版本</view>
<view class="kpi-value">{{modelInfo.version || '未训练'}}</view>
</view>
<view class="kpi">
<view class="kpi-label">训练样本</view>
<view class="kpi-value">{{modelInfo.sample_count || 0}}</view>
</view>
<view class="kpi">
<view class="kpi-label">垃圾阈值</view>
<view class="kpi-value">{{thresholdText}}</view>
</view>
<view class="kpi">
<view class="kpi-label">最近训练</view>
<view class="kpi-value small">{{modelInfo.trained_at || '--'}}</view>
</view>
</view>
</view>
<view class="card fade-up fade-up-delay-2">
<view class="card-title">用户功能</view>
<view class="card-desc">常用操作入口,覆盖发布、检测、历史和账号设置。</view>
<view class="grid-2">
<view class="module-card" wx:for="{{userModules}}" wx:key="name" data-path="{{item.path}}" bindtap="goto">
<view class="module-name">{{item.name}}</view>
<view class="module-desc">{{item.desc}}</view>
<view class="module-tag">{{item.tag}}</view>
</view>
</view>
</view>
<view class="card fade-up fade-up-delay-3" wx:if="{{user && user.is_admin}}">
<view class="card-title">管理员功能</view>
<view class="card-desc">支持阈值调节、复核处理、样本维护和用户管理。</view>
<view class="grid-2">
<view class="module-card" wx:for="{{adminModules}}" wx:key="name" data-path="{{item.path}}" bindtap="goto">
<view class="module-name">{{item.name}}</view>
<view class="module-desc">{{item.desc}}</view>
<view class="module-tag">{{item.tag}}</view>
</view>
</view>
</view>
<button class="btn btn-ghost fade-up fade-up-delay-3" bindtap="logout">退出登录</button>
</view>

View File

@@ -0,0 +1 @@
/* home styles use global theme */