sync: 同步 monkey-ai@weiyuan(ddc5b9443) 的 web/ 到 ui-optimization
- 合入 weiyuan 新功能前端:分佣 V2 / 伙伴工作台、智能路由、企业资金与分析、官网设置与预约演示等, semi-ui 已全部迁移到 antd 6 / @/components/ui,不重新引入 Semi - 分佣二级菜单与页头去重、伙伴入口探测(企业伙伴走企业中心「企业分佣」)、超管侧栏入口恢复 - 适配层 DatePicker / TimePicker 统一 onChange(Date|Date[]|null, 文本) 契约;生产构建剔除调试日志 - 图片链接刷新:同任务请求复用、后台刷新不弹全局错误、离页停止批量请求 - 恢复 bun.lock(与 package-lock.json 共存);docs 规范与 CHANGELOG 更新 - 停止跟踪 .env.playwright.local(本地登录凭据,已加入 .gitignore)
This commit is contained in:
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Alert, Button, Empty, Table, Tag } from 'antd';
|
||||
import { listDecisions } from './api';
|
||||
import { gateText, jevReasonText, srcText } from './labels';
|
||||
|
||||
// 判定明细:只读 router_eval_records(§12.3)
|
||||
const DecisionTable = ({ mode, orgId }) => {
|
||||
const { t } = useTranslation();
|
||||
const [data, setData] = useState({ items: [], total: 0 });
|
||||
const [page, setPage] = useState(1);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState('');
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true);
|
||||
setError('');
|
||||
try {
|
||||
setData(
|
||||
(await listDecisions(mode, orgId, { p: page, page_size: 20 })) || {
|
||||
items: [],
|
||||
total: 0,
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
setError(e?.message || t('加载失败'));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [mode, orgId, page, t]);
|
||||
|
||||
useEffect(() => {
|
||||
load();
|
||||
}, [load]);
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: t('时间'),
|
||||
dataIndex: 'created_at',
|
||||
width: 180,
|
||||
render: (v) => (
|
||||
<span className='smart-router-num'>
|
||||
{new Date(v * 1000).toLocaleString()}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('虚拟模型'),
|
||||
dataIndex: 'virtual_model',
|
||||
width: 180,
|
||||
render: (v) => <span className='smart-router-mono'>{v}</span>,
|
||||
},
|
||||
{
|
||||
title: t('实际模型'),
|
||||
dataIndex: 'actual_model',
|
||||
width: 200,
|
||||
render: (v) => <span className='smart-router-mono'>{v || '-'}</span>,
|
||||
},
|
||||
{
|
||||
title: t('判定来源'),
|
||||
dataIndex: 'src',
|
||||
width: 200,
|
||||
render: (v, r) => (
|
||||
<Tag variant='filled' color={v === 'error' ? 'error' : 'blue'}>
|
||||
{srcText(t, v)}
|
||||
{r.reason ? ` · ${jevReasonText(t, r.reason)}` : ''}
|
||||
</Tag>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('任务 / 难度档'),
|
||||
key: 'task',
|
||||
width: 140,
|
||||
render: (_, r) => `${r.task || '-'} / ${r.difficulty_tier}`,
|
||||
},
|
||||
{
|
||||
title: t('合规闸门'),
|
||||
dataIndex: 'gate',
|
||||
width: 140,
|
||||
render: (v) => gateText(t, v),
|
||||
},
|
||||
{
|
||||
title: t('状态码'),
|
||||
dataIndex: 'status_code',
|
||||
width: 90,
|
||||
align: 'right',
|
||||
render: (v) => <span className='smart-router-num'>{v}</span>,
|
||||
},
|
||||
{
|
||||
title: t('判定耗时'),
|
||||
dataIndex: 'judge_ms',
|
||||
width: 110,
|
||||
align: 'right',
|
||||
render: (v) => (
|
||||
<span className='smart-router-num'>{v ? `${v} ms` : '-'}</span>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
if (error)
|
||||
return (
|
||||
<Alert
|
||||
type='error'
|
||||
showIcon
|
||||
title={error}
|
||||
action={
|
||||
<Button size='small' onClick={load}>
|
||||
{t('重试')}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<Table
|
||||
rowKey='id'
|
||||
size='middle'
|
||||
loading={loading}
|
||||
columns={columns}
|
||||
dataSource={data.items || []}
|
||||
scroll={{ x: 'max-content' }}
|
||||
locale={{
|
||||
emptyText: (
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description={t('还没有智能路由请求')}
|
||||
/>
|
||||
),
|
||||
}}
|
||||
pagination={{
|
||||
// 接口固定 page_size=20,不提供每页条数切换
|
||||
current: page,
|
||||
pageSize: 20,
|
||||
total: data.total || 0,
|
||||
size: 'small',
|
||||
showSizeChanger: false,
|
||||
showTotal: (total) => t('共 {{total}} 条', { total }),
|
||||
onChange: setPage,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default DecisionTable;
|
||||
Reference in New Issue
Block a user