This commit is contained in:
@@ -104,12 +104,35 @@ class StorageCompatibilityManager {
|
||||
return location.href.includes(RoutesAlias.Login)
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查当前是否处于免登录页面
|
||||
*/
|
||||
private isOnPublicPage(): boolean {
|
||||
if (this.isOnLoginPage()) return true
|
||||
|
||||
const route = router.currentRoute.value
|
||||
if (route?.meta?.noLogin) return true
|
||||
|
||||
// 兜底:初始导航可能尚未完成,按地址判断免登录路由
|
||||
const hashPath = location.hash.replace(/^#/, '').split('?')[0]
|
||||
const pathName = location.pathname.split('?')[0]
|
||||
return router.getRoutes().some((record) => {
|
||||
if (!record.meta?.noLogin) return false
|
||||
return (
|
||||
hashPath === record.path ||
|
||||
hashPath.startsWith(`${record.path}/`) ||
|
||||
pathName === record.path ||
|
||||
pathName.startsWith(`${record.path}/`)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证存储数据完整性
|
||||
*/
|
||||
validateStorageData(): boolean {
|
||||
// 如果在登录页面,跳过验证
|
||||
if (this.isOnLoginPage()) {
|
||||
// 如果在登录页或免登录页,跳过验证
|
||||
if (this.isOnPublicPage()) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user