From 85b49d7e502a583994368edfc5449e769c669b70 Mon Sep 17 00:00:00 2001 From: sion <450702724@qq.com> Date: Wed, 1 Apr 2026 13:01:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=90=8E=E9=9C=80=E8=A6=81=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 业务层未授权响应不再自动清除用户数据 - 只有 HTTP 401 错误才会触发登出 - 避免误判导致登录状态丢失 --- flutter_monisuo/lib/core/network/dio_client.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/flutter_monisuo/lib/core/network/dio_client.dart b/flutter_monisuo/lib/core/network/dio_client.dart index 2bc8b89..225de44 100644 --- a/flutter_monisuo/lib/core/network/dio_client.dart +++ b/flutter_monisuo/lib/core/network/dio_client.dart @@ -97,9 +97,12 @@ class DioClient { if (data is Map) { final apiResponse = ApiResponse.fromJson(data, fromJson); // 检测业务层未授权(后端返回 HTTP 200 + code "0002") + // 注意:不再自动清除用户数据,避免误判 + // 只有在 HTTP 401 时才清除用户数据 if (apiResponse.isUnauthorized) { - LocalStorage.clearUserData(); - onUnauthorized?.call(); + debugPrint('业务层未授权响应: ${apiResponse.message}'); + // 不再自动调用 onUnauthorized,避免刷新时误判 + // onUnauthorized?.call(); } return apiResponse; }