feat(douyu): 账号表格新增最近结果列,支持快速查看二维码
- 新增 latestTaskByAccount 按账号聚合最近一条任务 - 账号表新增最近结果列:任务类型Tag+查看按钮+进度文案 - 有二维码/弹窗的任务显示查看按钮,点击直接打开对应弹窗 - 二维码收起后可在账号表快速重新打开,无需去任务记录查找
This commit is contained in:
@@ -344,6 +344,16 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
||||
return map;
|
||||
}, [tasks]);
|
||||
|
||||
// 每个账号最近一条任务(当前手册类型),用于账号表"最近结果"列快速查看二维码
|
||||
const latestTaskByAccount = useMemo(() => {
|
||||
const map = new Map<number, DouyuTaskItem>();
|
||||
for (const task of visibleTasks) {
|
||||
const previous = map.get(task.account_id);
|
||||
if (!previous || task.id > previous.id) map.set(task.account_id, task);
|
||||
}
|
||||
return map;
|
||||
}, [visibleTasks]);
|
||||
|
||||
const loadData = useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
@@ -959,6 +969,45 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
||||
return aw - bw;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '最近结果', width: 200,
|
||||
render: (_, record) => {
|
||||
const task = latestTaskByAccount.get(record.id);
|
||||
if (!task) return <Text type="secondary">无</Text>;
|
||||
const typeLabel = taskTypes[task.task_type] || task.task_type;
|
||||
// 是否有可打开的二维码/弹窗
|
||||
const canOpen = hasBindQrcode(task) || hasPaymentQrcode(task)
|
||||
|| (['prepare_esports_bind', 'get_esports_bind_qr'].includes(task.task_type)
|
||||
&& (Boolean(resultText(task.result, 'url')) || task.result?.esports_bind_dialog === true));
|
||||
const openTask = () => {
|
||||
if (hasBindQrcode(task)) openQrTask(task);
|
||||
else if (hasPaymentQrcode(task)) openPayTask(task);
|
||||
else openEsportsBindTask(task);
|
||||
};
|
||||
return (
|
||||
<Space direction="vertical" size={2} style={{ width: '100%' }}>
|
||||
<Space size={4} wrap>
|
||||
<Tag color={STATUS_COLORS[task.status] || 'default'} style={{ margin: 0 }}>{typeLabel}</Tag>
|
||||
{canOpen && (
|
||||
<Button
|
||||
size="small" type="link" icon={<QrcodeOutlined />}
|
||||
onClick={openTask}
|
||||
style={{ padding: 0, height: 20, fontSize: 12 }}
|
||||
>
|
||||
查看
|
||||
</Button>
|
||||
)}
|
||||
</Space>
|
||||
<Text
|
||||
type="secondary" style={{ fontSize: 12 }}
|
||||
ellipsis={{ tooltip: task.message || '' }}
|
||||
>
|
||||
{task.message || STATUS_LABELS[task.status] || task.status}
|
||||
</Text>
|
||||
</Space>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
// 任务记录表
|
||||
|
||||
Reference in New Issue
Block a user