feat: add download button to Tables/Images views, add task history delete/clear-all
This commit is contained in:
@@ -112,6 +112,29 @@ async def get_task(
|
||||
return task
|
||||
|
||||
|
||||
@router.delete("/{task_id}")
|
||||
async def delete_task(
|
||||
task_id: str,
|
||||
current_user: dict = Depends(get_current_user),
|
||||
):
|
||||
"""Delete a single task by ID."""
|
||||
loop = asyncio.get_event_loop()
|
||||
deleted = await loop.run_in_executor(None, lambda: db_schema.delete_task(task_id))
|
||||
if not deleted:
|
||||
raise HTTPException(status_code=404, detail="任务不存在")
|
||||
return {"message": "已删除"}
|
||||
|
||||
|
||||
@router.delete("")
|
||||
async def clear_all_tasks(
|
||||
current_user: dict = Depends(get_current_user),
|
||||
):
|
||||
"""Clear all task history records."""
|
||||
loop = asyncio.get_event_loop()
|
||||
count = await loop.run_in_executor(None, db_schema.clear_task_history)
|
||||
return {"message": f"已清除 {count} 条记录", "count": count}
|
||||
|
||||
|
||||
@router.post("/{task_id}/retry")
|
||||
async def retry_task(
|
||||
task_id: str,
|
||||
|
||||
Reference in New Issue
Block a user