fix(web): 审核回归 — 5 项修复 (渠道写入丢失/斗鱼WS生命周期/归属校验/恢复订阅/画像key稳定)
B1 routers/huya.py: 批量 Web 登录 login_channel/status 回填在 helper 内部 commit 之后赋值且未再提交 → 丢失; 补 db.commit() 并统一 status=active B2 routers/login.py + services/login_service.py: 斗鱼登录 WS 断线即 pop 批次, 刷新后无法重连订阅 → 对齐虎牙模式 (BatchRegistry.mark_finished, 仅结束后清理) B3 routers/login.py: WS 增加批次归属校验 (非 view_all 仅可订阅自建批次) S1 LoginTasksPage: effectiveBatchId 从任务列表推导活跃批次, 刷新后停止按钮/ 日志订阅自动恢复 S4 services/huya_service.py: username 仅在为空时回填, 防止 udb_passport 覆盖 登录名导致一号一设备绑定 key 漂移 验证: 77 后端单测 OK; tsc + vite build OK
This commit is contained in:
@@ -467,6 +467,8 @@ class LoginBatchRunner:
|
||||
self._push_log("info", f"批量{action_name}任务 {batch_id} 完成")
|
||||
self._push_log("result", "")
|
||||
finally:
|
||||
# 标记批次结束:WS 端据此决定何时清理注册表(断线重连可继续订阅日志)。
|
||||
batch_registry.mark_finished(batch_id)
|
||||
# 确保 DB Session 被关闭,避免连接泄漏
|
||||
self.db.close()
|
||||
|
||||
@@ -485,11 +487,24 @@ class BatchRegistry:
|
||||
"loop": loop,
|
||||
"runner": runner,
|
||||
"owner_id": owner_id,
|
||||
"finished": False,
|
||||
"finished_at": None,
|
||||
}
|
||||
|
||||
def get(self, batch_id: str):
|
||||
return self._batches.get(batch_id)
|
||||
|
||||
def mark_finished(self, batch_id: str):
|
||||
"""标记批次已结束(幂等;不在本注册表的批次为无操作)。
|
||||
|
||||
与虎牙批次一致:WS 端只在 finished 后 pop,客户端断线重连仍可订阅
|
||||
到运行中批次的实时日志。
|
||||
"""
|
||||
batch = self._batches.get(batch_id)
|
||||
if batch:
|
||||
batch["finished"] = True
|
||||
batch["finished_at"] = time.time()
|
||||
|
||||
def pop(self, batch_id: str):
|
||||
return self._batches.pop(batch_id, None)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user