1. 将 jwxt() 移动到 njupt_api 下,实现根据设置选择教务系统登录方式。
2. 将 api_router.py 和 mcp_router.py 中的对 ZhengFang() 的调用全部替换为对 jwxt() 的调用。
This commit is contained in:
2026-04-21 17:42:59 +08:00
parent b284c3c260
commit 16bd8e9f9a
9 changed files with 88 additions and 51 deletions

View File

@@ -1,5 +1,7 @@
from njupt_api.baselib import PlayContextManager, logger
from .exc import LoginError
class SSO(PlayContextManager):
def __init__(self) -> None:
@@ -14,6 +16,9 @@ class SSO(PlayContextManager):
Returns:
bool表明判登录是否成功。
Raises:
LoginError: 登录失败,暂时不包含任何提示信息……
"""
await self.page.goto("http://i.njupt.edu.cn/")
@@ -24,7 +29,7 @@ class SSO(PlayContextManager):
await self.page.wait_for_load_state("networkidle")
if "user-login" in self.page.url:
logger.error(f"{username} | 登录失败,请检查学号和密码是否正确。")
return False
raise LoginError("unknown")
logger.info(f"{username} | 登录南邮统一身份认证成功。")
self.isLogin = True