import { formatUserReference } from '../../helpers/safeDisplay'; import { Trans } from 'react-i18next'; import React, { useState } from 'react'; import { Table, Tag, Button, Modal, Input, Typography, Space, Select, } from '@/components/ui'; import { IconRefresh } from '@/components/ui/icons'; import { renderQuota } from '../../helpers'; const { Text } = Typography; const formatTime = (ts) => { if (!ts) return '-'; const d = new Date(ts * 1000); const pad = (n) => (n < 10 ? '0' + n : '' + n); return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`; }; /** * 自动封号历史 / 解封操作中心 * * 职责: * - 持久查看所有由风控自动封号产生的记录(即使用户已经从疑似列表中消失) * - 解封操作的主入口(疑似列表里的解封按钮只能覆盖"封号后还有活动"的边界场景) */ const RiskControlBanLogs = ({ loading, banLogs, banLogTotal, banLogStatus, setBanLogStatus, banLogPage, banLogPageSize, fetchBanLogs, unbanUser, t, }) => { const [unbanModalVisible, setUnbanModalVisible] = useState(false); const [unbanRow, setUnbanRow] = useState(null); const [unbanReason, setUnbanReason] = useState(''); const columns = [ { title: t('封号时间'), dataIndex: 'ban_at', width: 150, render: (v) => formatTime(v), }, { title: t('用户ID'), dataIndex: 'user_id', width: 100, }, { title: t('用户名(快照)'), dataIndex: 'user_snapshot', width: 140, render: (v) => v || -, }, { title: t('请求次数'), dataIndex: 'request_count', width: 100, render: (v) => (v || 0).toLocaleString(), }, { title: t('总消耗'), dataIndex: 'total_quota', width: 110, render: (v) => renderQuota(v || 0, 4), }, { title: t('平均消耗'), dataIndex: 'avg_quota_x1000', width: 120, render: (v) => renderQuota((v || 0) / 1000, 6), }, { title: t('最常用模型'), dataIndex: 'top_model', width: 150, render: (v) => v ? {v} : -, }, { title: t('活跃 IP'), dataIndex: 'last_ip', width: 130, render: (v) => v || -, }, { title: t('状态'), dataIndex: 'status', width: 100, render: (v) => v === 1 ? ( {t('已封号')} ) : ( {t('已解封')} ), }, { title: t('解封时间'), dataIndex: 'unban_at', width: 150, render: (v) => (v > 0 ? formatTime(v) : -), }, { title: t('解封原因'), dataIndex: 'unban_reason', width: 180, render: (v) => v || -, }, { title: t('操作'), width: 110, fixed: 'right', render: (_v, row) => { if (row.status === 1) { return ( ); } return ( - ); }, }, ]; const statusOptions = [ { value: 0, label: t('全部') }, { value: 1, label: t('已封号') }, { value: 2, label: t('已解封') }, ]; return (