feat(douyu): 优化精英宝典批量选择与工作台交互
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
Alert, Button, Card, Input, InputNumber, Modal, Popconfirm, QRCode, Select,
|
Alert, Button, Card, Dropdown, Input, InputNumber, Modal, Popconfirm, QRCode, Select,
|
||||||
Space, Table, Tabs, Tag, Tooltip, Typography, theme,
|
Space, Table, Tabs, Tag, Tooltip, Typography, theme,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import type { TableProps } from 'antd';
|
import type { TableProps } from 'antd';
|
||||||
import {
|
import {
|
||||||
CheckCircleOutlined, ColumnWidthOutlined, CopyOutlined, CreditCardOutlined, ExclamationCircleOutlined, FieldTimeOutlined, FilterOutlined, GiftOutlined,
|
CheckCircleOutlined, ColumnWidthOutlined, CopyOutlined, CreditCardOutlined, ExclamationCircleOutlined, FieldTimeOutlined, FilterOutlined, GiftOutlined,
|
||||||
ImportOutlined, LoadingOutlined, QrcodeOutlined, ReloadOutlined,
|
ImportOutlined, LoadingOutlined, MoreOutlined, QrcodeOutlined, ReloadOutlined,
|
||||||
SearchOutlined, SettingOutlined, ShoppingOutlined, StopOutlined,
|
SearchOutlined, SettingOutlined, ShoppingOutlined, StopOutlined, SwapOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import {
|
import {
|
||||||
accountApi,
|
accountApi,
|
||||||
@@ -194,6 +194,7 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
const [workbenchIds, setWorkbenchIds] = useState<number[]>([]);
|
const [workbenchIds, setWorkbenchIds] = useState<number[]>([]);
|
||||||
const [workbenchReady, setWorkbenchReady] = useState(false);
|
const [workbenchReady, setWorkbenchReady] = useState(false);
|
||||||
const [selectedIds, setSelectedIds] = useState<number[]>([]);
|
const [selectedIds, setSelectedIds] = useState<number[]>([]);
|
||||||
|
const [eliteSelectLoading, setEliteSelectLoading] = useState(false);
|
||||||
const [goods, setGoods] = useState<DouyuGoodsItem[]>([]);
|
const [goods, setGoods] = useState<DouyuGoodsItem[]>([]);
|
||||||
const [tasks, setTasks] = useState<DouyuTaskItem[]>([]);
|
const [tasks, setTasks] = useState<DouyuTaskItem[]>([]);
|
||||||
const [taskTypes, setTaskTypes] = useState<Record<string, string>>({});
|
const [taskTypes, setTaskTypes] = useState<Record<string, string>>({});
|
||||||
@@ -963,21 +964,21 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
const ids = accountIds || selectedIds;
|
const ids = accountIds || selectedIds;
|
||||||
if (ids.length === 0) {
|
if (ids.length === 0) {
|
||||||
message.warning('请先选择账号');
|
message.warning('请先选择账号');
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
// 多批次并发:不再拦截,允许在已有批次运行时继续创建新批次
|
// 多批次并发:不再拦截,允许在已有批次运行时继续创建新批次
|
||||||
if (['lock_goods', 'exchange_goods', 'exchange_esports_goods', 'exchange_xpd_goods'].includes(taskType) && !selectedGoodsId) {
|
if (['lock_goods', 'exchange_goods', 'exchange_esports_goods', 'exchange_xpd_goods'].includes(taskType) && !selectedGoodsId) {
|
||||||
message.warning('请先选择兑换商品');
|
message.warning('请先选择兑换商品');
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
if (taskType === 'exchange_xpd_goods') {
|
if (taskType === 'exchange_xpd_goods') {
|
||||||
if (selectedXpdGoodsSoldOut) {
|
if (selectedXpdGoodsSoldOut) {
|
||||||
message.warning('该商品库存不足,请刷新商品列表后重试');
|
message.warning('该商品库存不足,请刷新商品列表后重试');
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
if (!xpdPaymentOptions.some((option) => option.value === xpdPayType)) {
|
if (!xpdPaymentOptions.some((option) => option.value === xpdPayType)) {
|
||||||
message.warning('该商品不支持当前兑换方式');
|
message.warning('该商品不支持当前兑换方式');
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const payload: Record<string, unknown> = { ...extraPayload };
|
const payload: Record<string, unknown> = { ...extraPayload };
|
||||||
@@ -1067,8 +1068,86 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
});
|
});
|
||||||
message.success(`已创建 ${result.count} 个任务`);
|
message.success(`已创建 ${result.count} 个任务`);
|
||||||
setTimeout(() => { void loadTasks(); }, 400);
|
setTimeout(() => { void loadTasks(); }, 400);
|
||||||
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
message.error(getErrorMessage(error));
|
message.error(getErrorMessage(error));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const invertCurrentPageSelection = () => {
|
||||||
|
const currentPageIds = new Set(accounts.map((account) => account.id));
|
||||||
|
setSelectedIds((current) => {
|
||||||
|
const next = new Set(current);
|
||||||
|
for (const accountId of currentPageIds) {
|
||||||
|
if (next.has(accountId)) next.delete(accountId);
|
||||||
|
else next.add(accountId);
|
||||||
|
}
|
||||||
|
return Array.from(next);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const queryAndSelectUnopenedElite = async () => {
|
||||||
|
if (!isEliteHandbook) return;
|
||||||
|
const targetIds = accounts.map((account) => account.id);
|
||||||
|
if (targetIds.length === 0) {
|
||||||
|
message.warning('当前页没有可查询的账号');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setEliteSelectLoading(true);
|
||||||
|
try {
|
||||||
|
const created = await startTask('query_elite_status', targetIds);
|
||||||
|
if (!created) return;
|
||||||
|
|
||||||
|
const deadline = Date.now() + 180_000;
|
||||||
|
let batchTasks: DouyuTaskItem[] = [];
|
||||||
|
while (true) {
|
||||||
|
batchTasks = await douyuApi.listTasks(handbook, created.batch_id);
|
||||||
|
const allFinished = batchTasks.length >= created.count
|
||||||
|
&& batchTasks.every((task) => !['planned', 'pending', 'running'].includes(task.status));
|
||||||
|
if (allFinished || Date.now() >= deadline) break;
|
||||||
|
await new Promise((resolve) => window.setTimeout(resolve, 800));
|
||||||
|
}
|
||||||
|
|
||||||
|
const unopenedIds = new Set(
|
||||||
|
batchTasks
|
||||||
|
.filter((task) => task.status === 'success' && task.result?.elite_opened === false)
|
||||||
|
.map((task) => task.account_id),
|
||||||
|
);
|
||||||
|
|
||||||
|
let refreshedAccounts = accounts;
|
||||||
|
if (workbenchIds.length > 0) {
|
||||||
|
const refreshed = await douyuApi.listAccountsPaged({
|
||||||
|
ids: workbenchIds.join(','),
|
||||||
|
search: accountSearch.trim() || undefined,
|
||||||
|
page: accountPage,
|
||||||
|
page_size: accountPageSize,
|
||||||
|
});
|
||||||
|
refreshedAccounts = refreshed.items;
|
||||||
|
setAccounts(refreshed.items);
|
||||||
|
setAccountTotal(refreshed.total);
|
||||||
|
}
|
||||||
|
|
||||||
|
const selected = refreshedAccounts
|
||||||
|
.filter((account) => unopenedIds.has(account.id))
|
||||||
|
.map((account) => account.id);
|
||||||
|
setSelectedIds(selected);
|
||||||
|
|
||||||
|
const unfinished = batchTasks.filter(
|
||||||
|
(task) => ['planned', 'pending', 'running'].includes(task.status),
|
||||||
|
).length;
|
||||||
|
if (unfinished > 0) {
|
||||||
|
message.warning(`查询超时,已按完成的 ${batchTasks.length - unfinished} 个任务选中 ${selected.length} 个未开通账号`);
|
||||||
|
} else if (selected.length > 0) {
|
||||||
|
message.success(`查询完成,已选中 ${selected.length} 个未开通精英宝典的账号`);
|
||||||
|
} else {
|
||||||
|
message.info('查询完成,当前页没有未开通精英宝典的账号');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
message.error(`查询未开通账号失败: ${getErrorMessage(error)}`);
|
||||||
|
} finally {
|
||||||
|
setEliteSelectLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1548,11 +1627,11 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
// Account table
|
// Account table
|
||||||
const accountColumns: TableProps<DouyuTaskAccountItem>['columns'] = [
|
const accountColumns: TableProps<DouyuTaskAccountItem>['columns'] = [
|
||||||
{
|
{
|
||||||
title: '#', width: 45,
|
title: '#', width: 50,
|
||||||
render: (_, __, index) => <Text type="secondary">{index + 1}</Text>,
|
render: (_, __, index) => <Text type="secondary">{index + 1}</Text>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '账号', dataIndex: 'username', width: 150,
|
title: '账号', dataIndex: 'username', width: 180,
|
||||||
render: (_, record) => (
|
render: (_, record) => (
|
||||||
<Space direction="vertical" size={0}>
|
<Space direction="vertical" size={0}>
|
||||||
<Text strong>{record.nickname || record.username}</Text>
|
<Text strong>{record.nickname || record.username}</Text>
|
||||||
@@ -1561,7 +1640,7 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'CK状态', width: 100, align: 'center',
|
title: 'CK状态', width: 110, align: 'center',
|
||||||
render: (_, record) => {
|
render: (_, record) => {
|
||||||
if (ckCheckingIds.has(record.id)) {
|
if (ckCheckingIds.has(record.id)) {
|
||||||
return <Tag color="processing" icon={<LoadingOutlined />}>检测中</Tag>;
|
return <Tag color="processing" icon={<LoadingOutlined />}>检测中</Tag>;
|
||||||
@@ -1584,7 +1663,7 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '游戏名', dataIndex: 'game_name', width: 170,
|
title: '游戏名', dataIndex: 'game_name', width: 220,
|
||||||
render: (_, record) => {
|
render: (_, record) => {
|
||||||
if (isPeaceHandbook) {
|
if (isPeaceHandbook) {
|
||||||
// 和平小店:角色名与绑定状态都读**账号字段**(不再从任务日志反推)。
|
// 和平小店:角色名与绑定状态都读**账号字段**(不再从任务日志反推)。
|
||||||
@@ -1665,13 +1744,13 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
{
|
{
|
||||||
title: isPeaceHandbook ? '点券' : (isEsportsHandbook ? '电竞积分' : '积分'),
|
title: isPeaceHandbook ? '点券' : (isEsportsHandbook ? '电竞积分' : '积分'),
|
||||||
dataIndex: isPeaceHandbook ? 'xpd_balance' : (isEsportsHandbook ? 'esports_points' : 'points'),
|
dataIndex: isPeaceHandbook ? 'xpd_balance' : (isEsportsHandbook ? 'esports_points' : 'points'),
|
||||||
width: 80,
|
width: 88,
|
||||||
render: (v) => v ?? <Text type="secondary">-</Text>,
|
render: (v) => v ?? <Text type="secondary">-</Text>,
|
||||||
},
|
},
|
||||||
// 精英宝典开通状态:积分区分不了「开通后积分花完」和「从未开通」,单独展示
|
// 精英宝典开通状态:积分区分不了「开通后积分花完」和「从未开通」,单独展示
|
||||||
...(isEliteHandbook
|
...(isEliteHandbook
|
||||||
? [{
|
? [{
|
||||||
title: '宝典状态', dataIndex: 'elite_opened', width: 150,
|
title: '宝典状态', dataIndex: 'elite_opened', width: 160,
|
||||||
render: (_: unknown, record: DouyuTaskAccountItem) => {
|
render: (_: unknown, record: DouyuTaskAccountItem) => {
|
||||||
const text = eliteStatusText(record);
|
const text = eliteStatusText(record);
|
||||||
if (!text) return <Text type="secondary">未查</Text>;
|
if (!text) return <Text type="secondary">未查</Text>;
|
||||||
@@ -1689,11 +1768,11 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
}] as NonNullable<TableProps<DouyuTaskAccountItem>['columns']>
|
}] as NonNullable<TableProps<DouyuTaskAccountItem>['columns']>
|
||||||
: [
|
: [
|
||||||
{
|
{
|
||||||
title: '鱼翅', dataIndex: 'gold_balance', width: 70,
|
title: '鱼翅', dataIndex: 'gold_balance', width: 80,
|
||||||
render: (v: number | null) => v ?? <Text type="secondary">-</Text>,
|
render: (v: number | null) => v ?? <Text type="secondary">-</Text>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '限制兑换', dataIndex: 'exchange_balance', width: 150, ellipsis: true,
|
title: '限制兑换', dataIndex: 'exchange_balance', width: 160, ellipsis: true,
|
||||||
render: (_, record) => {
|
render: (_, record) => {
|
||||||
const latestLimitedTask = latestLimitedGoodsTaskByAccount.get(record.id);
|
const latestLimitedTask = latestLimitedGoodsTaskByAccount.get(record.id);
|
||||||
const text = limitedGoodsTaskText(latestLimitedTask);
|
const text = limitedGoodsTaskText(latestLimitedTask);
|
||||||
@@ -1709,7 +1788,7 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '换绑时间', dataIndex: 'change_role_wait_time', width: 130,
|
title: '换绑时间', dataIndex: 'change_role_wait_time', width: 150,
|
||||||
render: (_, record) => {
|
render: (_, record) => {
|
||||||
const fromTask = latestChangeWaitByAccount.get(record.id);
|
const fromTask = latestChangeWaitByAccount.get(record.id);
|
||||||
const canChangeTime = fromTask?.canChangeTime ?? (
|
const canChangeTime = fromTask?.canChangeTime ?? (
|
||||||
@@ -1762,7 +1841,7 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
},
|
},
|
||||||
] as NonNullable<TableProps<DouyuTaskAccountItem>['columns']>),
|
] as NonNullable<TableProps<DouyuTaskAccountItem>['columns']>),
|
||||||
{
|
{
|
||||||
title: '最近操作', width: 220,
|
title: '最近操作', width: 260,
|
||||||
render: (_, record) => {
|
render: (_, record) => {
|
||||||
const latest = latestTaskByAccount.get(record.id);
|
const latest = latestTaskByAccount.get(record.id);
|
||||||
if (!latest) return <Text type="secondary">暂无操作</Text>;
|
if (!latest) return <Text type="secondary">暂无操作</Text>;
|
||||||
@@ -1772,7 +1851,7 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
<Tag color={TASK_STATUS_COLORS[latest.status] || 'default'}>
|
<Tag color={TASK_STATUS_COLORS[latest.status] || 'default'}>
|
||||||
{TASK_STATUS_LABELS[latest.status] || latest.status}
|
{TASK_STATUS_LABELS[latest.status] || latest.status}
|
||||||
</Tag>
|
</Tag>
|
||||||
<Text strong ellipsis style={{ maxWidth: 130 }}>
|
<Text strong ellipsis style={{ maxWidth: 170 }}>
|
||||||
{taskTypes[latest.task_type] || latest.task_type}
|
{taskTypes[latest.task_type] || latest.task_type}
|
||||||
</Text>
|
</Text>
|
||||||
</Space>
|
</Space>
|
||||||
@@ -1789,7 +1868,7 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '二维码', width: 76, align: 'center',
|
title: '二维码', width: 92, align: 'center',
|
||||||
render: (_, record) => {
|
render: (_, record) => {
|
||||||
const task = latestTaskByAccount.get(record.id);
|
const task = latestTaskByAccount.get(record.id);
|
||||||
// 只要结果里还有二维码地址就一直展示:绑定类任务等不到扫码时也会以
|
// 只要结果里还有二维码地址就一直展示:绑定类任务等不到扫码时也会以
|
||||||
@@ -1819,7 +1898,7 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '兑换图片', width: 80, align: 'center',
|
title: '兑换图片', width: 100, align: 'center',
|
||||||
render: (_, record) => {
|
render: (_, record) => {
|
||||||
const task = latestExchangeTaskByAccount.get(record.id);
|
const task = latestExchangeTaskByAccount.get(record.id);
|
||||||
if (!task) return <Text type="secondary">-</Text>;
|
if (!task) return <Text type="secondary">-</Text>;
|
||||||
@@ -1852,7 +1931,7 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
},
|
},
|
||||||
}] : []),
|
}] : []),
|
||||||
...(!isPeaceHandbook && !isEsportsHandbook ? [{
|
...(!isPeaceHandbook && !isEsportsHandbook ? [{
|
||||||
title: '锁单', width: 150, align: 'center' as const,
|
title: '锁单', width: 170, align: 'center' as const,
|
||||||
render: (_: unknown, record: DouyuTaskAccountItem) => {
|
render: (_: unknown, record: DouyuTaskAccountItem) => {
|
||||||
const task = latestLockedTaskByAccount.get(record.id);
|
const task = latestLockedTaskByAccount.get(record.id);
|
||||||
if (!task) return <Text type="secondary">-</Text>;
|
if (!task) return <Text type="secondary">-</Text>;
|
||||||
@@ -2110,6 +2189,19 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
const activePaySessionView = visiblePaySessionViews.find(
|
const activePaySessionView = visiblePaySessionViews.find(
|
||||||
(view) => view.session.batchId === activePayBatchId,
|
(view) => view.session.batchId === activePayBatchId,
|
||||||
) || visiblePaySessionViews[0];
|
) || visiblePaySessionViews[0];
|
||||||
|
const requestClosePayModal = () => {
|
||||||
|
if (activePaySessionView?.active) {
|
||||||
|
Modal.confirm({
|
||||||
|
title: '关闭当前支付任务?',
|
||||||
|
content: '关闭只会移除当前支付码会话,后台任务仍会继续运行;如需停止任务,请使用“停止当前批次”。',
|
||||||
|
okText: '关闭会话',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: closeActivePaySession,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
closeActivePaySession();
|
||||||
|
};
|
||||||
const payReadyCount = activePaySessionView?.readyCount || 0;
|
const payReadyCount = activePaySessionView?.readyCount || 0;
|
||||||
const payQueuedCount = activePaySessionView?.queuedCount || 0;
|
const payQueuedCount = activePaySessionView?.queuedCount || 0;
|
||||||
const payDoneCount = activePaySessionView?.doneCount || 0;
|
const payDoneCount = activePaySessionView?.doneCount || 0;
|
||||||
@@ -2442,19 +2534,37 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
<Space style={{ marginBottom: 8, width: '100%', justifyContent: 'space-between', flexShrink: 0 }} wrap>
|
<Space style={{ marginBottom: 8, width: '100%', justifyContent: 'space-between', flexShrink: 0 }} wrap>
|
||||||
<Space>
|
<Space>
|
||||||
<Input
|
<Input
|
||||||
size="small" placeholder="搜索账号/昵称/游戏名" prefix={<SearchOutlined />}
|
placeholder="搜索账号/昵称/游戏名" prefix={<SearchOutlined />}
|
||||||
value={accountSearch}
|
value={accountSearch}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setAccountSearch(e.target.value);
|
setAccountSearch(e.target.value);
|
||||||
setAccountPage(1);
|
setAccountPage(1);
|
||||||
}}
|
}}
|
||||||
style={{ width: 200 }} allowClear
|
style={{ width: 240 }} allowClear
|
||||||
/>
|
/>
|
||||||
|
<Button
|
||||||
|
icon={<SwapOutlined />}
|
||||||
|
disabled={accounts.length === 0}
|
||||||
|
onClick={invertCurrentPageSelection}
|
||||||
|
>
|
||||||
|
反选本页
|
||||||
|
</Button>
|
||||||
|
{isEliteHandbook && (
|
||||||
|
<Tooltip title="查询当前页账号并选中未开通精英宝典的账号">
|
||||||
|
<Button
|
||||||
|
icon={<FilterOutlined />}
|
||||||
|
loading={eliteSelectLoading}
|
||||||
|
disabled={accounts.length === 0}
|
||||||
|
onClick={() => void queryAndSelectUnopenedElite()}
|
||||||
|
>
|
||||||
|
查询并选未开通
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
</Space>
|
</Space>
|
||||||
<Space>
|
<Space>
|
||||||
<Button size="small" icon={<ImportOutlined />} onClick={() => setImportOpen(true)}>导入账号</Button>
|
<Button icon={<ImportOutlined />} onClick={() => setImportOpen(true)}>导入账号</Button>
|
||||||
<Button
|
<Button
|
||||||
size="small"
|
|
||||||
icon={<CheckCircleOutlined />}
|
icon={<CheckCircleOutlined />}
|
||||||
disabled={selectedIds.length === 0 || ckCheckingIds.size > 0}
|
disabled={selectedIds.length === 0 || ckCheckingIds.size > 0}
|
||||||
onClick={() => void checkWorkbenchCk(selectedIds)}
|
onClick={() => void checkWorkbenchCk(selectedIds)}
|
||||||
@@ -2463,7 +2573,6 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
</Button>
|
</Button>
|
||||||
{isAdmin && (
|
{isAdmin && (
|
||||||
<Button
|
<Button
|
||||||
size="small"
|
|
||||||
danger
|
danger
|
||||||
icon={<ReloadOutlined />}
|
icon={<ReloadOutlined />}
|
||||||
disabled={selectedIds.length === 0}
|
disabled={selectedIds.length === 0}
|
||||||
@@ -2473,20 +2582,20 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{selectedIds.length > 0 && (
|
{selectedIds.length > 0 && (
|
||||||
<Button size="small" danger onClick={removeSelected}>移出选中</Button>
|
<Button danger onClick={removeSelected}>移出选中</Button>
|
||||||
)}
|
)}
|
||||||
</Space>
|
</Space>
|
||||||
</Space>
|
</Space>
|
||||||
<div ref={accountTableAreaRef} style={{ flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column' }}>
|
<div ref={accountTableAreaRef} style={{ flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column' }}>
|
||||||
<Table
|
<Table
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
size="small"
|
|
||||||
className="douyu-task-record-table"
|
className="douyu-task-record-table"
|
||||||
loading={loading || !workbenchReady}
|
loading={loading || !workbenchReady}
|
||||||
locale={{ emptyText: '工作台暂无账号,点击右上角「导入账号」添加' }}
|
locale={{ emptyText: '工作台暂无账号,点击右上角「导入账号」添加' }}
|
||||||
rowSelection={{
|
rowSelection={{
|
||||||
selectedRowKeys: selectedIds,
|
selectedRowKeys: selectedIds,
|
||||||
onChange: (keys) => setSelectedIds(keys.map(Number)),
|
onChange: (keys) => setSelectedIds(keys.map(Number)),
|
||||||
|
preserveSelectedRowKeys: true,
|
||||||
}}
|
}}
|
||||||
columns={accountColumns}
|
columns={accountColumns}
|
||||||
dataSource={accounts}
|
dataSource={accounts}
|
||||||
@@ -2496,7 +2605,6 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
total: accountTotal,
|
total: accountTotal,
|
||||||
showSizeChanger: true,
|
showSizeChanger: true,
|
||||||
pageSizeOptions: [10, 20, 50, 100],
|
pageSizeOptions: [10, 20, 50, 100],
|
||||||
size: 'small',
|
|
||||||
showLessItems: true,
|
showLessItems: true,
|
||||||
showTotal: (total) => `共 ${total} 条`,
|
showTotal: (total) => `共 ${total} 条`,
|
||||||
onChange: (page, size) => {
|
onChange: (page, size) => {
|
||||||
@@ -2508,7 +2616,7 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
tableLayout="fixed"
|
tableLayout="fixed"
|
||||||
scroll={{ x: 1380, y: Math.max(120, accountTableAreaHeight - 80) }}
|
scroll={{ x: 1880, y: Math.max(120, accountTableAreaHeight - 80) }}
|
||||||
onRow={(record) => ({
|
onRow={(record) => ({
|
||||||
onContextMenu: (e) => handleRowContextMenu(record, e),
|
onContextMenu: (e) => handleRowContextMenu(record, e),
|
||||||
style: { cursor: 'context-menu' },
|
style: { cursor: 'context-menu' },
|
||||||
@@ -2536,7 +2644,7 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
.douyu-task-record-table .ant-table {
|
.douyu-task-record-table .ant-table {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
font-size: 12px;
|
font-size: 13px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
@@ -2556,22 +2664,26 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
}
|
}
|
||||||
.douyu-task-record-table .ant-table-thead > tr > th,
|
.douyu-task-record-table .ant-table-thead > tr > th,
|
||||||
.douyu-task-record-table .ant-table-tbody > tr > td {
|
.douyu-task-record-table .ant-table-tbody > tr > td {
|
||||||
padding: 4px 8px;
|
padding: 7px 10px;
|
||||||
line-height: 20px;
|
line-height: 21px;
|
||||||
|
}
|
||||||
|
.douyu-task-record-table .ant-table-thead > tr > th {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
.douyu-task-record-table .ant-typography {
|
.douyu-task-record-table .ant-typography {
|
||||||
font-size: 12px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
.douyu-task-record-table .ant-tag {
|
.douyu-task-record-table .ant-tag {
|
||||||
font-size: 11px;
|
font-size: 12px;
|
||||||
line-height: 18px;
|
line-height: 20px;
|
||||||
margin-inline-end: 0;
|
margin-inline-end: 0;
|
||||||
padding-inline: 5px;
|
padding-inline: 7px;
|
||||||
}
|
}
|
||||||
.douyu-task-record-table .ant-pagination {
|
.douyu-task-record-table .ant-pagination {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 6px 4px 2px;
|
padding: 8px 4px 2px;
|
||||||
border-top: 1px solid ${token.colorBorderSecondary};
|
border-top: 1px solid ${token.colorBorderSecondary};
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@@ -3095,39 +3207,30 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
</Space>
|
</Space>
|
||||||
}
|
}
|
||||||
open={payOpen}
|
open={payOpen}
|
||||||
onCancel={() => setPayOpen(false)}
|
onCancel={requestClosePayModal}
|
||||||
footer={(
|
footer={
|
||||||
<Space wrap>
|
activePaySessionView && activePaySessionOwned && activePaySessionView.active
|
||||||
<Button onClick={() => setPayOpen(false)}>关闭</Button>
|
? (
|
||||||
{activePaySessionView && activePaySessionOwned && (
|
<Space wrap>
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
title="停止当前充值批次?"
|
title="停止当前充值批次?"
|
||||||
description="只停止当前 Tab 的批次,不会影响其他批次。"
|
description="只停止当前 Tab 的批次,不会影响其他批次。"
|
||||||
okText="停止"
|
okText="停止"
|
||||||
cancelText="取消"
|
cancelText="取消"
|
||||||
onConfirm={() => void stopActivePaySession()}
|
onConfirm={() => void stopActivePaySession()}
|
||||||
>
|
|
||||||
<Button
|
|
||||||
danger
|
|
||||||
icon={<StopOutlined />}
|
|
||||||
loading={stoppingPayBatchId === activePaySessionView.session.batchId}
|
|
||||||
disabled={!activePaySessionView.active}
|
|
||||||
>
|
>
|
||||||
停止当前批次
|
<Button
|
||||||
</Button>
|
danger
|
||||||
</Popconfirm>
|
icon={<StopOutlined />}
|
||||||
)}
|
loading={stoppingPayBatchId === activePaySessionView.session.batchId}
|
||||||
<Button
|
>
|
||||||
onClick={clearHistoricalPaySessions}
|
停止当前批次
|
||||||
disabled={historicalPaySessionIds.length === 0}
|
</Button>
|
||||||
>
|
</Popconfirm>
|
||||||
清理历史会话
|
</Space>
|
||||||
</Button>
|
)
|
||||||
<Button onClick={closeActivePaySession} disabled={!activePaySessionView}>
|
: null
|
||||||
关闭当前会话
|
}
|
||||||
</Button>
|
|
||||||
</Space>
|
|
||||||
)}
|
|
||||||
centered
|
centered
|
||||||
width={920}
|
width={920}
|
||||||
>
|
>
|
||||||
@@ -3138,6 +3241,25 @@ export default function DouyuTasksPage({ handbook }: { handbook: HandbookKind })
|
|||||||
setActivePayBatchId(batchId);
|
setActivePayBatchId(batchId);
|
||||||
void loadPaySessionTasks([batchId]);
|
void loadPaySessionTasks([batchId]);
|
||||||
}}
|
}}
|
||||||
|
tabBarExtraContent={historicalPaySessionIds.length > 0 ? (
|
||||||
|
<Dropdown
|
||||||
|
trigger={['click']}
|
||||||
|
menu={{
|
||||||
|
items: [{
|
||||||
|
key: 'clear-history',
|
||||||
|
label: `清理历史会话(${historicalPaySessionIds.length})`,
|
||||||
|
onClick: clearHistoricalPaySessions,
|
||||||
|
}],
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
type="text"
|
||||||
|
icon={<MoreOutlined />}
|
||||||
|
aria-label="更多会话操作"
|
||||||
|
title="更多会话操作"
|
||||||
|
/>
|
||||||
|
</Dropdown>
|
||||||
|
) : null}
|
||||||
items={visiblePaySessionViews.map((view) => ({
|
items={visiblePaySessionViews.map((view) => ({
|
||||||
key: view.session.batchId,
|
key: view.session.batchId,
|
||||||
label: (
|
label: (
|
||||||
|
|||||||
Reference in New Issue
Block a user