修复登录后首页入口跳转问题

This commit is contained in:
andy
2026-07-10 10:28:04 +08:00
parent 25efcccf72
commit 9de4f0e7b6
8 changed files with 132 additions and 20 deletions

View File

@@ -0,0 +1,27 @@
export const DEFAULT_AUTHENTICATED_ROUTE = '/reservation/orders'
export function normalizeAuthenticatedRoutePath(path: unknown): string | null {
if (typeof path !== 'string') {
return null
}
const trimmedPath = path.trim()
if (!trimmedPath.startsWith('/') || trimmedPath.startsWith('//')) {
return null
}
const [pathOnly = ''] = trimmedPath.split(/[?#]/, 1)
if (pathOnly === '/' || pathOnly.startsWith('/login')) {
return null
}
return trimmedPath
}
export function resolveAuthenticatedEntryPath(firstMenuPath: string | null | undefined): string {
return normalizeAuthenticatedRoutePath(firstMenuPath) ?? DEFAULT_AUTHENTICATED_ROUTE
}
export function resolveLoginRedirectPath(
redirect: unknown,
firstMenuPath: string | null | undefined,
): string {
return normalizeAuthenticatedRoutePath(redirect) ?? resolveAuthenticatedEntryPath(firstMenuPath)
}