fix: 修复刷新页面后需要重新登录的问题
- 业务层未授权响应不再自动清除用户数据 - 只有 HTTP 401 错误才会触发登出 - 避免误判导致登录状态丢失
This commit is contained in:
@@ -97,9 +97,12 @@ class DioClient {
|
||||
if (data is Map<String, dynamic>) {
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user