Skip to content

Let's use AI to Earn!

fix: 401问题完善

gaoSirf7d12d8c9e60
diff --git a/src/utils/request.ts b/src/utils/request.ts
index f602c054..4d07c6f8 100644
--- a/src/utils/request.ts
+++ b/src/utils/request.ts
@@ -57,15 +57,16 @@ export async function request<T>(params: RequestParamsWithSilent) {
contact: isZh ? "如需帮助请联系客服:" : "Need help? Contact support:",
};
+ // 未登录拦截
if (data.code === 401 && !useUserStore.getState().token) {
- // useUserStore.getState().logout();
- // message.error({
- // key: "NoPermission",
- // content: "登录状态过期,请重新登录",
- // });
return null;
}
+ // 已登录、但是登录过期
+ if (data.code === 401) {
+ useUserStore.getState().logout();
+ }
+
if (data.code !== 0) {
if (!params.silent && typeof window !== "undefined") {
message.warning({