From c8ce273c30a0d0e6794c1e378648e988ffb6aae4 Mon Sep 17 00:00:00 2001 From: zhaoxing <2558691827@qq.com> Date: Mon, 16 Nov 2026 17:53:33 +0800 Subject: [PATCH] =?UTF-8?q?style(semi-auto):=20=E4=BC=98=E5=8C=96=E5=B1=A5?= =?UTF-8?q?=E7=BA=A6=E5=8E=86=E5=8F=B2=E6=97=B6=E9=97=B4=E7=BA=BF=E4=B8=8E?= =?UTF-8?q?=E6=8A=A5=E6=96=87=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 顶部汇总当前状态;节点按操作结果命名并加来源/异常筛选;状态变化改为标签对比,原始详情折叠;报文改为请求/响应两栏并统一字段名称。 --- .../admin/SemiAutoTaskHistoryDrawer.tsx | 454 +++++++++++++++--- 1 file changed, 390 insertions(+), 64 deletions(-) diff --git a/apps/frontend/src/components/admin/SemiAutoTaskHistoryDrawer.tsx b/apps/frontend/src/components/admin/SemiAutoTaskHistoryDrawer.tsx index 10837271..2d63244f 100644 --- a/apps/frontend/src/components/admin/SemiAutoTaskHistoryDrawer.tsx +++ b/apps/frontend/src/components/admin/SemiAutoTaskHistoryDrawer.tsx @@ -1,12 +1,17 @@ -import { CopyOutlined, ReloadOutlined } from '@ant-design/icons' +import { ArrowRightOutlined, CopyOutlined, ReloadOutlined } from '@ant-design/icons' import { App, Button, + Card, + Checkbox, + Col, Collapse, + Descriptions, Drawer, Empty, Input, Pagination, + Row, Select, Space, Tabs, @@ -26,20 +31,39 @@ import { useIsMobile } from '@/utils/use-is-mobile' const { Text } = Typography -const EVENT_LABELS: Record = { - task_created: '任务创建', - customer_link_opened: '客户打开链接', - customer_profile_saved: '客户保存角色资料', - login_started: '开始平台登录', - login_status_changed: '登录状态变更', - binding_status_changed: '绑定状态变更', - task_claimed: '客服领取', - customer_reauth_requested: '重新发起客户授权', - browser_session_opened: '生成浏览器注入票据', - credential_session_restored: '凭证恢复登录', - credential_invalidated: '凭证失效', - task_completed: '订单完成', - task_cancelled: '订单取消', +/** 非状态类事件:名称直接写清楚「谁做了什么」。 */ +const EVENT_TITLES: Record = { + task_created: '创建履约任务', + customer_link_opened: '客户打开授权页', + customer_profile_saved: '客户提交游戏角色', + login_started: '客户开始登录', + task_claimed: '客服领取任务', + customer_reauth_requested: '客服重新发起授权', + browser_session_opened: '客服生成浏览器登录票据', + credential_session_restored: '使用已保存 CK 恢复登录', + credential_invalidated: '平台 CK 已失效', + task_completed: '客服完成履约', + task_cancelled: '任务已取消', +} + +/** 状态变更事件:按「变更后的状态」命名,读起来就是一句操作结果。 */ +const LOGIN_EVENT_TITLES: Record = { + waiting_code: '等待客户输入验证码', + qr_pending: '生成登录二维码', + scanned: '客户已扫码,等待确认', + authenticated: '客户完成平台登录', + failed: '平台登录失败', + expired: '登录二维码已过期', +} + +const BINDING_EVENT_TITLES: Record = { + not_started: '绑定状态重置', + qr_pending: '生成绑定二维码', + scanned: '客户已扫码绑定', + role_ready: '平台识别到游戏角色', + confirmed: '客户确认绑定角色', + failed: '角色绑定失败', + expired: '绑定二维码已过期', } const CHANNEL_LABELS: Record = { @@ -50,11 +74,38 @@ const CHANNEL_LABELS: Record = { external_connector: '外部 Connector', } +const CHANNEL_COLORS: Record = { + customer_api: 'blue', + admin_api: 'cyan', + huya_wup: 'purple', + huya_http: 'geekblue', + external_connector: 'gold', +} + const CHANNEL_OPTIONS = Object.keys(CHANNEL_LABELS).map((value) => ({ value, label: CHANNEL_LABELS[value], })) +const ACTOR_LABELS: Record = { + system: '系统', + customer: '客户', + admin: '客服', + connector: '平台连接器', +} + +const ACTOR_COLORS: Record = { + system: 'default', + customer: 'blue', + admin: 'cyan', + connector: 'purple', +} + +const ACTOR_OPTIONS = Object.keys(ACTOR_LABELS).map((value) => ({ + value, + label: ACTOR_LABELS[value], +})) + const LOGIN_STATUS_LABELS: Record = { waiting_login: '等待登录', qr_pending: '待扫码', @@ -83,6 +134,16 @@ const EXECUTION_STATUS_LABELS: Record = { cancelled: '已取消', } +/** antd 6 的 Timeline 预设色会被主题色覆盖,这里用固定色值保证语义色稳定。 */ +const TIMELINE_COLORS = { + gray: '#8c8c8c', + green: '#52c41a', + blue: '#1677ff', + gold: '#faad14', + cyan: '#13c2c2', + red: '#ff4d4f', +} + type SemiAutoTaskHistoryDrawerProps = { open: boolean taskId: number | null @@ -98,6 +159,8 @@ export default function SemiAutoTaskHistoryDrawer({ const isMobile = useIsMobile() const { token } = theme.useToken() const [tab, setTab] = useState('events') + const [eventActor, setEventActor] = useState('') + const [onlyError, setOnlyError] = useState(false) const [channel, setChannel] = useState('') const [status, setStatus] = useState('') const [keywordDraft, setKeywordDraft] = useState('') @@ -109,6 +172,8 @@ export default function SemiAutoTaskHistoryDrawer({ useEffect(() => { if (!open) return setTab('events') + setEventActor('') + setOnlyError(false) setChannel('') setStatus('') setKeywordDraft('') @@ -141,6 +206,11 @@ export default function SemiAutoTaskHistoryDrawer({ const events = history?.events || [] const traces = history?.traces const traceItems = traces?.items || [] + const visibleEvents = events.filter((event) => { + if (eventActor && event.actorType !== eventActor) return false + if (onlyError && !eventIsFailure(event)) return false + return true + }) const preStyle: CSSProperties = { margin: '6px 0 0', padding: 10, @@ -150,7 +220,7 @@ export default function SemiAutoTaskHistoryDrawer({ color: token.colorText, fontSize: 12, lineHeight: 1.55, - maxHeight: 320, + maxHeight: 280, overflow: 'auto', whiteSpace: 'pre-wrap', wordBreak: 'break-all', @@ -170,40 +240,106 @@ export default function SemiAutoTaskHistoryDrawer({ const eventsPanel = ( {history?.task ? ( - - - 登录:{LOGIN_STATUS_LABELS[history.task.loginStatus] || history.task.loginStatus} - - - 绑定: - {history.task.platform === 'weibo' - ? '登录即授权' - : BINDING_STATUS_LABELS[history.task.bindingStatus] || history.task.bindingStatus} - - - 执行: - {EXECUTION_STATUS_LABELS[history.task.executionStatus] || history.task.executionStatus} - - 创建 {formatAdminDateTime(history.task.createdAt)} - {history.task.completedAt ? ( - 完成 {formatAdminDateTime(history.task.completedAt)} - ) : null} - + + + {LOGIN_STATUS_LABELS[history.task.loginStatus] || history.task.loginStatus} + + ), + }, + { + key: 'binding', + label: '绑定状态', + children: ( + + {history.task.platform === 'weibo' + ? '登录即授权' + : BINDING_STATUS_LABELS[history.task.bindingStatus] || + history.task.bindingStatus} + + ), + }, + { + key: 'execution', + label: '执行状态', + children: ( + + {EXECUTION_STATUS_LABELS[history.task.executionStatus] || + history.task.executionStatus} + + ), + }, + { + key: 'createdAt', + label: '创建时间', + children: formatAdminDateTime(history.task.createdAt), + }, + { + key: 'completedAt', + label: '完成时间', + children: history.task.completedAt + ? formatAdminDateTime(history.task.completedAt) + : '—', + }, + { + key: 'eventTotal', + label: '事件数量', + children: `${history.eventTotal} 条`, + }, + ]} + /> + ) : null} - {history && history.eventTotal > events.length ? ( + + +