添加后端重连后剔除ws功能
This commit is contained in:
@@ -71,6 +71,10 @@ class WebSocketManager:
|
||||
def connect_backend(self, token: str) -> bool:
|
||||
"""连接后端WebSocket"""
|
||||
try:
|
||||
# 🔥 重置清理标记,准备下次重连检测
|
||||
if hasattr(self, '_cleared'):
|
||||
delattr(self, '_cleared')
|
||||
|
||||
# 1 保存token到配置
|
||||
try:
|
||||
from config import set_saved_token
|
||||
@@ -143,6 +147,13 @@ class WebSocketManager:
|
||||
def _handle_platform_login(self, platform_name: str, store_id: str, cookies: str):
|
||||
"""处理平台登录请求"""
|
||||
try:
|
||||
# 🔥 检查并清理旧连接(重连后首次登录时)
|
||||
if not hasattr(self, '_cleared') and self.platform_listeners:
|
||||
self._log(f"🔄 检测到后端重连后首次登录,清理 {len(self.platform_listeners)} 个旧连接", "INFO")
|
||||
self.platform_listeners.clear()
|
||||
self.connected_platforms.clear()
|
||||
self._cleared = True
|
||||
|
||||
# 平台名称映射
|
||||
platform_map = {
|
||||
"淘宝": "千牛",
|
||||
|
||||
Reference in New Issue
Block a user