diff --git a/src/permission.ts b/src/permission.ts index dfd774d7..8201e1d6 100644 --- a/src/permission.ts +++ b/src/permission.ts @@ -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()