增加斗鱼账号检测功能
This commit is contained in:
@@ -2,7 +2,10 @@ import { useEffect, useState, useMemo, useCallback } from 'react';
|
||||
import {
|
||||
Table, Button, Select, message, Tag, Space, InputNumber, Tooltip, Popconfirm, theme, Modal, Form,
|
||||
} from 'antd';
|
||||
import { PlayCircleOutlined, StopOutlined, FilterOutlined, ReloadOutlined, DeleteOutlined, SettingOutlined } from '@ant-design/icons';
|
||||
import {
|
||||
PlayCircleOutlined, StopOutlined, FilterOutlined, ReloadOutlined, DeleteOutlined,
|
||||
SettingOutlined, SafetyCertificateOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import { accountApi, loginApi, type AccountItem, type LoginTaskItem } from '../api/modules';
|
||||
import RealtimeLogPanel from '../components/RealtimeLogPanel';
|
||||
import { usePermissions } from '../hooks/usePermissions';
|
||||
@@ -16,6 +19,11 @@ const STATUS_COLORS: Record<string, string> = {
|
||||
success: 'success',
|
||||
failed: 'error',
|
||||
error: 'error',
|
||||
account_cancelled: 'error',
|
||||
password_wrong: 'error',
|
||||
account_unverified: 'warning',
|
||||
account_verified: 'success',
|
||||
account_auth_unknown: 'warning',
|
||||
};
|
||||
|
||||
const STATUS_LABELS: Record<string, string> = {
|
||||
@@ -24,8 +32,15 @@ const STATUS_LABELS: Record<string, string> = {
|
||||
success: '成功',
|
||||
failed: '失败',
|
||||
error: '异常',
|
||||
account_cancelled: '账号已注销',
|
||||
password_wrong: '账号密码错误',
|
||||
account_unverified: '账号未认证',
|
||||
account_verified: '账号已认证',
|
||||
account_auth_unknown: '认证状态未知',
|
||||
};
|
||||
|
||||
type BatchMode = 'login' | 'check';
|
||||
|
||||
interface SelectGroupOption {
|
||||
label: string;
|
||||
options: { value: number; label: string }[];
|
||||
@@ -146,8 +161,8 @@ export default function LoginTasksPage() {
|
||||
return () => clearInterval(timer);
|
||||
}, [loadTasks]);
|
||||
|
||||
// 共享的批量登录启动逻辑
|
||||
const startBatch = async (accountIds: number[]) => {
|
||||
// 共享的批量任务启动逻辑
|
||||
const startBatch = async (accountIds: number[], mode: BatchMode = 'login') => {
|
||||
if (accountIds.length === 0) {
|
||||
message.warning('请选择账号');
|
||||
return;
|
||||
@@ -161,9 +176,10 @@ export default function LoginTasksPage() {
|
||||
max_login_retries: maxLoginRetries,
|
||||
max_total_time: maxTotalTime,
|
||||
api_strategy: apiStrategy,
|
||||
mode,
|
||||
});
|
||||
setBatchId(result.batch_id);
|
||||
message.success(`已创建登录任务,共 ${result.count} 个账号`);
|
||||
message.success(`已创建${mode === 'check' ? '检测' : '登录'}任务,共 ${result.count} 个账号`);
|
||||
|
||||
connectLogs(`/api/login/ws/login/${result.batch_id}`, {
|
||||
onClose: () => { setBatchId(null); setStarting(false); },
|
||||
@@ -178,7 +194,8 @@ export default function LoginTasksPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleBatchLogin = () => startBatch(selectedIds);
|
||||
const handleBatchLogin = () => startBatch(selectedIds, 'login');
|
||||
const handleBatchCheck = () => startBatch(selectedIds, 'check');
|
||||
|
||||
// 重试当前批次所有失败的任务
|
||||
const handleRetryFailed = () => {
|
||||
@@ -189,14 +206,14 @@ export default function LoginTasksPage() {
|
||||
message.info('没有失败的任务');
|
||||
return;
|
||||
}
|
||||
startBatch(failedIds);
|
||||
startBatch(failedIds, 'login');
|
||||
};
|
||||
|
||||
// 重试单个失败任务
|
||||
const handleRetryOne = (taskId: number) => {
|
||||
const task = tasks.find((t) => t.id === taskId);
|
||||
if (!task) return;
|
||||
startBatch([task.account_id]);
|
||||
startBatch([task.account_id], 'login');
|
||||
};
|
||||
|
||||
const handleStop = async () => {
|
||||
@@ -238,6 +255,13 @@ export default function LoginTasksPage() {
|
||||
|
||||
const successCount = tasks.filter((t) => t.status === 'success').length;
|
||||
const failedCount = tasks.filter((t) => ['failed', 'error'].includes(t.status)).length;
|
||||
const checkedCount = tasks.filter((t) => [
|
||||
'account_cancelled',
|
||||
'password_wrong',
|
||||
'account_unverified',
|
||||
'account_verified',
|
||||
'account_auth_unknown',
|
||||
].includes(t.status)).length;
|
||||
|
||||
const columns = [
|
||||
{ title: 'ID', dataIndex: 'id', width: 60 },
|
||||
@@ -354,6 +378,15 @@ export default function LoginTasksPage() {
|
||||
size="small"
|
||||
/>
|
||||
</Tooltip>
|
||||
<Button
|
||||
icon={<SafetyCertificateOutlined />}
|
||||
loading={loading}
|
||||
onClick={handleBatchCheck}
|
||||
disabled={selectedIds.length === 0 || starting}
|
||||
size="small"
|
||||
>
|
||||
检测账号
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<PlayCircleOutlined />}
|
||||
@@ -380,6 +413,7 @@ export default function LoginTasksPage() {
|
||||
<span>共 <b>{tasks.length}</b> 个任务</span>
|
||||
<span>成功 <b style={{ color: token.colorSuccess }}>{successCount}</b></span>
|
||||
<span>失败 <b style={{ color: token.colorError }}>{failedCount}</b></span>
|
||||
{checkedCount > 0 && <span>检测 <b>{checkedCount}</b></span>}
|
||||
{batchId && <span>批次: <b>{batchId}</b></span>}
|
||||
<div style={{ flex: 1 }} />
|
||||
{selectedRowKeys.length > 0 && (
|
||||
|
||||
Reference in New Issue
Block a user