Skip to content

Commit

Permalink
三级菜单自动配置组件
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzongzhuan committed Nov 28, 2020
1 parent b199db3 commit 20f85a3
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public class UserConstants
/** Layout组件标识 */
public final static String LAYOUT = "Layout";

/** ParentView组件标识 */
public final static String PARENT_VIEW = "ParentView";

/** 校验返回结果码 */
public final static String UNIQUE = "0";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ public String getComponent(SysMenu menu)
{
component = menu.getComponent();
}
else if (StringUtils.isEmpty(menu.getComponent()) && isParentView(menu))
{
component = UserConstants.PARENT_VIEW;
}
return component;
}

Expand All @@ -379,6 +383,17 @@ public boolean isMeunFrame(SysMenu menu)
&& menu.getIsFrame().equals(UserConstants.NO_FRAME);
}

/**
* 是否为parent_view组件
*
* @param menu 菜单信息
* @return 结果
*/
public boolean isParentView(SysMenu menu)
{
return menu.getParentId().intValue() != 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType());
}

/**
* 根据父节点的ID获取所有子节点
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<template >
<router-view />
</template>
<template >
<router-view />
</template>
1 change: 1 addition & 0 deletions ruoyi-ui/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Vue.use(Router)

/* Layout */
import Layout from '@/layout'
import ParentView from '@/components/ParentView';

/**
* Note: 路由配置项
Expand Down
5 changes: 4 additions & 1 deletion ruoyi-ui/src/store/modules/permission.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { constantRoutes } from '@/router'
import { getRouters } from '@/api/menu'
import Layout from '@/layout/index'
import ParentView from '@/components/ParentView';

const permission = {
state: {
Expand Down Expand Up @@ -33,9 +34,11 @@ const permission = {
function filterAsyncRouter(asyncRouterMap) {
return asyncRouterMap.filter(route => {
if (route.component) {
// Layout组件特殊处理
// Layout ParentView 组件特殊处理
if (route.component === 'Layout') {
route.component = Layout
} else if (route.component === 'ParentView') {
route.component = ParentView
} else {
route.component = loadView(route.component)
}
Expand Down
2 changes: 1 addition & 1 deletion sql/ry_20200924.sql → sql/ry_20201128.sql
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ insert into sys_menu values('104', '岗位管理', '1', '5', 'post',
insert into sys_menu values('105', '字典管理', '1', '6', 'dict', 'system/dict/index', 1, 0, 'C', '0', '0', 'system:dict:list', 'dict', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '字典管理菜单');
insert into sys_menu values('106', '参数设置', '1', '7', 'config', 'system/config/index', 1, 0, 'C', '0', '0', 'system:config:list', 'edit', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '参数设置菜单');
insert into sys_menu values('107', '通知公告', '1', '9', 'notice', 'system/notice/index', 1, 0, 'C', '0', '0', 'system:notice:list', 'message', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '通知公告菜单');
insert into sys_menu values('108', '日志管理', '1', '10', 'log', 'system/log/index', 1, 0, 'M', '0', '0', '', 'log', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '日志管理菜单');
insert into sys_menu values('108', '日志管理', '1', '10', 'log', '', 1, 0, 'M', '0', '0', '', 'log', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '日志管理菜单');
insert into sys_menu values('109', '在线用户', '2', '1', 'online', 'monitor/online/index', 1, 0, 'C', '0', '0', 'monitor:online:list', 'online', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '在线用户菜单');
insert into sys_menu values('110', '定时任务', '2', '2', 'job', 'monitor/job/index', 1, 0, 'C', '0', '0', 'monitor:job:list', 'job', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '定时任务菜单');
insert into sys_menu values('111', 'Sentinel控制台', '2', '3', 'http://localhost:8718', '', 1, 0, 'C', '0', '0', 'monitor:sentinel:list', 'sentinel', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '流量控制菜单');
Expand Down

0 comments on commit 20f85a3

Please sign in to comment.