fix: ImportMonitor labels + Progress kbName
All checks were successful
Deploy Admin Frontend / build-and-deploy (push) Successful in 12s

This commit is contained in:
wangdl 2026-06-19 13:13:54 +08:00
parent 5dd35a1c9f
commit e07f09002d
2 changed files with 6 additions and 11 deletions

View File

@ -3,6 +3,7 @@ import { useQuery, useQueryClient } from '@tanstack/react-query'
import { Table, Tag, Typography, Button, App, Drawer, Space } from 'antd' import { Table, Tag, Typography, Button, App, Drawer, Space } from 'antd'
import { ReloadOutlined, RetweetOutlined, ImportOutlined, EyeOutlined } from '@ant-design/icons' import { ReloadOutlined, RetweetOutlined, ImportOutlined, EyeOutlined } from '@ant-design/icons'
import { api } from '@/services/http-client' import { api } from '@/services/http-client'
import { importStatusLabels, importStepLabels } from '@/constants/labels'
import dayjs from 'dayjs' import dayjs from 'dayjs'
const { Title, Text } = Typography const { Title, Text } = Typography
@ -31,20 +32,14 @@ export default function ImportMonitorPage() {
qc.invalidateQueries({ queryKey: ['admin-imports'] }) qc.invalidateQueries({ queryKey: ['admin-imports'] })
} }
const statusLabel: Record<string, string> = {
QUEUED: '排队中', PROCESSING: '处理中', COMPLETED: '已完成', FAILED: '失败', CANCELLED: '已取消',
}
const statusColor: Record<string, string> = { const statusColor: Record<string, string> = {
QUEUED: 'blue', PROCESSING: 'processing', COMPLETED: 'green', FAILED: 'red', CANCELLED: 'default', QUEUED: 'blue', processing: 'processing', completed: 'green', failed: 'red',
}
const stepLabel: Record<string, string> = {
pending: '待处理', running: '执行中', completed: '已完成', failed: '失败', skipped: '已跳过',
} }
const columns = [ const columns = [
{ title: '名称', dataIndex: 'sourceName', width: 180, ellipsis: true }, { title: '名称', dataIndex: 'sourceName', width: 180, ellipsis: true },
{ title: '类型', dataIndex: 'sourceType', width: 80, render: (s: string) => (s === 'file' ? '文件' : s === 'url' ? '链接' : s === 'text' ? '文本' : s) }, { title: '类型', dataIndex: 'sourceType', width: 80, render: (s: string) => (s === 'file' ? '文件' : s === 'url' ? '链接' : s === 'text' ? '文本' : s) },
{ title: '状态', dataIndex: 'status', width: 90, render: (s: string) => <Tag color={statusColor[s] || 'default'}>{statusLabel[s] || s}</Tag> }, { title: '状态', dataIndex: 'status', width: 90, render: (s: string) => <Tag color={statusColor[s] || 'default'}>{importStatusLabels[s] || s}</Tag> },
{ title: '进度', dataIndex: 'progress', width: 70, render: (v: number) => `${v || 0}%` }, { title: '进度', dataIndex: 'progress', width: 70, render: (v: number) => `${v || 0}%` },
{ title: '重试', dataIndex: 'retryCount', width: 60, align: 'center' as const }, { title: '重试', dataIndex: 'retryCount', width: 60, align: 'center' as const },
{ title: '步骤', dataIndex: 'step', width: 100, ellipsis: true }, { title: '步骤', dataIndex: 'step', width: 100, ellipsis: true },
@ -63,7 +58,7 @@ export default function ImportMonitorPage() {
const stepCols = [ const stepCols = [
{ title: '步骤', dataIndex: 'step', width: 120 }, { title: '步骤', dataIndex: 'step', width: 120 },
{ title: '状态', dataIndex: 'status', width: 80, render: (s: string) => <Tag color={s === 'completed' ? 'green' : s === 'failed' ? 'red' : 'blue'}>{stepLabel[s] || s}</Tag> }, { title: '状态', dataIndex: 'status', width: 80, render: (s: string) => <Tag color={s === 'completed' ? 'green' : s === 'failed' ? 'red' : 'blue'}>{importStepLabels[s] || s}</Tag> },
{ title: '详情', dataIndex: 'detail', ellipsis: true }, { title: '详情', dataIndex: 'detail', ellipsis: true },
{ title: '开始', dataIndex: 'startedAt', width: 130, render: (d: string) => d ? dayjs(d).format('HH:mm:ss') : '-' }, { title: '开始', dataIndex: 'startedAt', width: 130, render: (d: string) => d ? dayjs(d).format('HH:mm:ss') : '-' },
{ title: '完成', dataIndex: 'completedAt', width: 130, render: (d: string) => d ? dayjs(d).format('HH:mm:ss') : '-' }, { title: '完成', dataIndex: 'completedAt', width: 130, render: (d: string) => d ? dayjs(d).format('HH:mm:ss') : '-' },
@ -81,7 +76,7 @@ export default function ImportMonitorPage() {
{detail && ( {detail && (
<> <>
<Title level={5} style={{ fontSize: 14 }}>Job: {detail.job?.id}</Title> <Title level={5} style={{ fontSize: 14 }}>Job: {detail.job?.id}</Title>
<Text>: <Tag color={statusColor[detail.job?.status]}>{statusLabel[detail.job?.status] || detail.job?.status}</Tag></Text> <Text>: <Tag color={statusColor[detail.job?.status]}>{importStatusLabels[detail.job?.status] || detail.job?.status}</Tag></Text>
<Text style={{ marginLeft: 16 }}>: {detail.job?.progress || 0}%</Text> <Text style={{ marginLeft: 16 }}>: {detail.job?.progress || 0}%</Text>
<Text style={{ marginLeft: 16 }}>: {detail.job?.retryCount}/{detail.job?.maxRetries}</Text> <Text style={{ marginLeft: 16 }}>: {detail.job?.retryCount}/{detail.job?.maxRetries}</Text>
{detail.job?.errorMessage && <div style={{ marginTop: 8 }}><Text type="danger">{detail.job?.errorMessage}</Text></div>} {detail.job?.errorMessage && <div style={{ marginTop: 8 }}><Text type="danger">{detail.job?.errorMessage}</Text></div>}

View File

@ -195,7 +195,7 @@ export function ProgressPage() {
{ title: '用户', dataIndex: 'userId', key: 'userId', render: (_: any, r: any) => r.userName || r.userId, width: 90, ellipsis: true }, { title: '用户', dataIndex: 'userId', key: 'userId', render: (_: any, r: any) => r.userName || r.userId, width: 90, ellipsis: true },
{ title: '资料', dataIndex: 'materialId', key: 'materialId', render: (_: any, r: any) => r.materialName || r.materialId, width: 110, ellipsis: true }, { title: '资料', dataIndex: 'materialId', key: 'materialId', render: (_: any, r: any) => r.materialName || r.materialId, width: 110, ellipsis: true },
{ title: '目标类型', dataIndex: 'readingTargetType', key: 'targetType', width: 85, render: (v?: string) => v ? <Tag>{targetTypeLabels[v] || v}</Tag> : '-' }, { title: '目标类型', dataIndex: 'readingTargetType', key: 'targetType', width: 85, render: (v?: string) => v ? <Tag>{targetTypeLabels[v] || v}</Tag> : '-' },
{ title: '知识库', dataIndex: 'knowledgeBaseId', key: 'kbId', width: 75, ellipsis: true, render: (v?: string) => v?.slice(0,8) || '-' }, { title: '知识库', dataIndex: 'knowledgeBaseId', key: 'kbId', width: 75, ellipsis: true, render: (_: any, r: any) => r.kbName || r.knowledgeBaseId },
{ title: 'Session', dataIndex: 'lastClientSessionId', key: 'sessionId', width: 120, ellipsis: true, render: (v?: string) => v?.slice(0,16) || '-' }, { title: 'Session', dataIndex: 'lastClientSessionId', key: 'sessionId', width: 120, ellipsis: true, render: (v?: string) => v?.slice(0,16) || '-' },
{ title: '状态', dataIndex: 'status', key: 'status', width: 85, render: (s: string) => <Tag color={s === 'reading' ? 'blue' : s === 'completed' ? 'green' : 'orange'}>{progressStatusLabels[s] || s}</Tag> }, { title: '状态', dataIndex: 'status', key: 'status', width: 85, render: (s: string) => <Tag color={s === 'reading' ? 'blue' : s === 'completed' ? 'green' : 'orange'}>{progressStatusLabels[s] || s}</Tag> },
{ title: '进度', dataIndex: 'lastProgress', key: 'progress', width: 65, render: (v: number) => v != null ? `${Math.round(v * 100)}%` : '-' }, { title: '进度', dataIndex: 'lastProgress', key: 'progress', width: 65, render: (v: number) => v != null ? `${Math.round(v * 100)}%` : '-' },