feat: Cookie管理页面增加批量删除功能
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import api from './client';
|
||||
import type { CookieItem, MessageResponse } from './types';
|
||||
import type { CookieItem, MessageDeletedResponse, MessageResponse } from './types';
|
||||
|
||||
export const cookieApi = {
|
||||
list: () => api.get<CookieItem[], CookieItem[]>('/cookies'),
|
||||
exportCsv: (format?: string) => api.get<Blob, Blob>('/cookies/export', { responseType: 'blob', params: format ? { format } : {} }),
|
||||
delete: (id: number) => api.delete<MessageResponse, MessageResponse>(`/cookies/${id}`),
|
||||
deleteBatch: (ids: number[]) => api.delete<MessageDeletedResponse, MessageDeletedResponse>('/cookies/batch', { params: { task_ids: ids.join(',') } }),
|
||||
};
|
||||
|
||||
@@ -118,6 +118,22 @@ export default function CookiePage() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteSelected = async () => {
|
||||
if (selectedRowKeys.length === 0) {
|
||||
message.warning('请先选择要删除的 Cookie');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const ids = selectedRowKeys.map((k) => Number(k));
|
||||
const res = await cookieApi.deleteBatch(ids);
|
||||
message.success(res.message);
|
||||
setSelectedRowKeys([]);
|
||||
loadCookies();
|
||||
} catch (e: unknown) {
|
||||
message.error(getErrorMessage(e));
|
||||
}
|
||||
};
|
||||
|
||||
// 筛选
|
||||
const filteredCookies = cookies.filter((c) => {
|
||||
if (!searchText) return true;
|
||||
@@ -199,6 +215,21 @@ export default function CookiePage() {
|
||||
>
|
||||
复制选中 {selectedRowKeys.length > 0 && `(${selectedRowKeys.length})`}
|
||||
</Button>
|
||||
{canExport && (
|
||||
<Popconfirm
|
||||
title={`确认删除选中的 ${selectedRowKeys.length} 条 Cookie?`}
|
||||
onConfirm={handleDeleteSelected}
|
||||
disabled={selectedRowKeys.length === 0}
|
||||
>
|
||||
<Button
|
||||
danger
|
||||
icon={<DeleteOutlined />}
|
||||
disabled={selectedRowKeys.length === 0}
|
||||
>
|
||||
删除选中 {selectedRowKeys.length > 0 && `(${selectedRowKeys.length})`}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
)}
|
||||
{canExport && (
|
||||
<Dropdown
|
||||
menu={{
|
||||
|
||||
Reference in New Issue
Block a user