From da25804a060646349b3acb8065c67c9ef10747f7 Mon Sep 17 00:00:00 2001 From: Lixi20 Date: Fri, 4 Sep 2026 12:17:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=99=BB=E5=BD=95=E9=A1=B5=E8=A1=A5?= =?UTF-8?q?=E5=85=85=2042300=20=E8=B4=A6=E5=8F=B7=E9=94=81=E5=AE=9A?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=A0=81=E6=98=A0=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 对齐后端 T4 新增的登录锁定契约(openapi.yaml),锁定时展示明确横幅而非通用兜底 - 门禁:format 0 changed / analyze 0 issues / flutter test 30 passed --- lib/core/network/api_exception.dart | 3 +++ lib/features/auth/login_page.dart | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/core/network/api_exception.dart b/lib/core/network/api_exception.dart index 3e3604e..de6fe78 100644 --- a/lib/core/network/api_exception.dart +++ b/lib/core/network/api_exception.dart @@ -19,6 +19,9 @@ abstract final class ApiCodes { /// 手机号重复。 static const phoneTaken = 40901; + + /// 登录失败次数过多,账号临时锁定(HTTP 423,见 openapi.yaml)。 + static const loginLocked = 42300; } /// API 调用的类型化异常。页面按类型映射为三层错误呈现 diff --git a/lib/features/auth/login_page.dart b/lib/features/auth/login_page.dart index a1b89e3..cb1e623 100644 --- a/lib/features/auth/login_page.dart +++ b/lib/features/auth/login_page.dart @@ -110,9 +110,11 @@ class _LoginPageState extends State { // 认证状态机随 saveSession 切换,根路由 300ms fade 进主壳。 } on ApiBusinessException catch (error) { if (!mounted) return; - _showFormError( - error.code == ApiCodes.badCredentials ? '用户名或密码错误' : '登录失败,请稍后重试', - ); + _showFormError(switch (error.code) { + ApiCodes.badCredentials => '用户名或密码错误', + ApiCodes.loginLocked => '尝试次数过多,账号已临时锁定,请稍后再试', + _ => '登录失败,请稍后重试', + }); } on ApiRateLimitException { if (!mounted) return; _showFormError('尝试次数过多,请稍后再试');