修复添加账号后不实时显示的问题

添加账号成功后通过socket推送account_update事件,前端实时更新列表

🤖 Generated with Claude Code
This commit is contained in:
Yu Yon
2025-12-12 15:52:12 +08:00
parent 512380a80d
commit c793999f3c

5
app.py
View File

@@ -1771,6 +1771,10 @@ def add_account():
user_accounts[user_id][account_id] = account
log_to_client(f"添加账号: {username}", user_id)
# 通过socket实时推送新账号到前端
socketio.emit('account_update', account.to_dict(), room=f'user_{user_id}')
return jsonify(account.to_dict())
@@ -1952,6 +1956,7 @@ def run_task(user_id, account_id, browse_type, enable_screenshot=True, source="m
retry_count: 当前重试次数用于自动重试机制最多重试2次
"""
MAX_AUTO_RETRY = 2 # 最大自动重试次数
print(f"[DEBUG run_task] account={account_id}, enable_screenshot={enable_screenshot} (类型:{type(enable_screenshot).__name__}), source={source}, retry={retry_count}")
if user_id not in user_accounts or account_id not in user_accounts[user_id]:
return