diff --git a/apps/admin/src/utils/common.ts b/apps/admin/src/utils/common.ts index e20c19f..7b4960c 100644 --- a/apps/admin/src/utils/common.ts +++ b/apps/admin/src/utils/common.ts @@ -59,9 +59,18 @@ export function setRedirectUrl(value?: string) { export function Logout() { if (!isBrowser()) return; removeCookie("Authorization"); + const pathname = location.pathname; + const hash = location.hash.slice(1); + if (!["", "/"].includes(pathname)) { - setRedirectUrl(location.pathname); + setRedirectUrl(pathname); + location.href = "/"; + return; + } + + if (hash && !["", "/"].includes(hash)) { + setRedirectUrl(hash); location.href = "/"; } } diff --git a/apps/user/src/utils/common.ts b/apps/user/src/utils/common.ts index 2c07e45..cfe0b79 100644 --- a/apps/user/src/utils/common.ts +++ b/apps/user/src/utils/common.ts @@ -46,7 +46,10 @@ export function setRedirectUrl(value?: string) { export function Logout() { if (!isBrowser()) return; removeCookie("Authorization"); + const pathname = location.pathname; + const hash = location.hash.slice(1); // 移除 '#' + if ( !( ["", "/", "/auth", "/tos", "/privacy-policy"].includes(pathname) || @@ -54,7 +57,20 @@ export function Logout() { pathname.startsWith("/oauth/") ) ) { - setRedirectUrl(location.pathname); + setRedirectUrl(pathname); + location.href = "/#/auth"; + return; + } + + if ( + hash && + !( + ["", "/", "/auth", "/tos", "/privacy-policy"].includes(hash) || + hash.startsWith("/purchasing") || + hash.startsWith("/oauth/") + ) + ) { + setRedirectUrl(hash); location.href = "/#/auth"; } }