Commit c621e773 by chenwq1

fix:跳转登录

1 parent 7f89579c
Pipeline #165 for c621e773 failed in 0 seconds
......@@ -84,6 +84,24 @@ function buildLoginUrlWithHostContext(): string {
return `${next.pathname}${next.search}`;
}
function getLoginRouteQueryFromCurrentUrl(): { openType?: string } {
const url = new URL(window.location.href);
const openType = url.searchParams.get("openType");
return openType ? { openType } : {};
}
async function navigateToLogin() {
try {
const { default: router } = await import("@/router");
await router.replace({
path: "/login",
query: getLoginRouteQueryFromCurrentUrl(),
});
} catch {
window.location.replace(buildLoginUrlWithHostContext());
}
}
function redirectToLogin(message?: string) {
if (isRedirectingToLogin) {
return;
......@@ -91,7 +109,7 @@ function redirectToLogin(message?: string) {
isRedirectingToLogin = true;
showToast(message || "登录已过期,请重新登录");
localStorage.removeItem(TOKEN_KEY);
window.location.replace(buildLoginUrlWithHostContext());
void navigateToLogin();
}
let axiosInstance: AxiosInstance | null = null;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!