Add task list page for Video Learning sessions
This commit adds a dedicated task list page to view and manage all video learning sessions, solving the issue where users couldn't find their background tasks after navigating away. Features: - New sessions.html page with card-based layout for all sessions - Real-time polling for session status updates (every 3 seconds) - Session control buttons (pause/resume/stop/delete) - localStorage integration for session persistence across page refreshes - Navigation links added to main page and video learning page - Empty state UI when no sessions exist New files: - dashboard/static/sessions.html - Task list page - dashboard/static/js/sessions.js - Sessions module with API calls - dashboard/static/css/sessions.css - Styling for sessions page Modified files: - dashboard/api/video_learning.py - Added /sessions/list endpoint - dashboard/static/index.html - Added "任务列表" button - dashboard/static/video-learning.html - Added "任务列表" button and localStorage Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -351,6 +351,29 @@ async def list_sessions() -> List[str]:
|
||||
return list(_active_sessions.keys())
|
||||
|
||||
|
||||
@router.get("/sessions/list")
|
||||
async def list_all_sessions() -> List[Dict[str, Any]]:
|
||||
"""获取所有会话的详细信息(包含进度、状态等)"""
|
||||
result = []
|
||||
for session_id, agent in _active_sessions.items():
|
||||
try:
|
||||
progress = agent.get_session_progress()
|
||||
result.append({
|
||||
"session_id": session_id,
|
||||
"platform": progress.get("platform", ""),
|
||||
"target_count": progress.get("target_count", 0),
|
||||
"watched_count": progress.get("watched_count", 0),
|
||||
"progress_percent": progress.get("progress_percent", 0),
|
||||
"is_active": progress.get("is_active", False),
|
||||
"is_paused": progress.get("is_paused", False),
|
||||
"total_duration": progress.get("total_duration", 0),
|
||||
})
|
||||
except Exception as e:
|
||||
# 跳过出错的会话
|
||||
continue
|
||||
return result
|
||||
|
||||
|
||||
@router.delete("/sessions/{session_id}", response_model=Dict[str, str])
|
||||
async def delete_session(session_id: str) -> Dict[str, str]:
|
||||
"""Delete a session and clean up device mapping."""
|
||||
|
||||
Reference in New Issue
Block a user