style:修改路由跳转首页逻辑

main
黄伟杰 3 weeks ago
parent a87f00633e
commit b071a40c2b

@ -67,7 +67,7 @@ const resolveFirstMenuPath = (routes: any[], parentPath = ''): string | undefine
const currentPath = parentPath ? resolveChildPath(parentPath, String(r.path ?? '')) : String(r.path ?? '')
const childPath = resolveFirstMenuPath(r.children, currentPath)
if (childPath) return childPath
if (currentPath && currentPath !== '/') return currentPath
if (currentPath) return currentPath
}
return undefined
}
@ -119,7 +119,12 @@ router.beforeEach(async (to, from, next) => {
next(nextData)
} else {
if (to.path === '/') {
next({ path: resolveFirstMenuPath(permissionStore.addRouters) ?? '/empty', replace: true })
const firstMenuPath = resolveFirstMenuPath(permissionStore.addRouters) ?? '/empty'
if (firstMenuPath === '/') {
next()
} else {
next({ path: firstMenuPath, replace: true })
}
return
}
next()

Loading…
Cancel
Save