Compare commits
5 Commits
200a0ae2e4
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0f7a758eb | ||
|
|
b8acc8be43 | ||
|
|
829599bc17 | ||
|
|
f3c0c44f27 | ||
|
|
eaa5a27370 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -17,3 +17,8 @@ __pycache__/
|
|||||||
# OS
|
# OS
|
||||||
.DS_Store
|
.DS_Store
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
|
||||||
|
# Archives
|
||||||
|
*.zip
|
||||||
|
*.tar.gz
|
||||||
|
*.7z
|
||||||
|
|||||||
@@ -5,6 +5,23 @@ import './styles/theme.css'
|
|||||||
|
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
|
|
||||||
|
Vue.config.errorHandler = (err, vm, info) => {
|
||||||
|
console.error('[vue error]', info, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
Vue.config.warnHandler = (msg, vm, trace) => {
|
||||||
|
console.warn('[vue warn]', msg, trace)
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('unhandledrejection', (event) => {
|
||||||
|
console.warn('[unhandled rejection]', event.reason)
|
||||||
|
event.preventDefault()
|
||||||
|
})
|
||||||
|
|
||||||
|
window.addEventListener('error', (event) => {
|
||||||
|
console.error('[window error]', event.error || event.message)
|
||||||
|
})
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
router,
|
router,
|
||||||
render: (h) => h(App)
|
render: (h) => h(App)
|
||||||
|
|||||||
@@ -57,3 +57,42 @@ export function previewImage(urls, current) {
|
|||||||
if (!urls || !urls.length) return
|
if (!urls || !urls.length) return
|
||||||
ensurePreview().open({ urls, current })
|
ensurePreview().open({ urls, current })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function copyText(text) {
|
||||||
|
if (text === undefined || text === null) return false
|
||||||
|
const value = String(text)
|
||||||
|
|
||||||
|
if (navigator.clipboard && window.isSecureContext) {
|
||||||
|
try {
|
||||||
|
await navigator.clipboard.writeText(value)
|
||||||
|
return true
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('[copyText] navigator.clipboard 不可用,回退到 execCommand', err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const textarea = document.createElement('textarea')
|
||||||
|
textarea.value = value
|
||||||
|
textarea.setAttribute('readonly', '')
|
||||||
|
textarea.style.position = 'fixed'
|
||||||
|
textarea.style.top = '0'
|
||||||
|
textarea.style.left = '0'
|
||||||
|
textarea.style.width = '1px'
|
||||||
|
textarea.style.height = '1px'
|
||||||
|
textarea.style.opacity = '0'
|
||||||
|
textarea.style.pointerEvents = 'none'
|
||||||
|
document.body.appendChild(textarea)
|
||||||
|
|
||||||
|
textarea.focus()
|
||||||
|
textarea.select()
|
||||||
|
textarea.setSelectionRange(0, value.length)
|
||||||
|
|
||||||
|
const ok = document.execCommand('copy')
|
||||||
|
document.body.removeChild(textarea)
|
||||||
|
return !!ok
|
||||||
|
} catch (err) {
|
||||||
|
console.error('[copyText] execCommand 也失败了', err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { getToken, clearAuth } from '@/utils/auth'
|
import { getToken, clearAuth } from '@/utils/auth'
|
||||||
import { toast } from '@/utils/feedback'
|
|
||||||
|
|
||||||
const BASE_URL = '/api'
|
const BASE_URL = '/api'
|
||||||
|
|
||||||
@@ -21,21 +20,21 @@ instance.interceptors.request.use(
|
|||||||
(err) => Promise.reject(err)
|
(err) => Promise.reject(err)
|
||||||
)
|
)
|
||||||
|
|
||||||
function handleUnauthorized() {
|
function handleUnauthorized(url) {
|
||||||
|
console.warn('[auth] 登录已过期,自动退出登录', url || '')
|
||||||
clearAuth()
|
clearAuth()
|
||||||
toast('登录已过期,请重新登录', 'error')
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (location.hash !== '#/login') {
|
if (location.hash !== '#/login') {
|
||||||
location.hash = '#/login'
|
location.hash = '#/login'
|
||||||
}
|
}
|
||||||
}, 400)
|
}, 200)
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.interceptors.response.use(
|
instance.interceptors.response.use(
|
||||||
(response) => response,
|
(response) => response,
|
||||||
(err) => {
|
(err) => {
|
||||||
if (err && err.response && err.response.status === 401) {
|
if (err && err.response && err.response.status === 401) {
|
||||||
handleUnauthorized()
|
handleUnauthorized(err.config && err.config.url)
|
||||||
}
|
}
|
||||||
return Promise.reject(err)
|
return Promise.reject(err)
|
||||||
}
|
}
|
||||||
@@ -43,14 +42,7 @@ instance.interceptors.response.use(
|
|||||||
|
|
||||||
export function request({ url, method = 'GET', data, params, headers, responseType } = {}) {
|
export function request({ url, method = 'GET', data, params, headers, responseType } = {}) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
instance({
|
instance({ url, method, data, params, headers, responseType })
|
||||||
url,
|
|
||||||
method,
|
|
||||||
data,
|
|
||||||
params,
|
|
||||||
headers,
|
|
||||||
responseType
|
|
||||||
})
|
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (responseType === 'blob' || responseType === 'arraybuffer') {
|
if (responseType === 'blob' || responseType === 'arraybuffer') {
|
||||||
resolve(res)
|
resolve(res)
|
||||||
@@ -64,18 +56,16 @@ export function request({ url, method = 'GET', data, params, headers, responseTy
|
|||||||
}
|
}
|
||||||
|
|
||||||
const message = body.message || '请求失败'
|
const message = body.message || '请求失败'
|
||||||
toast(message, 'error')
|
console.error('[request]', method, url, '业务失败:', message, body)
|
||||||
reject(new Error(message))
|
reject(new Error(message))
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
if (err && err.response && err.response.status === 401) {
|
if (err && err.response && err.response.status === 401) {
|
||||||
reject(err)
|
reject(new Error('Unauthorized'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const msg = (err && err.message) || '网络异常'
|
const msg = (err && err.message) || '网络异常'
|
||||||
if (!/Unauthorized/.test(msg)) {
|
console.error('[request]', method, url, '请求异常:', msg, err)
|
||||||
toast(msg, 'error')
|
|
||||||
}
|
|
||||||
reject(err)
|
reject(err)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -98,12 +88,16 @@ export function uploadFile(file) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const message = body.message || '上传失败'
|
const message = body.message || '上传失败'
|
||||||
toast(message, 'error')
|
console.error('[upload] 业务失败:', message, body)
|
||||||
reject(new Error(message))
|
reject(new Error(message))
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
if (err && err.response && err.response.status === 401) {
|
||||||
|
reject(new Error('Unauthorized'))
|
||||||
|
return
|
||||||
|
}
|
||||||
const msg = (err && err.message) || '上传失败'
|
const msg = (err && err.message) || '上传失败'
|
||||||
toast(msg, 'error')
|
console.error('[upload] 请求异常:', msg, err)
|
||||||
reject(err)
|
reject(err)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -136,7 +136,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { request } from '@/utils/request'
|
import { request } from '@/utils/request'
|
||||||
import { toast, confirm } from '@/utils/feedback'
|
import { toast, confirm, copyText } from '@/utils/feedback'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'BatchView',
|
name: 'BatchView',
|
||||||
@@ -176,7 +176,10 @@ export default {
|
|||||||
this.lineCount = lines.length
|
this.lineCount = lines.length
|
||||||
toast(`已读取 ${lines.length} 条文本`, 'success')
|
toast(`已读取 ${lines.length} 条文本`, 'success')
|
||||||
}
|
}
|
||||||
reader.onerror = () => toast('文件读取失败', 'error')
|
reader.onerror = (e) => {
|
||||||
|
console.error('[batch] 文件读取失败', e)
|
||||||
|
toast('文件读取失败', 'error')
|
||||||
|
}
|
||||||
reader.readAsText(file, 'utf-8')
|
reader.readAsText(file, 'utf-8')
|
||||||
e.target.value = ''
|
e.target.value = ''
|
||||||
},
|
},
|
||||||
@@ -267,6 +270,7 @@ export default {
|
|||||||
}, 0)
|
}, 0)
|
||||||
toast('导出成功', 'success')
|
toast('导出成功', 'success')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error('[batch] 导出失败', err)
|
||||||
toast('导出失败', 'error')
|
toast('导出失败', 'error')
|
||||||
} finally {
|
} finally {
|
||||||
this.exporting = false
|
this.exporting = false
|
||||||
@@ -278,10 +282,11 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const csv = this.generateCSV()
|
const csv = this.generateCSV()
|
||||||
try {
|
const ok = await copyText(csv)
|
||||||
await navigator.clipboard.writeText(csv)
|
if (ok) {
|
||||||
toast('CSV 内容已复制到剪贴板', 'success')
|
toast('CSV 内容已复制到剪贴板', 'success')
|
||||||
} catch (err) {
|
} else {
|
||||||
|
console.error('[batch] 复制失败,CSV 内容打印到控制台供手动复制\n' + csv)
|
||||||
toast('复制失败,请手动选择文本', 'error')
|
toast('复制失败,请手动选择文本', 'error')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,6 +168,8 @@ export default {
|
|||||||
detect_spam_probability_text: this.formatPercent((result.detect || {}).spam_probability, 2)
|
detect_spam_probability_text: this.formatPercent((result.detect || {}).spam_probability, 2)
|
||||||
}
|
}
|
||||||
toast(result.publish_allowed ? '发布成功' : '已拦截,可申诉', result.publish_allowed ? 'success' : 'error')
|
toast(result.publish_allowed ? '发布成功' : '已拦截,可申诉', result.publish_allowed ? 'success' : 'error')
|
||||||
|
} catch (err) {
|
||||||
|
console.error('[detect] 发布失败', err)
|
||||||
} finally {
|
} finally {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,11 +118,14 @@ export default {
|
|||||||
async bootstrap() {
|
async bootstrap() {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
try {
|
try {
|
||||||
const [, modelInfo] = await Promise.all([
|
await refreshUser()
|
||||||
refreshUser(),
|
const modelInfo = await request({ url: '/spam/model/info' }).catch((err) => {
|
||||||
request({ url: '/spam/model/info' })
|
console.warn('[home] 模型信息加载失败', err)
|
||||||
])
|
return null
|
||||||
this.modelInfo = modelInfo
|
})
|
||||||
|
if (modelInfo) this.modelInfo = modelInfo
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('[home] bootstrap 异常', err)
|
||||||
} finally {
|
} finally {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,7 +147,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { request } from '@/utils/request'
|
import { request } from '@/utils/request'
|
||||||
import { toast } from '@/utils/feedback'
|
import { toast, copyText } from '@/utils/feedback'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'AdminDashboard',
|
name: 'AdminDashboard',
|
||||||
@@ -256,10 +256,12 @@ export default {
|
|||||||
`【近 7 日趋势】`,
|
`【近 7 日趋势】`,
|
||||||
(report.spam_trend || []).slice(-7).map((t) => `${t.label}: 拦截${t.blocked}条,发布${t.published}条`).join('\n')
|
(report.spam_trend || []).slice(-7).map((t) => `${t.label}: 拦截${t.blocked}条,发布${t.published}条`).join('\n')
|
||||||
]
|
]
|
||||||
try {
|
const content = lines.join('\n')
|
||||||
await navigator.clipboard.writeText(lines.join('\n'))
|
const ok = await copyText(content)
|
||||||
|
if (ok) {
|
||||||
toast('报告已复制到剪贴板', 'success')
|
toast('报告已复制到剪贴板', 'success')
|
||||||
} catch (err) {
|
} else {
|
||||||
|
console.error('[dashboard] 复制失败,报告内容打印到控制台供手动复制\n' + content)
|
||||||
toast('复制失败,请手动选择', 'error')
|
toast('复制失败,请手动选择', 'error')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,6 +161,7 @@ export default {
|
|||||||
try {
|
try {
|
||||||
items = JSON.parse(this.importText)
|
items = JSON.parse(this.importText)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error('[samples] JSON 格式错误', err)
|
||||||
toast('JSON 格式错误', 'error')
|
toast('JSON 格式错误', 'error')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ export default {
|
|||||||
try {
|
try {
|
||||||
items = JSON.parse(this.importText)
|
items = JSON.parse(this.importText)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error('[users] JSON 格式错误', err)
|
||||||
toast('JSON 格式错误', 'error')
|
toast('JSON 格式错误', 'error')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ module.exports = defineConfig({
|
|||||||
port: 8080,
|
port: 8080,
|
||||||
host: '0.0.0.0',
|
host: '0.0.0.0',
|
||||||
historyApiFallback: true,
|
historyApiFallback: true,
|
||||||
|
client: {
|
||||||
|
overlay: false,
|
||||||
|
logging: 'warn'
|
||||||
|
},
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/api': {
|
||||||
target: 'http://127.0.0.1:5000',
|
target: 'http://127.0.0.1:5000',
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"host": "127.0.0.1",
|
"host": "127.0.0.1",
|
||||||
"port": 3306,
|
"port": 3306,
|
||||||
"user": "root",
|
"user": "root",
|
||||||
"password": "123456",
|
"password": "rootroot",
|
||||||
"database": "spam_nb_miniapp",
|
"database": "spam_nb_miniapp",
|
||||||
"charset": "utf8mb4",
|
"charset": "utf8mb4",
|
||||||
"admin_init": {
|
"admin_init": {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"pages": [
|
"pages": [
|
||||||
"pages/home/index",
|
"pages/home/index",
|
||||||
"pages/detect/index",
|
|
||||||
"pages/history/index",
|
"pages/history/index",
|
||||||
"pages/inbox/index",
|
"pages/inbox/index",
|
||||||
"pages/profile/index",
|
"pages/profile/index",
|
||||||
@@ -24,12 +23,6 @@
|
|||||||
"list": [
|
"list": [
|
||||||
{
|
{
|
||||||
"pagePath": "pages/home/index",
|
"pagePath": "pages/home/index",
|
||||||
"text": "首页",
|
|
||||||
"iconPath": "assets/icons/home.png",
|
|
||||||
"selectedIconPath": "assets/icons/home-active.png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"pagePath": "pages/detect/index",
|
|
||||||
"text": "发布",
|
"text": "发布",
|
||||||
"iconPath": "assets/icons/publish.png",
|
"iconPath": "assets/icons/publish.png",
|
||||||
"selectedIconPath": "assets/icons/publish-active.png"
|
"selectedIconPath": "assets/icons/publish-active.png"
|
||||||
|
|||||||
@@ -1,17 +1,29 @@
|
|||||||
const { request } = require('../../utils/request')
|
const { request } = require('../../utils/request')
|
||||||
|
|
||||||
const USER_MODULES = [
|
const QUICK_TEXTS = [
|
||||||
{ name: '批量识别', desc: '多条文本批量检测并给出风险汇总', tag: '批量筛查', path: '/pages/batch/index' }
|
'大家好,今晚 8 点社区线上读书会,欢迎参加。',
|
||||||
|
'恭喜中奖领取大额现金,点击链接立即到账。',
|
||||||
|
'本周活动报名已开放,请在群里接龙。',
|
||||||
|
'高薪兼职日结,扫码进群立刻赚钱。'
|
||||||
|
]
|
||||||
|
|
||||||
|
const VISIBILITY_OPTIONS = [
|
||||||
|
{ value: 'public', label: '公开信息发布' },
|
||||||
|
{ value: 'private', label: '私有信息发布' },
|
||||||
|
{ value: 'direct', label: '用户私信发布' }
|
||||||
]
|
]
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
loading: true,
|
loading: false,
|
||||||
user: null,
|
user: null,
|
||||||
modelInfo: null,
|
text: '',
|
||||||
threshold: null,
|
result: null,
|
||||||
thresholdText: '--',
|
quickTexts: QUICK_TEXTS,
|
||||||
userModules: USER_MODULES
|
visibilityOptions: VISIBILITY_OPTIONS,
|
||||||
|
visibilityIndex: 0,
|
||||||
|
visibility: 'public',
|
||||||
|
recipientUsername: ''
|
||||||
},
|
},
|
||||||
|
|
||||||
onShow() {
|
onShow() {
|
||||||
@@ -25,29 +37,110 @@ Page({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setData({ loading: true })
|
|
||||||
try {
|
try {
|
||||||
const [user, modelInfo] = await Promise.all([
|
const user = await request({ url: '/auth/me' })
|
||||||
request({ url: '/auth/me' }),
|
|
||||||
request({ url: '/spam/model/info' })
|
|
||||||
])
|
|
||||||
|
|
||||||
app.globalData.user = user
|
app.globalData.user = user
|
||||||
wx.setStorageSync('user', user)
|
wx.setStorageSync('user', user)
|
||||||
const threshold = modelInfo.threshold || null
|
this.setData({ user })
|
||||||
const thresholdText = threshold === null || threshold === undefined ? '--' : `${(Number(threshold) * 100).toFixed(1)}%`
|
} catch (e) {
|
||||||
this.setData({ user, modelInfo, threshold, thresholdText })
|
// ignore
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
formatPercent(value, digits = 2) {
|
||||||
|
const num = Number(value || 0)
|
||||||
|
return `${(num * 100).toFixed(digits)}%`
|
||||||
|
},
|
||||||
|
|
||||||
|
onInput(e) {
|
||||||
|
const field = e.currentTarget.dataset.field || 'text'
|
||||||
|
this.setData({ [field]: e.detail.value || '' })
|
||||||
|
},
|
||||||
|
|
||||||
|
fillQuick(e) {
|
||||||
|
this.setData({ text: e.currentTarget.dataset.text || '' })
|
||||||
|
},
|
||||||
|
|
||||||
|
onVisibilityChange(e) {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
const row = this.data.visibilityOptions[idx] || this.data.visibilityOptions[0]
|
||||||
|
this.setData({ visibilityIndex: idx, visibility: row.value })
|
||||||
|
},
|
||||||
|
|
||||||
|
async publish() {
|
||||||
|
if (this.data.loading) return
|
||||||
|
const text = (this.data.text || '').trim()
|
||||||
|
if (text.length < 2) {
|
||||||
|
wx.showToast({ title: '请输入至少 2 个字符', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const payload = {
|
||||||
|
text,
|
||||||
|
visibility: this.data.visibility
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.data.visibility === 'direct') {
|
||||||
|
const receiver = (this.data.recipientUsername || '').trim()
|
||||||
|
if (!receiver) {
|
||||||
|
wx.showToast({ title: '私信请填写接收人用户名', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
payload.recipient_username = receiver
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setData({ loading: true })
|
||||||
|
try {
|
||||||
|
const result = await request({
|
||||||
|
url: '/content/publish',
|
||||||
|
method: 'POST',
|
||||||
|
data: payload
|
||||||
|
})
|
||||||
|
|
||||||
|
this.setData({
|
||||||
|
result: {
|
||||||
|
...result,
|
||||||
|
detect: {
|
||||||
|
...(result.detect || {}),
|
||||||
|
confidence_text: this.formatPercent((result.detect || {}).confidence, 2)
|
||||||
|
},
|
||||||
|
post_threshold_text: this.formatPercent((result.post || {}).threshold, 1),
|
||||||
|
detect_spam_probability_text: this.formatPercent((result.detect || {}).spam_probability, 2)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
wx.showToast({
|
||||||
|
title: result.publish_allowed ? '发布成功' : '已拦截,可申诉',
|
||||||
|
icon: result.publish_allowed ? 'success' : 'none'
|
||||||
|
})
|
||||||
} finally {
|
} finally {
|
||||||
this.setData({ loading: false })
|
this.setData({ loading: false })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
goBatch() {
|
||||||
|
wx.navigateTo({ url: '/pages/batch/index' })
|
||||||
|
},
|
||||||
|
|
||||||
goto(e) {
|
goto(e) {
|
||||||
const path = e.currentTarget.dataset.path
|
const path = e.currentTarget.dataset.path
|
||||||
if (!path) return
|
if (!path) return
|
||||||
wx.navigateTo({ url: path })
|
wx.navigateTo({ url: path })
|
||||||
},
|
},
|
||||||
|
|
||||||
|
showTokenWeight(e) {
|
||||||
|
const token = e.currentTarget.dataset.token
|
||||||
|
const weight = e.currentTarget.dataset.weight
|
||||||
|
const weightNum = Number(weight || 0)
|
||||||
|
const direction = weightNum >= 0 ? '倾向垃圾判定' : '倾向正常判定'
|
||||||
|
wx.showModal({
|
||||||
|
title: '关键词权重',
|
||||||
|
content: `关键词"${token}"\n权重贡献:${weightNum >= 0 ? '+' : ''}${weightNum.toFixed(4)}\n(${direction})`,
|
||||||
|
showCancel: false,
|
||||||
|
confirmText: '关闭'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
logout() {
|
logout() {
|
||||||
getApp().clearAuth()
|
getApp().clearAuth()
|
||||||
wx.reLaunch({ url: '/pages/login/index' })
|
wx.reLaunch({ url: '/pages/login/index' })
|
||||||
|
|||||||
@@ -3,45 +3,79 @@
|
|||||||
<view class="hero-badge">CONTROL CENTER</view>
|
<view class="hero-badge">CONTROL CENTER</view>
|
||||||
<view class="hero-title">{{user ? ('欢迎,' + user.nickname) : '社区内容风控工作台'}}</view>
|
<view class="hero-title">{{user ? ('欢迎,' + user.nickname) : '社区内容风控工作台'}}</view>
|
||||||
<view class="hero-sub">发布内容将实时进入朴素贝叶斯识别流程,疑似垃圾信息自动拦截并支持申诉。</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>
|
||||||
|
|
||||||
<view class="card fade-up fade-up-delay-1" wx:if="{{modelInfo}}">
|
<view class="card fade-up fade-up-delay-1">
|
||||||
<view class="card-title">检测引擎状态</view>
|
<view class="card-title">发布信息</view>
|
||||||
<view class="grid-2">
|
|
||||||
<view class="kpi">
|
<view class="field">
|
||||||
<view class="kpi-label">模型版本</view>
|
<text class="field-label">内容文本</text>
|
||||||
<view class="kpi-value">{{modelInfo.version || '未训练'}}</view>
|
<textarea class="textarea" placeholder="请输入要发布的文本信息" value="{{text}}" data-field="text" bindinput="onInput" />
|
||||||
</view>
|
<view class="field-help">当前字数:{{text.length}},建议不少于 2 个字符。</view>
|
||||||
<view class="kpi">
|
</view>
|
||||||
<view class="kpi-label">训练样本</view>
|
|
||||||
<view class="kpi-value">{{modelInfo.sample_count || 0}}</view>
|
<view class="field">
|
||||||
</view>
|
<view class="row">
|
||||||
<view class="kpi">
|
<text class="field-label">发布类型</text>
|
||||||
<view class="kpi-label">垃圾阈值</view>
|
<picker mode="selector" range="{{visibilityOptions}}" range-key="label" value="{{visibilityIndex}}" bindchange="onVisibilityChange">
|
||||||
<view class="kpi-value">{{thresholdText}}</view>
|
<view class="picker-value">{{visibilityOptions[visibilityIndex].label}}</view>
|
||||||
</view>
|
</picker>
|
||||||
<view class="kpi">
|
|
||||||
<view class="kpi-label">最近训练</view>
|
|
||||||
<view class="kpi-value small">{{modelInfo.trained_at || '--'}}</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="card fade-up fade-up-delay-2">
|
<view class="field" wx:if="{{visibility === 'direct'}}">
|
||||||
<view class="card-title">更多功能</view>
|
<text class="field-label">接收人用户名</text>
|
||||||
<view class="card-desc">批量检测与管理功能入口。</view>
|
<input class="input" placeholder="私信发送时必填" value="{{recipientUsername}}" data-field="recipientUsername" bindinput="onInput" />
|
||||||
<view class="grid-2">
|
</view>
|
||||||
<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="field" wx:if="{{result}}">
|
||||||
<view class="module-desc">{{item.desc}}</view>
|
<text class="field-label">识别反馈</text>
|
||||||
<view class="module-tag">{{item.tag}}</view>
|
<view class="row">
|
||||||
|
<text class="label">发布结果</text>
|
||||||
|
<text class="{{result.publish_allowed ? 'status-ham' : 'status-spam'}}">{{result.publish_allowed ? '发布成功' : '已拦截,需申诉'}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="row" wx:if="{{result.detect.category_label}}">
|
||||||
|
<text class="label">分类标签</text>
|
||||||
|
<text class="status-spam">{{result.detect.category_label}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="row">
|
||||||
|
<text class="label">模型判断</text>
|
||||||
|
<text class="value">{{result.detect.prediction_text}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="row">
|
||||||
|
<text class="label">垃圾概率</text>
|
||||||
|
<text class="value">{{result.detect_spam_probability_text}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="progress-track">
|
||||||
|
<view class="progress-fill" style="width: {{result.detect_spam_probability_text}};"></view>
|
||||||
|
</view>
|
||||||
|
<view class="row">
|
||||||
|
<text class="label">检测置信度</text>
|
||||||
|
<text class="value">{{result.detect.confidence_text}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="progress-track">
|
||||||
|
<view class="progress-fill-safe" style="width: {{result.detect.confidence_text}};"></view>
|
||||||
|
</view>
|
||||||
|
<view class="row">
|
||||||
|
<text class="label">本次阈值</text>
|
||||||
|
<text class="value">{{result.post_threshold_text}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="field" wx:if="{{result.detect.reason_tokens && result.detect.reason_tokens.length}}">
|
||||||
|
<text class="field-label">风险关键词</text>
|
||||||
|
<view class="chip-group">
|
||||||
|
<text class="tag tag-danger" wx:for="{{result.detect.reason_tokens}}" wx:key="token" data-token="{{item.token}}" data-weight="{{item.weight}}" bindtap="showTokenWeight">{{item.token}}</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
|
||||||
|
|
||||||
|
<view class="field" wx:if="{{!result}}">
|
||||||
|
<text class="field-label">快捷示例</text>
|
||||||
|
<view class="chip-group">
|
||||||
|
<view class="chip" wx:for="{{quickTexts}}" wx:key="*this" data-text="{{item}}" bindtap="fillQuick">{{item}}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<button class="btn btn-primary" loading="{{loading}}" bindtap="publish">提交发布</button>
|
||||||
|
<button class="btn btn-ghost" style="margin-top: 12rpx;" bindtap="goBatch">批量识别</button>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
Reference in New Issue
Block a user