Merge pull request #102 from zhangshican/v2.0

修复添加菜单填写了重定向,然后菜单类型为“菜单” 会执行重定向
This commit is contained in:
孟帅 2024-05-15 12:05:41 +08:00 committed by GitHub
commit e672f54fbb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -36,12 +36,16 @@ export const routerGenerator = (routerMap, parent?): any[] => {
// 为了防止出现后端返回结果不规范,处理有可能出现拼接出两个 反斜杠
currentRouter.path = currentRouter.path.replace('//', '/');
// 重定向
item.redirect && (currentRouter.redirect = item.redirect);
// 重定向 ,菜单类型为目录默认默认跳转
if(item.meta.type === 1){
item.redirect && (currentRouter.redirect = item.redirect);
}
// 是否有子菜单,并递归处理
if (item.children && item.children.length > 0) {
//如果未定义 redirect 默认第一个子路由为 redirect
!item.redirect && (currentRouter.redirect = `${item.path}/${item.children[0].path}`);
if(item.meta.type === 1) {
!item.redirect && (currentRouter.redirect = `${item.path}/${item.children[0].path}`);
}
// Recursion
currentRouter.children = routerGenerator(item.children, currentRouter);
}