修复864二维码返回结构兼容
- 兼容 GetLoginQrCodeNew 返回 QrCodeUrl 的实际结构 - 从二维码图片地址的 data 参数中反解 weixin 扫码链接与 uuid,保障 Dashboard 可正确展示 864 登录二维码
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import qrcode
|
||||
from urllib.parse import parse_qs, urlparse
|
||||
|
||||
from wechat_ipad.providers.server_864.base import Server864APIClientBase
|
||||
|
||||
@@ -31,12 +32,24 @@ class LoginMixin(Server864APIClientBase):
|
||||
json_body={"Proxy": proxy_value, "Check": False},
|
||||
timeout=30,
|
||||
)
|
||||
uuid = self._pick_first(data, "UUID", "Uuid", "uuid") or ""
|
||||
qr_url = (
|
||||
self._pick_first(data, "QrUrl", "QRUrl", "qrUrl")
|
||||
qr_code_url = (
|
||||
self._pick_first(data, "QrCodeUrl", "QRCodeUrl", "qrCodeUrl")
|
||||
or self._pick_first(data, "QrUrl", "QRUrl", "qrUrl")
|
||||
or self._pick_first(self._pick_first(data, "Qrcode", "QrCode", "qrcode") or {}, "Src", "src")
|
||||
or ""
|
||||
)
|
||||
uuid = self._pick_first(data, "UUID", "Uuid", "uuid") or ""
|
||||
if not uuid and qr_code_url:
|
||||
# 864 当前真实返回的是“二维码图片服务地址”,
|
||||
# 其中真正的扫码链接藏在 `data=http://weixin.qq.com/x/<uuid>` 这个 query 里:
|
||||
# 1. Dashboard 需要 uuid 才能稳定生成扫码地址与展示文案;
|
||||
# 2. 因此这里把 query 中的真实扫码链接反解出来,兼容当前 server 的返回格式;
|
||||
# 3. 若未来某些 864 版本直接返回 UUID,本逻辑仍会优先使用原始字段,不会互相冲突。
|
||||
parsed_qs = parse_qs(urlparse(str(qr_code_url)).query)
|
||||
scan_data = str((parsed_qs.get("data") or [""])[0] or "")
|
||||
if "/x/" in scan_data:
|
||||
uuid = scan_data.rsplit("/x/", 1)[-1].strip()
|
||||
qr_url = str(qr_code_url)
|
||||
|
||||
if print_qr and uuid:
|
||||
qr = qrcode.QRCode(
|
||||
|
||||
Reference in New Issue
Block a user