mirror of
https://github.com/KwiTsukasa/kt-template-online-web.git
synced 2026-05-27 16:35:47 +08:00
fix(web): 修复后台登录回跳地址
This commit is contained in:
parent
fae5a9b99e
commit
99f5615144
@ -1,6 +1,6 @@
|
|||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
VITE_APP_PLAY_GROUND=http://localhost:48090
|
VITE_APP_PLAY_GROUND=http://localhost:48090
|
||||||
VITE_APP_PROXY=http://localhost:48085/
|
VITE_APP_PROXY=http://localhost:48085/
|
||||||
VITE_APP_ADMIN_LOGIN=http://localhost:5999/auth/login
|
VITE_APP_ADMIN_LOGIN=http://localhost:5999/#/auth/login
|
||||||
VITE_APP_BASE_API=/api
|
VITE_APP_BASE_API=/api
|
||||||
VITE_APP_OSS_DOMAIN=/chart-assets
|
VITE_APP_OSS_DOMAIN=/chart-assets
|
||||||
|
|||||||
@ -49,10 +49,24 @@ export const persistAuthData = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const redirectToAdminLogin = () => {
|
const buildAdminLoginUrl = (redirect: string) => {
|
||||||
const loginUrl = new URL(config.adminLogin);
|
const loginUrl = new URL(config.adminLogin);
|
||||||
loginUrl.searchParams.set("redirect", encodeURIComponent(window.location.href));
|
|
||||||
window.location.href = loginUrl.toString();
|
if (loginUrl.hash) {
|
||||||
|
const [hashPath, hashSearch = ""] = loginUrl.hash.slice(1).split("?");
|
||||||
|
const hashParams = new URLSearchParams(hashSearch);
|
||||||
|
hashParams.set("redirect", redirect);
|
||||||
|
// Admin 生产环境使用 hash 路由,redirect 必须放在 hash 内部才能被 Vue Router 读取。
|
||||||
|
loginUrl.hash = `${hashPath}?${hashParams.toString()}`;
|
||||||
|
return loginUrl.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
loginUrl.searchParams.set("redirect", redirect);
|
||||||
|
return loginUrl.toString();
|
||||||
|
};
|
||||||
|
|
||||||
|
export const redirectToAdminLogin = () => {
|
||||||
|
window.location.href = buildAdminLoginUrl(window.location.href);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const refreshPersistedAuth = async () => {
|
export const refreshPersistedAuth = async () => {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { os } from "@/utils/detect";
|
import { os } from "@/utils/detect";
|
||||||
|
|
||||||
const config = (() => ({
|
const config = (() => ({
|
||||||
adminLogin: import.meta.env.VITE_APP_ADMIN_LOGIN || `${window.location.protocol}//${window.location.hostname}:5999/auth/login`,
|
adminLogin: import.meta.env.VITE_APP_ADMIN_LOGIN || `${window.location.protocol}//${window.location.hostname}:5999/#/auth/login`,
|
||||||
isMobileApp: !os.desktop,
|
isMobileApp: !os.desktop,
|
||||||
axiosBase: "/api",
|
axiosBase: "/api",
|
||||||
playground: import.meta.env.VITE_APP_PLAY_GROUND,
|
playground: import.meta.env.VITE_APP_PLAY_GROUND,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user