diff --git a/src/pages/ContentSafety.tsx b/src/pages/ContentSafety.tsx index af336d9..b768874 100644 --- a/src/pages/ContentSafety.tsx +++ b/src/pages/ContentSafety.tsx @@ -17,6 +17,8 @@ function CSPage() { const { data: words } = useQuery({ queryKey: ['safety', 'words'], queryFn: (): Promise => api.get('/admin-api/content-safety/words') }) const { data: checks } = useQuery({ queryKey: ['safety', 'checks'], queryFn: (): Promise => api.get('/admin-api/content-safety/checks') }) + const { data: reports } = useQuery({ queryKey: ['safety', 'reports'], queryFn: (): Promise => api.get('/admin-api/content-safety/reports') }) + const { data: violations } = useQuery({ queryKey: ['safety', 'violations'], queryFn: (): Promise => api.get('/admin-api/content-safety/violations') }) const addWord = async () => { await api.post('/admin-api/content-safety/words', { word: newWord, category, riskLevel: risk }) @@ -29,6 +31,24 @@ function CSPage() { onOk: async () => { await api.delete(`/admin-api/content-safety/words/${id}`); qc.invalidateQueries({ queryKey: ['safety'] }) }, }) + const handleReport = (id: string, action: string) => modal.confirm({ + title: action === 'confirmed' ? '确认违规' : '驳回举报', + content: action === 'confirmed' ? '确认后将创建违规记录' : '驳回后将关闭此举报', + onOk: async () => { + await api.post(`/admin-api/content-safety/reports/${id}/handle`, { action, note: `Admin ${action}` }) + message.success('已处理'); qc.invalidateQueries({ queryKey: ['safety'] }) + }, + }) + + const applyPenalty = (id: string, penalty: string) => modal.confirm({ + title: '应用处罚', + content: `确认对违规记录应用「${penalty}」处罚?`, + onOk: async () => { + await api.post(`/admin-api/content-safety/violations/${id}/penalty`, { penalty }) + message.success('处罚已应用'); qc.invalidateQueries({ queryKey: ['safety'] }) + }, + }) + const wordCols = [ { title: '词汇', dataIndex: 'word', width: 150 }, { title: '分类', dataIndex: 'category', width: 100 }, @@ -46,6 +66,35 @@ function CSPage() { { title: '结果', dataIndex: 'result', width: 80, render: (v: string) => {v} }, ] + const reportCols = [ + { title: '时间', dataIndex: 'createdAt', width: 130, render: (d: string) => dayjs(d).format('MM-DD HH:mm') }, + { title: '类型', dataIndex: 'targetType', width: 110 }, + { title: '目标ID', dataIndex: 'targetId', width: 120, ellipsis: true }, + { title: '原因', dataIndex: 'reason', ellipsis: true }, + { title: '状态', dataIndex: 'status', width: 80, render: (v: string) => v === 'pending' ? 待处理 : v === 'confirmed' ? 已确认 : 已驳回 }, + { title: '操作', width: 160, render: (_: any, r: any) => r.status === 'pending' ? ( + + + + + ) : - }, + ] + + const violationCols = [ + { title: '时间', dataIndex: 'createdAt', width: 130, render: (d: string) => dayjs(d).format('MM-DD HH:mm') }, + { title: '用户', dataIndex: 'userId', width: 140, ellipsis: true }, + { title: '类型', dataIndex: 'contentType', width: 100 }, + { title: '内容', dataIndex: 'content', ellipsis: true, render: (v: string) => {v?.slice(0, 60)} }, + { title: '风险', dataIndex: 'riskLevel', width: 70, render: (v: string) => {v} }, + { title: '处罚', dataIndex: 'penalty', width: 80, render: (v: string) => v === 'none' ? : {v} }, + { title: '操作', width: 120, render: (_: any, r: any) => r.penalty === 'none' ? ( + + + + + ) : {r.penalty} }, + ] + return (
@@ -59,6 +108,8 @@ function CSPage() { }, { key: 'checks', label: '审核记录', children: }, + { key: 'reports', label: '举报管理', children:
}, + { key: 'violations', label: '违规记录', children:
}, ]} /> setAddOpen(false)} okText="添加">