From 0f49e500e35b8ee9d14d5af88d316f8ba253faeb Mon Sep 17 00:00:00 2001 From: Nixevol Date: Sun, 25 Oct 2026 07:11:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8F=AA=E6=9C=89=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=A4=B1=E6=95=88=E6=89=8D=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=B7=B2=E4=BF=9D=E5=AD=98=E5=87=AD=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/platform/sessions.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/backend/app/platform/sessions.py b/backend/app/platform/sessions.py index 7f482f6..e2727e1 100644 --- a/backend/app/platform/sessions.py +++ b/backend/app/platform/sessions.py @@ -7,7 +7,7 @@ from datetime import datetime import httpx -from app.platform.client import NqiClient, NqiError +from app.platform.client import NqiAuthError, NqiClient, NqiError from app.shared.paths import DATA_ROOT STORE = DATA_ROOT / "sessions.json" @@ -75,9 +75,9 @@ async def available_accounts() -> list[dict]: try: client.import_cookies(item.get("cookies") or []) user = await client.current_user() - except NqiError: + except NqiAuthError: continue - except (httpx.TimeoutException, httpx.RequestError): + except (NqiError, httpx.TimeoutException, httpx.RequestError, TimeoutError): kept.append(item) continue else: @@ -105,12 +105,15 @@ async def resume(login_id: str) -> tuple[NqiClient, dict]: try: client.import_cookies(matched.get("cookies") or []) user = await client.current_user() - except NqiError: + except NqiAuthError: await client.aclose() forget(login_id) - raise NqiError("这个账号的登录已失效") - except (httpx.TimeoutException, httpx.RequestError): + raise NqiError("这个账号的登录已失效") from None + except NqiError: await client.aclose() - raise NqiError("连接失败,请稍后重试") + raise + except (httpx.TimeoutException, httpx.RequestError, TimeoutError): + await client.aclose() + raise NqiError("连接失败,请稍后重试") from None remember(user, client.export_cookies()) return client, user