fix: 浏览内容进度实时显示
This commit is contained in:
@@ -590,12 +590,28 @@ def run_task(user_id, account_id, browse_type, enable_screenshot=True, source="m
|
||||
|
||||
safe_update_task_status(account_id, {"detail_status": "正在浏览"})
|
||||
log_to_client(f"开始浏览 '{browse_type}' 内容...", user_id, account_id)
|
||||
account.total_items = 0
|
||||
safe_update_task_status(account_id, {"progress": {"items": 0, "attachments": 0}})
|
||||
|
||||
def should_stop():
|
||||
return account.should_stop
|
||||
|
||||
def on_browse_progress(progress: dict):
|
||||
try:
|
||||
total_items = int(progress.get("total_items") or 0)
|
||||
browsed_items = int(progress.get("browsed_items") or 0)
|
||||
if total_items > 0:
|
||||
account.total_items = total_items
|
||||
safe_update_task_status(account_id, {"progress": {"items": browsed_items, "attachments": 0}})
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
checkpoint_mgr.update_stage(task_id, TaskStage.BROWSING, progress_percent=50)
|
||||
result = api_browser.browse_content(browse_type=browse_type, should_stop_callback=should_stop)
|
||||
result = api_browser.browse_content(
|
||||
browse_type=browse_type,
|
||||
should_stop_callback=should_stop,
|
||||
progress_callback=on_browse_progress,
|
||||
)
|
||||
else:
|
||||
error_message = "登录失败"
|
||||
log_to_client(f"❌ {error_message}", user_id, account_id)
|
||||
|
||||
Reference in New Issue
Block a user