feat: 添加退出登录, 优化闪跳

This commit is contained in:
Gavan
2025-07-22 15:06:39 +08:00
parent 472ad769a9
commit 7c33568da2
13 changed files with 234 additions and 33 deletions

View File

@@ -58,6 +58,9 @@ export enum ContentType {
Text = "text/plain",
}
const whitePathnameList = ["/user/login", "/login"];
const whiteApiList = ["/api/v1/user/profile", "/api/v1/admin/profile"];
const redirectToLogin = () => {
const redirectAfterLogin = encodeURIComponent(location.href);
const search = `redirect=${redirectAfterLogin}`;
@@ -101,6 +104,9 @@ export class HttpClient<SecurityDataType = unknown> {
},
(err) => {
if (err?.response?.status === 401) {
if (whitePathnameList.includes(location.pathname)) {
return;
}
Message.error("尚未登录");
redirectToLogin();
return;