diff --git a/src/constants/labels.ts b/src/constants/labels.ts index 39108fc..75b7ef3 100644 --- a/src/constants/labels.ts +++ b/src/constants/labels.ts @@ -51,3 +51,106 @@ export const parseStatusLabels: Record = { completed: '已解析', failed: '解析失败', }; + +// ── Review ── +export const reviewStatusLabels: Record = { + active: '活跃', + suspended: '暂停', + completed: '已完成', +}; +export const scheduleStateLabels: Record = { + learning: '学习中', + review: '复习中', + relearning: '重新学习', +}; +export const difficultyLabels: Record = { + easy: '简单', + medium: '中等', + hard: '困难', +}; + +// ── Import ── +export const importStatusLabels: Record = { + QUEUED: '排队中', + CLAIMED: '已认领', + DOWNLOADING: '下载中', + PARSING: '解析中', + OCR_PROCESSING: 'OCR 处理中', + CLEANING: '清洗中', + CHUNKING: '分段中', + EMBEDDING: '向量化中', + INDEXING: '索引中', + GENERATING_CANDIDATES: '生成候选中', + completed: '已完成', + failed: '失败', + FAILED_FINAL: '永久失败', +}; +export const importStepLabels: Record = { + completed: '已完成', + failed: '失败', + DOWNLOADING: '下载中', + PARSING: '解析中', + CLEANING: '清洗中', + CHUNKING: '分段中', +}; + +// ── Admin / User ── +export const adminStatusLabels: Record = { + ACTIVE: '正常', + DISABLED: '已禁用', + LOCKED: '已锁定', +}; +export const userStatusLabels: Record = { + active: '正常', + disabled: '已禁用', + deleted: '已注销', +}; + +// ── Knowledge ── +export const kbStatusLabels: Record = { active: '正常' }; +export const candidateStatusLabels: Record = { + PENDING: '待审核', + ACCEPTED: '已通过', + REJECTED: '已拒绝', +}; + +// ── Hermes / Agent ── +export const agentTaskStatusLabels: Record = { + pending: '待处理', + approved: '已批准', + rejected: '已拒绝', +}; +export const artifactStatusLabels: Record = { + draft: '草稿', + published: '已发布', +}; + +// ── Release ── +export const releaseStatusLabels: Record = { + proposed: '提案中', + accepted: '已通过', +}; + +// ── Backup ── +export const backupStatusLabels: Record = { + RUNNING: '运行中', + COMPLETED: '已完成', + FAILED: '失败', +}; + +// ── Secret ── +export const secretStatusLabels: Record = { + active: '活跃', + expired: '已过期', + rotated: '已轮换', + revoked: '已撤销', +}; + +// ── Compliance ── +export const complianceStatusLabels: Record = { + pending: '待处理', + approved: '已批准', + rejected: '已拒绝', + open: '待处理', + resolved: '已解决', +}; diff --git a/src/pages/BackupAdmin.tsx b/src/pages/BackupAdmin.tsx index 75f8f8c..8c1cefa 100644 --- a/src/pages/BackupAdmin.tsx +++ b/src/pages/BackupAdmin.tsx @@ -3,6 +3,7 @@ import { Table, Button, Tag, Space, Typography, Tabs, message } from 'antd' import { CloudUploadOutlined, DeleteOutlined } from '@ant-design/icons' import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query' import { api } from '@/services/http-client' +import { backupStatusLabels } from '@/constants/labels' const { Title } = Typography @@ -37,7 +38,7 @@ export default function BackupAdmin() { const backupColumns = [ { title: 'ID', dataIndex: 'id', width: 100, ellipsis: true }, { title: '类型', dataIndex: 'type', width: 80 }, - { title: '状态', dataIndex: 'status', width: 80, render: (s: string) => {s} }, + { title: '状态', dataIndex: 'status', width: 80, render: (s: string) => {backupStatusLabels[s] || s} }, { title: '本地路径', dataIndex: 'localPath', width: 200, ellipsis: true, render: (p: string | null) => p || '-' }, { title: 'COS Key', dataIndex: 'cosObjectKey', width: 180, ellipsis: true, render: (k: string | null) => k || '-' }, { title: '大小', dataIndex: 'fileSizeBytes', width: 80, render: (s: number) => s ? `${(Number(s) / 1048576).toFixed(1)} MB` : '-' }, @@ -48,7 +49,7 @@ export default function BackupAdmin() { const cleanupColumns = [ { title: 'ID', dataIndex: 'id', width: 100, ellipsis: true }, { title: '类型', dataIndex: 'type', width: 100 }, - { title: '状态', dataIndex: 'status', width: 80, render: (s: string) => {s} }, + { title: '状态', dataIndex: 'status', width: 80, render: (s: string) => {backupStatusLabels[s] || s} }, { title: '目标', dataIndex: 'target', width: 120, ellipsis: true, render: (t: string | null) => t || '-' }, { title: '影响行数', dataIndex: 'rowsAffected', width: 80 }, { title: '开始时间', dataIndex: 'startedAt', width: 120, render: (d: string) => new Date(d).toLocaleString() }, diff --git a/src/pages/HermesSettings.tsx b/src/pages/HermesSettings.tsx index ec8a923..6e0a2e0 100644 --- a/src/pages/HermesSettings.tsx +++ b/src/pages/HermesSettings.tsx @@ -2,6 +2,7 @@ import { Tabs, Table, Tag, Button, Space, Typography } from 'antd' import { CheckOutlined, CloseOutlined, RobotOutlined } from '@ant-design/icons' import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query' import { api } from '@/services/http-client' +import { agentTaskStatusLabels, artifactStatusLabels } from '@/constants/labels' import { message } from 'antd' const { Title } = Typography @@ -37,7 +38,7 @@ export default function HermesSettings() { { title: '类型', dataIndex: 'type', width: 90 }, { title: '输入', dataIndex: 'input', width: 180, ellipsis: true, render: (i: string) => i ? i.slice(0, 100) : '-' }, { title: '输出', dataIndex: 'output', width: 200, ellipsis: true, render: (o: string) => o ? o.slice(0, 120) : '-' }, - { title: '状态', dataIndex: 'status', width: 70, render: (s: string) => {s} }, + { title: '状态', dataIndex: 'status', width: 70, render: (s: string) => {agentTaskStatusLabels[s] || s} }, { title: '创建时间', dataIndex: 'createdAt', width: 110, render: (d: string) => new Date(d).toLocaleString() }, { title: '操作', width: 120, @@ -55,7 +56,7 @@ export default function HermesSettings() { { title: '类型', dataIndex: 'type', width: 100, render: (t: string) => artifactTypeLabels[t] || t }, { title: '标题', dataIndex: 'title', width: 200, ellipsis: true }, { title: '内容', dataIndex: 'content', width: 250, ellipsis: true, render: (c: string) => c ? c.slice(0, 150) : '-' }, - { title: '状态', dataIndex: 'status', width: 70, render: (s: string) => {s} }, + { title: '状态', dataIndex: 'status', width: 70, render: (s: string) => {artifactStatusLabels[s] || s} }, { title: '创建时间', dataIndex: 'createdAt', width: 110, render: (d: string) => new Date(d).toLocaleString() }, ] diff --git a/src/pages/KnowledgeBases.tsx b/src/pages/KnowledgeBases.tsx index 028bbc3..b74b27e 100644 --- a/src/pages/KnowledgeBases.tsx +++ b/src/pages/KnowledgeBases.tsx @@ -3,6 +3,7 @@ import { useQuery, useQueryClient } from '@tanstack/react-query' import { Table, Tag, Typography, Button, App, Drawer, Space, Descriptions } from 'antd' import { ReloadOutlined, DeleteOutlined, EyeOutlined, FileTextOutlined, LinkOutlined } from '@ant-design/icons' import { api } from '@/services/http-client' +import { kbStatusLabels } from '@/constants/labels' import dayjs from 'dayjs' const { Title, Text } = Typography @@ -71,7 +72,7 @@ function KBPage() { { title: '名称', dataIndex: 'title', width: 200, ellipsis: true }, { title: '用户', width: 120, render: (_: any, r: any) => r.user?.nickname || r.user?.email || '-' }, { title: '知识点', dataIndex: 'itemCount', width: 80, align: 'center' }, - { title: '状态', dataIndex: 'status', width: 80, render: (s: string) => {s} }, + { title: '状态', dataIndex: 'status', width: 80, render: (s: string) => {kbStatusLabels[s] || s} }, { title: '创建时间', dataIndex: 'createdAt', width: 170, render: (d: string) => dayjs(d).format('YYYY-MM-DD HH:mm') }, { title: '操作', width: 120, align: 'center', diff --git a/src/pages/KnowledgeOps.tsx b/src/pages/KnowledgeOps.tsx index 5e8c5d2..0a10073 100644 --- a/src/pages/KnowledgeOps.tsx +++ b/src/pages/KnowledgeOps.tsx @@ -3,6 +3,7 @@ import { useQuery, useQueryClient } from '@tanstack/react-query' import { Table, Tag, Typography, Button, App, Tabs, Input, Card, Space } from 'antd' import { ReloadOutlined, SearchOutlined, ExperimentOutlined } from '@ant-design/icons' import { api } from '@/services/http-client' +import { candidateStatusLabels } from '@/constants/labels' import dayjs from 'dayjs' const { Title, Text } = Typography @@ -32,8 +33,8 @@ export default function KnowledgeOpsPage() { const candidateCols = [ { title: '标题', dataIndex: 'title', width: 200, ellipsis: true }, - { title: '用户', dataIndex: 'userId', width: 120, ellipsis: true }, - { title: '状态', dataIndex: 'status', width: 80, render: (s: string) => {s} }, + { title: '用户', dataIndex: 'userId', width: 120, ellipsis: true, render: (_: any, r: any) => r.userName || r.userId }, + { title: '状态', dataIndex: 'status', width: 80, render: (s: string) => {candidateStatusLabels[s] || s} }, { title: '置信度', dataIndex: 'confidence', width: 80, align: 'center' as const, render: (v: any) => v ? `${(Number(v)*100).toFixed(0)}%` : '-' }, { title: '难度', dataIndex: 'difficulty', width: 70 }, { title: '时间', dataIndex: 'createdAt', width: 130, render: (d: string) => dayjs(d).format('MM-DD HH:mm') }, diff --git a/src/pages/ReleaseAdmin.tsx b/src/pages/ReleaseAdmin.tsx index 1cc1fa6..1310554 100644 --- a/src/pages/ReleaseAdmin.tsx +++ b/src/pages/ReleaseAdmin.tsx @@ -3,6 +3,7 @@ import { Table, Button, Modal, Form, Input, Checkbox, Tag, Space, Typography, Ta import { PlusOutlined, EditOutlined, DeleteOutlined, RocketOutlined } from '@ant-design/icons' import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query' import { api } from '@/services/http-client' +import { releaseStatusLabels } from '@/constants/labels' import { message } from 'antd' const { Title } = Typography @@ -83,7 +84,7 @@ export default function ReleaseAdmin() { { title: '标题', dataIndex: 'title', width: 200, ellipsis: true }, { title: '上下文', dataIndex: 'context', width: 200, ellipsis: true, render: (c: string) => c?.slice(0, 100) || '-' }, { title: '决策', dataIndex: 'decision', width: 250, ellipsis: true, render: (d: string) => d?.slice(0, 150) || '-' }, - { title: '状态', dataIndex: 'status', width: 80, render: (s: string) => {s} }, + { title: '状态', dataIndex: 'status', width: 80, render: (s: string) => {releaseStatusLabels[s] || s} }, { title: '操作', width: 100, render: (_: any, r: any) => ( diff --git a/src/pages/ReviewAdmin.tsx b/src/pages/ReviewAdmin.tsx index 4ed5e6a..b688713 100644 --- a/src/pages/ReviewAdmin.tsx +++ b/src/pages/ReviewAdmin.tsx @@ -4,6 +4,7 @@ import { SearchOutlined } from '@ant-design/icons' import { useQuery } from '@tanstack/react-query' import { api } from '@/services/http-client' import type { ReviewCardItem, PaginatedResult } from '@/types/api' +import { reviewStatusLabels, scheduleStateLabels, difficultyLabels } from '@/constants/labels' const { Title } = Typography @@ -29,16 +30,16 @@ export default function ReviewAdmin() { const columns = [ { title: 'ID', dataIndex: 'id', width: 100, ellipsis: true }, - { title: '用户', dataIndex: 'userId', width: 100, ellipsis: true }, + { title: '用户', dataIndex: 'userId', width: 100, ellipsis: true, render: (_: any, r: any) => r.userName || r.userId }, { title: '正面', dataIndex: 'frontText', width: 200, ellipsis: true }, - { title: '难度', dataIndex: 'difficulty', width: 80 }, + { title: '难度', dataIndex: 'difficulty', width: 80, render: (v: string) => difficultyLabels[v] || v || '-' }, { title: '状态', dataIndex: 'status', width: 80, - render: (s: string) => {s}, + render: (s: string) => {reviewStatusLabels[s] || s}, }, { title: '调度', dataIndex: 'scheduleState', width: 80, - render: (s: string) => s || '-', + render: (s: string) => scheduleStateLabels[s] || s || '-', }, { title: '间隔(天)', dataIndex: 'intervalDays', width: 80 }, { title: '复习次数', dataIndex: 'repetitionCount', width: 80 }, @@ -69,9 +70,7 @@ export default function ReviewAdmin() { style={{ width: 130 }} options={[ { label: '全部', value: '' }, - { label: 'Active', value: 'active' }, - { label: 'Suspended', value: 'suspended' }, - { label: 'Completed', value: 'completed' }, + ...Object.entries(reviewStatusLabels).map(([v, l]) => ({ label: l, value: v })), ]} /> diff --git a/src/pages/Secrets.tsx b/src/pages/Secrets.tsx index 769209b..1f5d1ed 100644 --- a/src/pages/Secrets.tsx +++ b/src/pages/Secrets.tsx @@ -3,6 +3,7 @@ import { useState } from 'react' import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query' import { Table, Button, Typography, App, Modal, Input, Select, Tag, Tabs, DatePicker, InputNumber, message } from 'antd' import { api } from '@/services/http-client' +import { secretStatusLabels } from '@/constants/labels' import dayjs from 'dayjs' const { Title, Text } = Typography @@ -55,7 +56,7 @@ function SecretsPage() { { title: '名称', dataIndex: 'name', width: 120 }, { title: '服务商', dataIndex: 'provider', width: 90, render: (v: string) => {v} }, { title: '末四位', dataIndex: 'maskLast4', width: 80, render: (v: string) => ****{v} }, - { title: '状态', dataIndex: 'status', width: 70, render: (v: string) => {v} }, + { title: '状态', dataIndex: 'status', width: 70, render: (v: string) => {secretStatusLabels[v] || v} }, { title: '到期', dataIndex: 'expiresAt', width: 100, render: (d: string) => d ? dayjs(d).format('MM-DD') : 永久 }, { title: '操作', width: 150, render: (_:any, r:any) => ( <>