mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-02-05 08:13:22 +08:00
feat: 添加退出登录, 优化闪跳
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user