feat(task): add batch delete and cancel API support
支持批量删除和取消任务的接口: - deleteTask 接口支持 POST 方式传入 ids 数组 - cancelTask 接口支持 POST 方式传入 ids 数组 - 前端批量操作改为调用批量接口,减少请求数量 Co-Authored-By: AI
This commit is contained in:
@@ -73,7 +73,27 @@ export const deleteTask = async (id: number) => {
|
||||
if (!res.success) throw new Error(res.message)
|
||||
}
|
||||
|
||||
/** 批量删除任务 */
|
||||
export const deleteTasks = async (ids: number[]) => {
|
||||
const res = await fetch('/api/deleteTask', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ ids })
|
||||
}).then(res => res.json()) as ResJSON
|
||||
if (!res.success) throw new Error(res.message)
|
||||
}
|
||||
|
||||
export const cancelTask = async (id: number) => {
|
||||
const res = await fetch(`/api/cancelTask?id=${id}`).then(res => res.json()) as ResJSON
|
||||
if (!res.success) throw new Error(res.message)
|
||||
}
|
||||
|
||||
/** 批量取消任务 */
|
||||
export const cancelTasks = async (ids: number[]) => {
|
||||
const res = await fetch('/api/cancelTask', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ ids })
|
||||
}).then(res => res.json()) as ResJSON
|
||||
if (!res.success) throw new Error(res.message)
|
||||
}
|
||||
Reference in New Issue
Block a user