支持864登录二维码切换与退出重登
This commit is contained in:
@@ -105,7 +105,19 @@ class LoginMixin(Server864APIClientBase):
|
||||
normalized_login_qr_api = str(login_qr_api or "new_x").strip().lower()
|
||||
normalized_login_way = self._normalize_login_way(login_way)
|
||||
|
||||
if normalized_login_qr_api in {"new_x", "x", "newx"}:
|
||||
if normalized_login_qr_api in {"harmony_api", "harmony", "harmony_login_api"}:
|
||||
# `HarmonyLoginApi` 是 864 服务端单独暴露的一条鸿蒙二维码链路:
|
||||
# 1. 用户当前希望在 Dashboard 上显式切换“鸿蒙专用二维码”和“标准 New 二维码”;
|
||||
# 2. 该接口的请求模型与 `GetLoginQrCodeNew` 一致,仍然只需要 `Proxy/Check`;
|
||||
# 3. 因此这里单独加一个模式键,不去复用 `new_x + way=harmony`,避免两条链路在运维上混淆。
|
||||
data = await self._request_data(
|
||||
"post",
|
||||
"/login/HarmonyLoginApi",
|
||||
json_body={"Proxy": proxy_value, "Check": False},
|
||||
timeout=30,
|
||||
)
|
||||
uuid, qr_url = self._extract_qr_response(data)
|
||||
elif normalized_login_qr_api in {"new_x", "x", "newx"}:
|
||||
try:
|
||||
# NewX 是当前 864 联调里更完整的一条登录链路:
|
||||
# 1. 它支持 `Way` 指定登录端形态,兼容更多 server 变体;
|
||||
@@ -126,6 +138,14 @@ class LoginMixin(Server864APIClientBase):
|
||||
timeout=30,
|
||||
)
|
||||
uuid, qr_url = self._extract_qr_response(data)
|
||||
elif normalized_login_qr_api in {"new", "legacy_new"}:
|
||||
data = await self._request_data(
|
||||
"post",
|
||||
"/login/GetLoginQrCodeNew",
|
||||
json_body={"Proxy": proxy_value, "Check": False},
|
||||
timeout=30,
|
||||
)
|
||||
uuid, qr_url = self._extract_qr_response(data)
|
||||
else:
|
||||
data = await self._request_data(
|
||||
"post",
|
||||
@@ -211,5 +231,12 @@ class LoginMixin(Server864APIClientBase):
|
||||
|
||||
async def log_out(self) -> bool:
|
||||
"""退出当前 864 登录态。"""
|
||||
await self._request_data("get", "/login/LogOutRequest", timeout=15)
|
||||
try:
|
||||
# 不同 864 版本里退出接口命名存在差异:
|
||||
# 1. 当前项目早期接的是 `/login/LogOutRequest`;
|
||||
# 2. 用户本地 864 源码中实际注册的是 `/login/LogOut`;
|
||||
# 3. 因此这里优先尝试较新的 `/LogOut`,失败后再回退到旧路径,降低版本切换成本。
|
||||
await self._request_data("get", "/login/LogOut", timeout=15)
|
||||
except Exception:
|
||||
await self._request_data("get", "/login/LogOutRequest", timeout=15)
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user