mirror of
https://github.com/KwiTsukasa/kt-template-admin.git
synced 2026-05-27 16:35:47 +08:00
fix(admin): 修复开发环境登录回跳
This commit is contained in:
parent
ce95d93c2b
commit
51464d85d5
@ -2,6 +2,7 @@
|
|||||||
VITE_PORT=5999
|
VITE_PORT=5999
|
||||||
|
|
||||||
VITE_BASE=/
|
VITE_BASE=/
|
||||||
|
VITE_ROUTER_HISTORY=hash
|
||||||
|
|
||||||
# 接口地址
|
# 接口地址
|
||||||
VITE_GLOB_API_URL=/api
|
VITE_GLOB_API_URL=/api
|
||||||
|
|||||||
@ -28,7 +28,21 @@ function getRedirectQuery(queryRedirect?: string) {
|
|||||||
if (queryRedirect) return queryRedirect;
|
if (queryRedirect) return queryRedirect;
|
||||||
|
|
||||||
// 兼容旧链接 /auth/login?redirect=... 在 hash 路由下被放到 location.search 的情况。
|
// 兼容旧链接 /auth/login?redirect=... 在 hash 路由下被放到 location.search 的情况。
|
||||||
return new URLSearchParams(window.location.search).get('redirect') || '';
|
const searchRedirect = new URLSearchParams(window.location.search).get(
|
||||||
|
'redirect',
|
||||||
|
);
|
||||||
|
if (searchRedirect) return searchRedirect;
|
||||||
|
|
||||||
|
// Web/Playground 生产配置会跳 /#/auth/login?redirect=...;
|
||||||
|
// Admin 本地 history 模式下该 query 只存在于 location.hash。
|
||||||
|
const hashQueryIndex = window.location.hash.indexOf('?');
|
||||||
|
if (hashQueryIndex === -1) return '';
|
||||||
|
|
||||||
|
return (
|
||||||
|
new URLSearchParams(window.location.hash.slice(hashQueryIndex + 1)).get(
|
||||||
|
'redirect',
|
||||||
|
) || ''
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -38,9 +38,19 @@ export const useAuthStore = defineStore('auth', () => {
|
|||||||
if (routeRedirect) return routeRedirect;
|
if (routeRedirect) return routeRedirect;
|
||||||
|
|
||||||
// 兼容旧链接 /auth/login?redirect=... 在 hash 路由下被放到 location.search 的情况。
|
// 兼容旧链接 /auth/login?redirect=... 在 hash 路由下被放到 location.search 的情况。
|
||||||
return new URLSearchParams(window.location.search).get('redirect') as
|
const searchRedirect = new URLSearchParams(window.location.search).get(
|
||||||
| null
|
'redirect',
|
||||||
| string;
|
);
|
||||||
|
if (searchRedirect) return searchRedirect;
|
||||||
|
|
||||||
|
// Web/Playground 生产配置会跳 /#/auth/login?redirect=...;
|
||||||
|
// Admin 本地 history 模式下该 query 只存在于 location.hash。
|
||||||
|
const hashQueryIndex = window.location.hash.indexOf('?');
|
||||||
|
if (hashQueryIndex === -1) return null;
|
||||||
|
|
||||||
|
return new URLSearchParams(
|
||||||
|
window.location.hash.slice(hashQueryIndex + 1),
|
||||||
|
).get('redirect');
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildExternalAuthRedirectUrl(target: string) {
|
function buildExternalAuthRedirectUrl(target: string) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user