feat: add task cancellation support
- Add CancelTask function to cancel running/waiting tasks - Add /api/cancelTask endpoint - Add cancel button in task list for running/waiting tasks - Check cancellation status during download and merge operations Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -170,3 +170,17 @@ func deleteTask(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
util.Res{Success: true, Message: "删除成功"}.Write(w)
|
||||
}
|
||||
|
||||
func cancelTask(w http.ResponseWriter, r *http.Request) {
|
||||
taskIDStr := r.FormValue("id")
|
||||
taskID, err := strconv.ParseInt(taskIDStr, 10, 64)
|
||||
if err != nil {
|
||||
util.Res{Success: false, Message: "参数错误"}.Write(w)
|
||||
return
|
||||
}
|
||||
if task.CancelTask(taskID) {
|
||||
util.Res{Success: true, Message: "任务已取消"}.Write(w)
|
||||
} else {
|
||||
util.Res{Success: false, Message: "任务不存在或已完成"}.Write(w)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user