update 优化 修改路由name命名规则

2.X
疯狂的狮子Li 7 months ago
parent 6924e54858
commit eaeaa7e859

@ -178,6 +178,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
/** /**
* *
* name path + id
* *
* @param menus * @param menus
* @return * @return
@ -186,9 +187,10 @@ public class SysMenuServiceImpl implements ISysMenuService {
public List<RouterVo> buildMenus(List<SysMenu> menus) { public List<RouterVo> buildMenus(List<SysMenu> menus) {
List<RouterVo> routers = new LinkedList<>(); List<RouterVo> routers = new LinkedList<>();
for (SysMenu menu : menus) { for (SysMenu menu : menus) {
String name = menu.getRouteName() + menu.getMenuId();
RouterVo router = new RouterVo(); RouterVo router = new RouterVo();
router.setHidden("1".equals(menu.getVisible())); router.setHidden("1".equals(menu.getVisible()));
router.setName(menu.getRouteName()); router.setName(name);
router.setPath(menu.getRouterPath()); router.setPath(menu.getRouterPath());
router.setComponent(menu.getComponentInfo()); router.setComponent(menu.getComponentInfo());
router.setQuery(menu.getQueryParam()); router.setQuery(menu.getQueryParam());
@ -199,12 +201,13 @@ public class SysMenuServiceImpl implements ISysMenuService {
router.setRedirect("noRedirect"); router.setRedirect("noRedirect");
router.setChildren(buildMenus(cMenus)); router.setChildren(buildMenus(cMenus));
} else if (menu.isMenuFrame()) { } else if (menu.isMenuFrame()) {
String frameName = StringUtils.capitalize(menu.getPath()) + menu.getMenuId();
router.setMeta(null); router.setMeta(null);
List<RouterVo> childrenList = new ArrayList<>(); List<RouterVo> childrenList = new ArrayList<>();
RouterVo children = new RouterVo(); RouterVo children = new RouterVo();
children.setPath(menu.getPath()); children.setPath(menu.getPath());
children.setComponent(menu.getComponent()); children.setComponent(menu.getComponent());
children.setName(StringUtils.capitalize(menu.getPath())); children.setName(frameName);
children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath())); children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
children.setQuery(menu.getQueryParam()); children.setQuery(menu.getQueryParam());
childrenList.add(children); childrenList.add(children);
@ -215,9 +218,10 @@ public class SysMenuServiceImpl implements ISysMenuService {
List<RouterVo> childrenList = new ArrayList<>(); List<RouterVo> childrenList = new ArrayList<>();
RouterVo children = new RouterVo(); RouterVo children = new RouterVo();
String routerPath = SysMenu.innerLinkReplaceEach(menu.getPath()); String routerPath = SysMenu.innerLinkReplaceEach(menu.getPath());
String innerLinkName = StringUtils.capitalize(routerPath) + menu.getMenuId();
children.setPath(routerPath); children.setPath(routerPath);
children.setComponent(UserConstants.INNER_LINK); children.setComponent(UserConstants.INNER_LINK);
children.setName(StringUtils.capitalize(routerPath)); children.setName(innerLinkName);
children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), menu.getPath())); children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), menu.getPath()));
childrenList.add(children); childrenList.add(children);
router.setChildren(childrenList); router.setChildren(childrenList);

Loading…
Cancel
Save