Pre Merge pull request !150 from runphp/N/A
This commit is contained in:
commit
d9c381146a
|
|
@ -154,6 +154,6 @@ public class SysMenuController extends BaseController
|
|||
{
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
||||
return AjaxResult.success(menuService.buildMenus(menus));
|
||||
return AjaxResult.success(menuService.buildMenus(menus, null));
|
||||
}
|
||||
}
|
||||
|
|
@ -58,9 +58,10 @@ public interface ISysMenuService
|
|||
* 构建前端路由所需要的菜单
|
||||
*
|
||||
* @param menus 菜单列表
|
||||
* @param parentRouter 父级菜单
|
||||
* @return 路由列表
|
||||
*/
|
||||
public List<RouterVo> buildMenus(List<SysMenu> menus);
|
||||
public List<RouterVo> buildMenus(List<SysMenu> menus, RouterVo parentRouter);
|
||||
|
||||
/**
|
||||
* 构建前端所需要树结构
|
||||
|
|
|
|||
|
|
@ -138,32 +138,33 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|||
* 构建前端路由所需要的菜单
|
||||
*
|
||||
* @param menus 菜单列表
|
||||
* @param parentRouter 父级菜单
|
||||
* @return 路由列表
|
||||
*/
|
||||
@Override
|
||||
public List<RouterVo> buildMenus(List<SysMenu> menus)
|
||||
public List<RouterVo> buildMenus(List<SysMenu> menus, RouterVo parentRouter)
|
||||
{
|
||||
List<RouterVo> routers = new LinkedList<RouterVo>();
|
||||
List<RouterVo> routers = new LinkedList<>();
|
||||
for (SysMenu menu : menus)
|
||||
{
|
||||
RouterVo router = new RouterVo();
|
||||
router.setHidden("1".equals(menu.getVisible()));
|
||||
router.setName(getRouteName(menu));
|
||||
router.setName(StringUtils.isNull(parentRouter)?getRouteName(menu):parentRouter.getName()+"_"+getRouteName(menu));
|
||||
router.setPath(getRouterPath(menu));
|
||||
router.setComponent(getComponent(menu));
|
||||
router.setQuery(menu.getQuery());
|
||||
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
|
||||
List<SysMenu> cMenus = menu.getChildren();
|
||||
if (!cMenus.isEmpty() && cMenus.size() > 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType()))
|
||||
if (!cMenus.isEmpty() && UserConstants.TYPE_DIR.equals(menu.getMenuType()))
|
||||
{
|
||||
router.setAlwaysShow(true);
|
||||
router.setRedirect("noRedirect");
|
||||
router.setChildren(buildMenus(cMenus));
|
||||
router.setChildren(buildMenus(cMenus, router));
|
||||
}
|
||||
else if (isMenuFrame(menu))
|
||||
{
|
||||
router.setMeta(null);
|
||||
List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
||||
List<RouterVo> childrenList = new ArrayList<>();
|
||||
RouterVo children = new RouterVo();
|
||||
children.setPath(menu.getPath());
|
||||
children.setComponent(menu.getComponent());
|
||||
|
|
@ -177,7 +178,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|||
{
|
||||
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon()));
|
||||
router.setPath("/inner");
|
||||
List<RouterVo> childrenList = new ArrayList<RouterVo>();
|
||||
List<RouterVo> childrenList = new ArrayList<>();
|
||||
RouterVo children = new RouterVo();
|
||||
String routerPath = innerLinkReplaceEach(menu.getPath());
|
||||
children.setPath(routerPath);
|
||||
|
|
|
|||
Loading…
Reference in New Issue