style(semi-auto): 优化履约历史时间线与报文展示
顶部汇总当前状态;节点按操作结果命名并加来源/异常筛选;状态变化改为标签对比,原始详情折叠;报文改为请求/响应两栏并统一字段名称。
This commit is contained in:
@@ -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<string, string> = {
|
||||
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<string, string> = {
|
||||
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<string, string> = {
|
||||
waiting_code: '等待客户输入验证码',
|
||||
qr_pending: '生成登录二维码',
|
||||
scanned: '客户已扫码,等待确认',
|
||||
authenticated: '客户完成平台登录',
|
||||
failed: '平台登录失败',
|
||||
expired: '登录二维码已过期',
|
||||
}
|
||||
|
||||
const BINDING_EVENT_TITLES: Record<string, string> = {
|
||||
not_started: '绑定状态重置',
|
||||
qr_pending: '生成绑定二维码',
|
||||
scanned: '客户已扫码绑定',
|
||||
role_ready: '平台识别到游戏角色',
|
||||
confirmed: '客户确认绑定角色',
|
||||
failed: '角色绑定失败',
|
||||
expired: '绑定二维码已过期',
|
||||
}
|
||||
|
||||
const CHANNEL_LABELS: Record<string, string> = {
|
||||
@@ -50,11 +74,38 @@ const CHANNEL_LABELS: Record<string, string> = {
|
||||
external_connector: '外部 Connector',
|
||||
}
|
||||
|
||||
const CHANNEL_COLORS: Record<string, string> = {
|
||||
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<string, string> = {
|
||||
system: '系统',
|
||||
customer: '客户',
|
||||
admin: '客服',
|
||||
connector: '平台连接器',
|
||||
}
|
||||
|
||||
const ACTOR_COLORS: Record<string, string> = {
|
||||
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<string, string> = {
|
||||
waiting_login: '等待登录',
|
||||
qr_pending: '待扫码',
|
||||
@@ -83,6 +134,16 @@ const EXECUTION_STATUS_LABELS: Record<string, string> = {
|
||||
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 = (
|
||||
<Space direction="vertical" size={12} style={{ width: '100%' }}>
|
||||
{history?.task ? (
|
||||
<Space size={6} wrap>
|
||||
<Tag color="blue">
|
||||
登录:{LOGIN_STATUS_LABELS[history.task.loginStatus] || history.task.loginStatus}
|
||||
</Tag>
|
||||
<Tag color="gold">
|
||||
绑定:
|
||||
{history.task.platform === 'weibo'
|
||||
? '登录即授权'
|
||||
: BINDING_STATUS_LABELS[history.task.bindingStatus] || history.task.bindingStatus}
|
||||
</Tag>
|
||||
<Tag color="purple">
|
||||
执行:
|
||||
{EXECUTION_STATUS_LABELS[history.task.executionStatus] || history.task.executionStatus}
|
||||
</Tag>
|
||||
<Text type="secondary">创建 {formatAdminDateTime(history.task.createdAt)}</Text>
|
||||
{history.task.completedAt ? (
|
||||
<Text type="secondary">完成 {formatAdminDateTime(history.task.completedAt)}</Text>
|
||||
) : null}
|
||||
</Space>
|
||||
<Card size="small">
|
||||
<Descriptions
|
||||
size="small"
|
||||
column={isMobile ? 1 : 3}
|
||||
items={[
|
||||
{
|
||||
key: 'login',
|
||||
label: '登录状态',
|
||||
children: (
|
||||
<Tag color={loginTagColor(history.task.loginStatus)}>
|
||||
{LOGIN_STATUS_LABELS[history.task.loginStatus] || history.task.loginStatus}
|
||||
</Tag>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'binding',
|
||||
label: '绑定状态',
|
||||
children: (
|
||||
<Tag color={bindingTagColor(history.task.bindingStatus)}>
|
||||
{history.task.platform === 'weibo'
|
||||
? '登录即授权'
|
||||
: BINDING_STATUS_LABELS[history.task.bindingStatus] ||
|
||||
history.task.bindingStatus}
|
||||
</Tag>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'execution',
|
||||
label: '执行状态',
|
||||
children: (
|
||||
<Tag color={executionTagColor(history.task.executionStatus)}>
|
||||
{EXECUTION_STATUS_LABELS[history.task.executionStatus] ||
|
||||
history.task.executionStatus}
|
||||
</Tag>
|
||||
),
|
||||
},
|
||||
{
|
||||
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} 条`,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</Card>
|
||||
) : null}
|
||||
{history && history.eventTotal > events.length ? (
|
||||
|
||||
<Space wrap>
|
||||
<Select
|
||||
allowClear
|
||||
placeholder="全部来源"
|
||||
value={eventActor || undefined}
|
||||
onChange={(value) => setEventActor(value || '')}
|
||||
options={ACTOR_OPTIONS}
|
||||
style={{ width: 140 }}
|
||||
/>
|
||||
<Checkbox checked={onlyError} onChange={(event) => setOnlyError(event.target.checked)}>
|
||||
只看异常
|
||||
</Checkbox>
|
||||
<Text type="secondary">
|
||||
仅展示最近 {events.length} 条状态事件,共 {history.eventTotal} 条。
|
||||
共 {events.length} 个节点,当前显示 {visibleEvents.length} 个
|
||||
</Text>
|
||||
) : null}
|
||||
{history && history.eventTotal > events.length ? (
|
||||
<Text type="secondary">
|
||||
(仅展示最近 {events.length} 条,共 {history.eventTotal} 条)
|
||||
</Text>
|
||||
) : null}
|
||||
</Space>
|
||||
|
||||
{historyQuery.isLoading ? (
|
||||
<Text type="secondary">加载中...</Text>
|
||||
) : events.length === 0 ? (
|
||||
<Empty description="暂无状态流转记录" />
|
||||
) : visibleEvents.length === 0 ? (
|
||||
<Empty
|
||||
description={
|
||||
events.length > 0 ? '当前筛选条件下没有节点' : '暂无状态流转记录(客户还未开始操作)'
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<Timeline
|
||||
items={events.map((event) => ({
|
||||
color: /fail|invalid|error|cancel/i.test(event.eventType) ? 'red' : 'blue',
|
||||
children: <EventItem event={event} preStyle={preStyle} />,
|
||||
mode={isMobile ? undefined : 'left'}
|
||||
items={visibleEvents.map((event) => ({
|
||||
key: String(event.id),
|
||||
color: eventDotColor(event),
|
||||
label: isMobile ? undefined : (
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
{formatAdminDateTime(event.createdAt)}
|
||||
</Text>
|
||||
),
|
||||
children: <EventItem event={event} preStyle={preStyle} showTime={isMobile} />,
|
||||
}))}
|
||||
/>
|
||||
)}
|
||||
@@ -265,6 +401,7 @@ export default function SemiAutoTaskHistoryDrawer({
|
||||
</Tag>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{traces?.summary?.length ? (
|
||||
<Space size={4} wrap>
|
||||
{traces.summary.map((item) => (
|
||||
@@ -278,11 +415,15 @@ export default function SemiAutoTaskHistoryDrawer({
|
||||
))}
|
||||
</Space>
|
||||
) : null}
|
||||
<Text type="secondary">报文保留 180 天;Cookie、Token、短信验证码和二维码内容不落库。</Text>
|
||||
|
||||
<Text type="secondary">
|
||||
报文保留 180 天;Cookie、Token、短信验证码和二维码内容不落库。轮询只在状态变化或失败时记录。
|
||||
</Text>
|
||||
|
||||
{historyQuery.isLoading ? (
|
||||
<Text type="secondary">加载中...</Text>
|
||||
) : traceItems.length === 0 ? (
|
||||
<Empty description="暂无报文记录(当前只记录状态变化与失败,未变化的轮询不落库)" />
|
||||
<Empty description="暂无报文记录" />
|
||||
) : (
|
||||
<Collapse
|
||||
size="small"
|
||||
@@ -303,6 +444,7 @@ export default function SemiAutoTaskHistoryDrawer({
|
||||
}))}
|
||||
/>
|
||||
)}
|
||||
|
||||
<Pagination
|
||||
size={isMobile ? 'small' : undefined}
|
||||
current={traces?.pagination.page || page}
|
||||
@@ -321,8 +463,15 @@ export default function SemiAutoTaskHistoryDrawer({
|
||||
return (
|
||||
<Drawer
|
||||
open={open}
|
||||
width={isMobile ? '100%' : 960}
|
||||
title={history?.task ? `履约历史 · ${history.task.orderNo}` : '履约历史'}
|
||||
width={isMobile ? '100%' : 1000}
|
||||
title={
|
||||
<Space direction="vertical" size={0}>
|
||||
<Text strong>履约历史</Text>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
{history?.task?.orderNo || '—'}
|
||||
</Text>
|
||||
</Space>
|
||||
}
|
||||
onClose={onClose}
|
||||
extra={
|
||||
<Button size="small" icon={<ReloadOutlined />} onClick={() => void historyQuery.refetch()}>
|
||||
@@ -353,46 +502,83 @@ export default function SemiAutoTaskHistoryDrawer({
|
||||
function EventItem({
|
||||
event,
|
||||
preStyle,
|
||||
showTime,
|
||||
}: {
|
||||
event: SemiAutoTaskHistoryEvent
|
||||
preStyle: CSSProperties
|
||||
showTime: boolean
|
||||
}) {
|
||||
const detail = event.detail || {}
|
||||
const detailKeys = Object.keys(detail)
|
||||
const transitions = [
|
||||
{
|
||||
key: 'login',
|
||||
label: '登录',
|
||||
map: LOGIN_STATUS_LABELS,
|
||||
from: event.fromLoginStatus,
|
||||
to: event.toLoginStatus,
|
||||
},
|
||||
{
|
||||
key: 'binding',
|
||||
label: '绑定',
|
||||
map: BINDING_STATUS_LABELS,
|
||||
from: event.fromBindingStatus,
|
||||
to: event.toBindingStatus,
|
||||
},
|
||||
{
|
||||
key: 'execution',
|
||||
label: '执行',
|
||||
map: EXECUTION_STATUS_LABELS,
|
||||
from: event.fromExecutionStatus,
|
||||
to: event.toExecutionStatus,
|
||||
},
|
||||
].filter((item) => item.from !== item.to && Boolean(item.from || item.to))
|
||||
const summary = resolveEventSummary(event)
|
||||
const detailKeys = Object.keys(detail)
|
||||
|
||||
return (
|
||||
<Space direction="vertical" size={2} style={{ width: '100%' }}>
|
||||
<Text strong>{EVENT_LABELS[event.eventType] || event.eventType}</Text>
|
||||
<Text type="secondary">
|
||||
{formatAdminDateTime(event.createdAt)} · {event.actorType}
|
||||
{event.actorId ? ` ${event.actorId}` : ''}
|
||||
</Text>
|
||||
{transitions.map((item) => (
|
||||
<Text key={item.label} type="secondary">
|
||||
{item.label}:{statusLabel(item.map, item.from)} → {statusLabel(item.map, item.to)}
|
||||
<Space direction="vertical" size={4} style={{ width: '100%' }}>
|
||||
<Space size={6} wrap align="center">
|
||||
<Text strong>{resolveEventTitle(event)}</Text>
|
||||
<Tag color={ACTOR_COLORS[event.actorType] || 'default'}>
|
||||
{ACTOR_LABELS[event.actorType] || event.actorType}
|
||||
</Tag>
|
||||
{eventIsFailure(event) ? <Tag color="red">异常</Tag> : null}
|
||||
</Space>
|
||||
{showTime ? (
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
{formatAdminDateTime(event.createdAt)}
|
||||
</Text>
|
||||
) : null}
|
||||
{transitions.map((item) => (
|
||||
<Space key={item.key} size={4} wrap>
|
||||
<Text type="secondary" style={{ fontSize: 12, minWidth: 28 }}>
|
||||
{item.label}
|
||||
</Text>
|
||||
<Tag bordered={false}>{statusLabel(item.map, item.from)}</Tag>
|
||||
<ArrowRightOutlined style={{ fontSize: 10 }} />
|
||||
<Tag bordered={false} color={transitionColor(item.key, item.to)}>
|
||||
{statusLabel(item.map, item.to)}
|
||||
</Tag>
|
||||
</Space>
|
||||
))}
|
||||
{detailKeys.length > 0 ? <pre style={preStyle}>{JSON.stringify(detail, null, 2)}</pre> : null}
|
||||
{summary ? <Text style={{ fontSize: 13 }}>{summary}</Text> : null}
|
||||
{detailKeys.length > 0 ? (
|
||||
<Collapse
|
||||
ghost
|
||||
size="small"
|
||||
items={[
|
||||
{
|
||||
key: 'detail',
|
||||
label: (
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
查看原始详情
|
||||
</Text>
|
||||
),
|
||||
children: <pre style={preStyle}>{JSON.stringify(detail, null, 2)}</pre>,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
) : null}
|
||||
</Space>
|
||||
)
|
||||
}
|
||||
@@ -404,7 +590,9 @@ function TraceLabel({ item }: { item: SemiAutoTraceItem }) {
|
||||
<Tag color={item.direction === 'inbound' ? 'blue' : 'purple'}>
|
||||
{item.direction === 'inbound' ? '入站' : '出站'}
|
||||
</Tag>
|
||||
<Tag>{CHANNEL_LABELS[item.channel] || item.channel}</Tag>
|
||||
<Tag color={CHANNEL_COLORS[item.channel] || 'default'}>
|
||||
{CHANNEL_LABELS[item.channel] || item.channel}
|
||||
</Tag>
|
||||
<Tag color={item.status === 'ok' ? 'green' : 'red'}>
|
||||
{item.status === 'ok' ? '成功' : '失败'}
|
||||
</Tag>
|
||||
@@ -435,10 +623,20 @@ function TracePayload({
|
||||
}) {
|
||||
return (
|
||||
<Space direction="vertical" size={10} style={{ width: '100%' }}>
|
||||
<PayloadBlock title="请求概要" value={item.requestSummary} preStyle={preStyle} />
|
||||
<PayloadBlock title="请求报文" value={item.requestBody} preStyle={preStyle} />
|
||||
<PayloadBlock title="响应概要" value={item.responseSummary} preStyle={preStyle} />
|
||||
<PayloadBlock title="响应报文" value={item.responseBody} preStyle={preStyle} />
|
||||
<Row gutter={[12, 12]}>
|
||||
<Col xs={24} lg={12}>
|
||||
<Space direction="vertical" size={10} style={{ width: '100%' }}>
|
||||
<PayloadBlock title="请求参数" value={item.requestSummary} preStyle={preStyle} />
|
||||
<PayloadBlock title="请求原文" value={item.requestBody} preStyle={preStyle} />
|
||||
</Space>
|
||||
</Col>
|
||||
<Col xs={24} lg={12}>
|
||||
<Space direction="vertical" size={10} style={{ width: '100%' }}>
|
||||
<PayloadBlock title="响应结果" value={item.responseSummary} preStyle={preStyle} />
|
||||
<PayloadBlock title="响应原文" value={item.responseBody} preStyle={preStyle} />
|
||||
</Space>
|
||||
</Col>
|
||||
</Row>
|
||||
<Space size={6} wrap>
|
||||
<Button
|
||||
size="small"
|
||||
@@ -495,7 +693,135 @@ function PayloadBlock({
|
||||
)
|
||||
}
|
||||
|
||||
function resolveEventTitle(event: SemiAutoTaskHistoryEvent) {
|
||||
if (event.eventType === 'login_status_changed') {
|
||||
return LOGIN_EVENT_TITLES[event.toLoginStatus || ''] || '登录状态变更'
|
||||
}
|
||||
if (event.eventType === 'binding_status_changed') {
|
||||
if (
|
||||
event.detail?.rebindUnchanged === true ||
|
||||
String(event.detail?.rebindConfirmState || '') === 'rejected'
|
||||
) {
|
||||
return '换绑被平台拒绝'
|
||||
}
|
||||
return BINDING_EVENT_TITLES[event.toBindingStatus || ''] || '绑定状态变更'
|
||||
}
|
||||
return EVENT_TITLES[event.eventType] || event.eventType
|
||||
}
|
||||
|
||||
function resolveEventSummary(event: SemiAutoTaskHistoryEvent) {
|
||||
const detail = event.detail || {}
|
||||
const text = (value: unknown) => String(value ?? '').trim()
|
||||
if (event.eventType === 'customer_profile_saved') {
|
||||
return [
|
||||
text(detail.roleName) ? `角色:${text(detail.roleName)}` : '',
|
||||
text(detail.roleId) ? `编号:${text(detail.roleId)}` : '',
|
||||
text(detail.serverZone) ? `区服:${text(detail.serverZone)}` : '',
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' · ')
|
||||
}
|
||||
if (event.eventType === 'binding_status_changed') {
|
||||
const parts: string[] = []
|
||||
if (text(detail.gameRole)) {
|
||||
parts.push(
|
||||
`绑定角色:${text(detail.gameRole)}${
|
||||
text(detail.gameRoleId) ? `(${text(detail.gameRoleId)})` : ''
|
||||
}`,
|
||||
)
|
||||
}
|
||||
if (detail.rebindUnchanged === true) parts.push('平台仍返回原绑定角色')
|
||||
const message = text(detail.message) || text(detail.rebindConfirmMessage)
|
||||
if (message) parts.push(message)
|
||||
return parts.join(' · ')
|
||||
}
|
||||
if (event.eventType === 'login_status_changed') {
|
||||
const method = text(detail.method)
|
||||
const methodLabel = method === 'sms' ? '短信验证码' : method === 'qr' ? '扫码' : ''
|
||||
return [methodLabel ? `登录方式:${methodLabel}` : '', text(detail.message)]
|
||||
.filter(Boolean)
|
||||
.join(' · ')
|
||||
}
|
||||
if (event.eventType === 'task_completed') {
|
||||
return [
|
||||
text(detail.note),
|
||||
text(detail.externalOrderNo) ? `外部单号:${text(detail.externalOrderNo)}` : '',
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' · ')
|
||||
}
|
||||
return text(detail.message) || text(detail.reason) || text(detail.note)
|
||||
}
|
||||
|
||||
function eventIsFailure(event: SemiAutoTaskHistoryEvent) {
|
||||
if (event.eventType === 'task_cancelled') return false
|
||||
if (/fail|invalid|error/i.test(event.eventType)) return true
|
||||
if (event.toLoginStatus === 'failed' || event.toLoginStatus === 'expired') return true
|
||||
if (event.toBindingStatus === 'failed' || event.toBindingStatus === 'expired') return true
|
||||
if (
|
||||
event.detail?.rebindUnchanged === true ||
|
||||
String(event.detail?.rebindConfirmState || '') === 'rejected'
|
||||
) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function eventDotColor(event: SemiAutoTaskHistoryEvent) {
|
||||
if (eventIsFailure(event)) return TIMELINE_COLORS.red
|
||||
switch (event.eventType) {
|
||||
case 'task_created':
|
||||
return TIMELINE_COLORS.gray
|
||||
case 'customer_link_opened':
|
||||
case 'customer_profile_saved':
|
||||
return TIMELINE_COLORS.green
|
||||
case 'login_started':
|
||||
case 'login_status_changed':
|
||||
return TIMELINE_COLORS.blue
|
||||
case 'binding_status_changed':
|
||||
return TIMELINE_COLORS.gold
|
||||
case 'task_claimed':
|
||||
case 'customer_reauth_requested':
|
||||
case 'browser_session_opened':
|
||||
return TIMELINE_COLORS.cyan
|
||||
case 'task_completed':
|
||||
return TIMELINE_COLORS.green
|
||||
case 'task_cancelled':
|
||||
return TIMELINE_COLORS.gray
|
||||
default:
|
||||
return TIMELINE_COLORS.blue
|
||||
}
|
||||
}
|
||||
|
||||
function loginTagColor(status: string) {
|
||||
if (status === 'authenticated') return 'green'
|
||||
if (status === 'failed' || status === 'expired') return 'red'
|
||||
return 'blue'
|
||||
}
|
||||
|
||||
function bindingTagColor(status: string) {
|
||||
if (status === 'confirmed') return 'green'
|
||||
if (status === 'role_ready') return 'gold'
|
||||
if (status === 'failed' || status === 'expired') return 'red'
|
||||
return 'blue'
|
||||
}
|
||||
|
||||
function executionTagColor(status: string) {
|
||||
if (status === 'completed') return 'green'
|
||||
if (status === 'failed') return 'red'
|
||||
if (status === 'cancelled') return 'default'
|
||||
if (status === 'waiting_operator') return 'orange'
|
||||
if (status === 'processing') return 'blue'
|
||||
return 'blue'
|
||||
}
|
||||
|
||||
function transitionColor(kind: string, value: string | null) {
|
||||
if (kind === 'login') return loginTagColor(String(value || ''))
|
||||
if (kind === 'binding') return bindingTagColor(String(value || ''))
|
||||
return executionTagColor(String(value || ''))
|
||||
}
|
||||
|
||||
function statusLabel(map: Record<string, string>, value: string | null) {
|
||||
if (!value) return '—'
|
||||
if (!value) return '初始'
|
||||
return map[value] || value
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user