Merge main into dev: 登录导出/失败入流水 + AGENTS.md 修正
把 main 上的两笔带过来,dev 继续在其上开发: -d11fa10登录任务按状态导出 CSV + 登录失败写进账号生命周期 -05b2bf8AGENTS.md 分支约定修正 两条线在此之前无文件重叠(dev 38 个 / main 9 个,交集为空),所以是干净合并。 注意:main 的登录功能不含迁移,dev 的 0052 仍是唯一新增迁移。
This commit is contained in:
@@ -26,6 +26,20 @@ export const loginApi = {
|
||||
listTasksPaged: (params: { page: number; page_size: number; batch_id?: string; status?: string }) =>
|
||||
api.get<TaskPage, TaskPage>('/login/tasks', { params: { ...params, batch_id: params.batch_id ?? '' } }),
|
||||
tasksSummary: () => api.get<TaskSummary, TaskSummary>('/login/tasks/summary'),
|
||||
/**
|
||||
* 导出登录任务 CSV(按当前筛选,不分页)。
|
||||
*
|
||||
* `status` 传 'failed' 时后端会展开成 failed + error —— 页面上「失败」
|
||||
* 本来就是一个组,导出与列表口径必须一致。
|
||||
*/
|
||||
exportTasks: (params: { batch_id?: string; status?: string }) =>
|
||||
api.get<Blob, Blob>('/login/tasks/export', {
|
||||
responseType: 'blob',
|
||||
params: {
|
||||
batch_id: params.batch_id ?? '',
|
||||
status: params.status ?? '',
|
||||
},
|
||||
}),
|
||||
stop: (batch_id: string) => api.post<MessageResponse, MessageResponse>(`/login/stop/${batch_id}`),
|
||||
deleteTask: (id: number) => api.delete<MessageResponse, MessageResponse>(`/login/tasks/${id}`),
|
||||
deleteTasks: (ids: number[]) => api.delete<MessageDeletedResponse, MessageDeletedResponse>(`/login/tasks`, { params: { task_ids: ids.join(',') } }),
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { useEffect, useState, useMemo, useCallback, useRef } from 'react';
|
||||
import {
|
||||
Table, Button, Select, Tag, Space, InputNumber, Tooltip, Popconfirm, theme, Modal, Form,
|
||||
Table, Button, Select, Tag, Space, InputNumber, Tooltip, Popconfirm, theme, Modal, Form, Dropdown,
|
||||
} from 'antd';
|
||||
import { message } from '../utils/antdMessage';
|
||||
import {
|
||||
PlayCircleOutlined, StopOutlined, FilterOutlined, ReloadOutlined, DeleteOutlined,
|
||||
SettingOutlined, SafetyCertificateOutlined,
|
||||
SettingOutlined, SafetyCertificateOutlined, DownloadOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import { accountApi, loginApi, type AccountItem, type LoginTaskItem, type TaskSummary } from '../api/modules';
|
||||
import RealtimeLogPanel from '../components/RealtimeLogPanel';
|
||||
@@ -391,6 +391,34 @@ export default function LoginTasksPage() {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 导出登录任务 CSV。
|
||||
*
|
||||
* `status` 传 undefined 表示「当前筛选」—— 与列表看到的完全是同一批;
|
||||
* 传 'all' 表示不受筛选限制导出全部(后端把空串当不加条件)。
|
||||
* 导出的是**全部匹配记录**,不是当前页。
|
||||
*/
|
||||
const handleExport = async (scope: 'current' | 'all' | 'success' | 'failed') => {
|
||||
const status =
|
||||
scope === 'current' ? taskStatus : scope === 'all' ? '' : scope;
|
||||
try {
|
||||
const blob = await loginApi.exportTasks({
|
||||
batch_id: batchId || undefined,
|
||||
status,
|
||||
});
|
||||
const url = URL.createObjectURL(blob instanceof Blob ? blob : new Blob([blob]));
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
const label = scope === 'current' ? (taskStatus || 'all') : scope;
|
||||
a.download = `login_tasks_${label}.csv`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
message.success('已导出,可用 Excel 打开(已带 BOM,中文不乱码)');
|
||||
} catch (e: unknown) {
|
||||
message.error(getErrorMessage(e));
|
||||
}
|
||||
};
|
||||
|
||||
// 一键清空当前筛选下的失败任务(跨页,不用先翻完所有页去勾)
|
||||
const handleClearFailed = async () => {
|
||||
try {
|
||||
@@ -649,6 +677,21 @@ export default function LoginTasksPage() {
|
||||
{ value: 'running', label: '进行中' },
|
||||
]}
|
||||
/>
|
||||
<Dropdown
|
||||
menu={{
|
||||
items: [
|
||||
{ key: 'current', label: taskStatus ? '导出当前筛选' : '导出全部' },
|
||||
{ key: 'all', label: '导出全部(忽略筛选)' },
|
||||
{ key: 'success', label: '只导出成功' },
|
||||
{ key: 'failed', label: '只导出失败(含异常)' },
|
||||
],
|
||||
onClick: ({ key }) => void handleExport(key as 'current' | 'all' | 'success' | 'failed'),
|
||||
}}
|
||||
>
|
||||
<Button size="small" icon={<DownloadOutlined />}>
|
||||
导出 CSV
|
||||
</Button>
|
||||
</Dropdown>
|
||||
<div style={{ flex: 1 }} />
|
||||
{canBatch && (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user