This commit is contained in:
zlwu committed 2026-05-28 13:05:46 +08:00
1 parent f1f5d24eff
commit 3c7a47981a
138 files changed
+18654 -12092

No files matched your search

+19
View File
@@ -10,6 +10,10 @@ import AppConfig from '@/config'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import i18n, { $t } from '@/locales'
import { RoutesAlias } from '@/router/routesAlias'
/** 历史遗留登录路径(与 RoutesAlias.Login 等价) */
const LEGACY_LOGIN_PATHS = new Set([RoutesAlias.Login, '/login'])
/** 扩展的路由配置类型 */
export type AppRouteRecordRaw = RouteRecordRaw & {
@@ -59,3 +63,18 @@ export const formatMenuTitle = (title: string): string => {
}
return ''
}
/**
* 解析登录后的安全跳转地址,避免 redirect 指回登录页导致无法进入系统
*/
export function resolveSafeRedirectTarget(redirect: unknown, fallback = '/'): string {
const raw = typeof redirect === 'string' ? redirect.trim() : ''
if (!raw) return fallback
const pathOnly = raw.split('?')[0].split('#')[0]
const normalized = pathOnly.startsWith('/') ? pathOnly : `/${pathOnly}`
if (LEGACY_LOGIN_PATHS.has(normalized)) {
return fallback
}
return raw
}