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 currentPath = parentPath ? resolveChildPath(parentPath, String(r.path ?? '')) : String(r.path ?? '')
const childPath = resolveFirstMenuPath(r.children, currentPath) const childPath = resolveFirstMenuPath(r.children, currentPath)
if (childPath) return childPath if (childPath) return childPath
if (currentPath && currentPath !== '/') return currentPath if (currentPath) return currentPath
} }
return undefined return undefined
} }
@ -119,7 +119,12 @@ router.beforeEach(async (to, from, next) => {
next(nextData) next(nextData)
} else { } else {
if (to.path === '/') { 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 return
} }
next() next()

Loading…
Cancel
Save