实现下发需要验证码结构给后端

This commit is contained in:
jjz
2025-09-16 11:17:30 +08:00
parent faef5d2316
commit 256e6c21a5
3 changed files with 141 additions and 94 deletions

View File

@@ -874,9 +874,9 @@ class BackendClient:
data = message.get('data', {})
# 判断是拼多多登录参数还是普通Cookie
if platform_name == "拼多多" and content == "拼多多登录" and data.get('login_params'):
if platform_name == "拼多多" and ("拼多多登录" in content) and data.get('login_params'):
# 拼多多登录参数模式 - 传递完整的消息JSON给处理器
print(f"收到拼多多登录参数: 平台={platform_name}, 店铺={store_id}")
print(f"收到拼多多登录参数: 平台={platform_name}, 店铺={store_id}, 类型={content}")
if self.login_callback:
# 传递完整的JSON消息让拼多多处理器来解析login_params
import json

View File

@@ -359,6 +359,8 @@ class WebSocketManager:
# 详细的结果分析
if result == "need_verification_code":
self._log("✅ [PDD] 登录流程正常,已发送验证码需求通知给后端", "SUCCESS")
elif result == "verification_code_error":
self._log("⚠️ [PDD] 验证码错误,已发送错误通知给后端", "WARNING")
elif result:
self._log("✅ [PDD] 登录成功,平台连接已建立", "SUCCESS")
else:
@@ -371,13 +373,13 @@ class WebSocketManager:
self._log(f"📊 start_with_cookies 执行结果: {result}", "DEBUG")
# 根据实际登录结果上报状态给后端
if self.backend_client and result != "need_verification_code":
# 如果返回need_verification_code说明验证码通知已经在PddLogin中发送了不需要重复发送
if self.backend_client and result not in ["need_verification_code", "verification_code_error", "login_failure"]:
# 如果是特殊状态,说明通知已经在PddLogin中发送了不需要重复发送
try:
message = {
"type": "connect_message",
"store_id": store_id,
"status": bool(result) if result != "need_verification_code" else False
"status": bool(result)
}
self.backend_client.send_message(message)
status_text = "成功" if result else "失败"
@@ -386,6 +388,10 @@ class WebSocketManager:
self._log(f"上报拼多多平台连接状态失败: {send_e}", "ERROR")
elif result == "need_verification_code":
self._log("需要验证码验证码通知已由PddLogin发送等待后端重新下发登录参数", "INFO")
elif result == "verification_code_error":
self._log("验证码错误错误通知已由PddLogin发送等待后端处理", "INFO")
elif result == "login_failure":
self._log("登录失败失败通知已由PddLogin发送等待后端处理", "INFO")
return result