mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-11-12 21:53:48 +08:00
v1.1.0
This commit is contained in:
@@ -12,7 +12,8 @@ const { homeName } = config;
|
||||
|
||||
Vue.use(Router);
|
||||
const router = new Router({
|
||||
routes: routers
|
||||
// routes: routers,
|
||||
routes: buildRouters(routers)
|
||||
// mode: 'history'
|
||||
});
|
||||
const LOGIN_PAGE_NAME = 'login';
|
||||
@@ -102,12 +103,69 @@ router.afterEach(to => {
|
||||
window.scrollTo(0, 0);
|
||||
});
|
||||
|
||||
function buildRouters (routerArray) {
|
||||
let lineRouters = [];
|
||||
for (let routerItem of routerArray) {
|
||||
//如果是顶层菜单
|
||||
if (routerItem.meta.topMenu) {
|
||||
// for (let children of routerItem.children) {
|
||||
let lineRouterArray = convertRouterTree2Line(routerItem.children);
|
||||
lineRouters.push(...lineRouterArray);
|
||||
// }
|
||||
} else {
|
||||
let lineRouterArray = convertRouterTree2Line([routerItem]);
|
||||
lineRouters.push(...lineRouterArray);
|
||||
}
|
||||
}
|
||||
return lineRouters;
|
||||
}
|
||||
|
||||
function convertRouterTree2Line (routerArray) {
|
||||
//一级,比如 人员管理
|
||||
let topArray = [];
|
||||
for (let router1Item of routerArray) {
|
||||
let level2Array = [];
|
||||
//二级,比如员工管理
|
||||
if (router1Item.children) {
|
||||
for (let level2Item of router1Item.children) {
|
||||
|
||||
let level2ItemCopy = {};
|
||||
for (let property in level2Item) {
|
||||
if ('children' !== property) {
|
||||
level2ItemCopy[property] = level2Item[property];
|
||||
}
|
||||
}
|
||||
|
||||
//三级,
|
||||
if (level2Item.children) {
|
||||
level2Array.push(...level2Item.children)
|
||||
}
|
||||
|
||||
level2ItemCopy.children = [];
|
||||
level2Array.push(level2Item);
|
||||
}
|
||||
}
|
||||
|
||||
let newTopRouterItem = {};
|
||||
for (let property in router1Item) {
|
||||
if ('children' !== property) {
|
||||
newTopRouterItem[property] = router1Item[property];
|
||||
}
|
||||
}
|
||||
|
||||
newTopRouterItem.children = level2Array;
|
||||
topArray.push(newTopRouterItem);
|
||||
}
|
||||
|
||||
return topArray;
|
||||
}
|
||||
|
||||
let tempCheckObj = {
|
||||
checkRouterNameMap: new Map(),
|
||||
checkRouterPathMap: new Map()
|
||||
};
|
||||
|
||||
function recursionRouter (routerArray) {
|
||||
function recursionCheckRouter (routerArray) {
|
||||
for (let routerItem of routerArray) {
|
||||
if (!routerItem.name) {
|
||||
console.error('没有配置router name', routerItem);
|
||||
@@ -141,14 +199,23 @@ function recursionRouter (routerArray) {
|
||||
}
|
||||
|
||||
if (routerItem.children) {
|
||||
recursionRouter(routerItem.children);
|
||||
recursionCheckRouter(routerItem.children);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
recursionRouter(routers);
|
||||
//如果是开发环境,需要检测router的规范性
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
recursionCheckRouter(routers);
|
||||
delete tempCheckObj.checkRouterNameMap;
|
||||
delete tempCheckObj.checkRouterPathMap;
|
||||
}
|
||||
|
||||
delete tempCheckObj.checkRouterNameMap;
|
||||
delete tempCheckObj.checkRouterPathMap;
|
||||
|
||||
const topMenuArray = routers.filter(e => e.meta.topMenu);
|
||||
export { topMenuArray };
|
||||
|
||||
export default router;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ export const emailSetting = [
|
||||
{ title: '删除', name: 'email-delete' }
|
||||
]
|
||||
},
|
||||
component: () => import('@/views/email/email-list.vue')
|
||||
component: () => import('@/views/business/email/email-list.vue')
|
||||
},
|
||||
// 发送email
|
||||
{
|
||||
@@ -33,7 +33,7 @@ export const emailSetting = [
|
||||
title: '发送邮件',
|
||||
privilege: [{ title: '发送', name: 'email-send' }]
|
||||
},
|
||||
component: () => import('@/views/email/send-mail.vue')
|
||||
component: () => import('@/views/business/email/send-mail.vue')
|
||||
}
|
||||
]
|
||||
}
|
||||
29
smart-admin-web/src/router/module/business/index.js
Normal file
29
smart-admin-web/src/router/module/business/index.js
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
import Main from '@/components/main';
|
||||
|
||||
import { peony } from './peony';
|
||||
import { emailSetting } from './email';
|
||||
import { keepAlive } from './keep-alive';
|
||||
import { notice } from './notice';
|
||||
import { threeRouter } from './three-router';
|
||||
|
||||
// 业务
|
||||
export const business = [
|
||||
{
|
||||
path: '/business',
|
||||
name: 'Business',
|
||||
component: Main,
|
||||
meta: {
|
||||
title: '业务功能',
|
||||
topMenu:true,
|
||||
icon: 'icon iconfont iconyoujianguanli'
|
||||
},
|
||||
children: [
|
||||
...peony,
|
||||
...emailSetting,
|
||||
...keepAlive,
|
||||
...notice,
|
||||
...threeRouter
|
||||
]
|
||||
}
|
||||
];
|
||||
@@ -16,7 +16,7 @@ export const keepAlive = [
|
||||
meta: {
|
||||
title: 'KeepAlive列表'
|
||||
},
|
||||
component: () => import('@/views/keep-alive/content-list.vue')
|
||||
component: () => import('@/views/business/keep-alive/content-list.vue')
|
||||
},
|
||||
{
|
||||
path: '/keep-alive/add-content',
|
||||
@@ -24,7 +24,7 @@ export const keepAlive = [
|
||||
meta: {
|
||||
title: 'KeepAlive表单'
|
||||
},
|
||||
component: () => import('@/views/keep-alive/add-content.vue')
|
||||
component: () => import('@/views/business/keep-alive/add-content.vue')
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -24,7 +24,7 @@ export const notice = [
|
||||
{ title: '发送', name: 'notice-send' }
|
||||
]
|
||||
},
|
||||
component: () => import('@/views/notice/notice-list.vue')
|
||||
component: () => import('@/views/business/notice/notice-list.vue')
|
||||
},
|
||||
{
|
||||
path: '/notice/person-notice',
|
||||
@@ -36,7 +36,7 @@ export const notice = [
|
||||
{ title: '详情', name: 'person-notice-detail' }
|
||||
]
|
||||
},
|
||||
component: () => import('@/views/notice/person-notice.vue')
|
||||
component: () => import('@/views/business/notice/person-notice.vue')
|
||||
},
|
||||
{
|
||||
path: '/notice/notice-detail',
|
||||
@@ -45,7 +45,7 @@ export const notice = [
|
||||
title: '消息详情',
|
||||
hideInMenu:true
|
||||
},
|
||||
component: () => import('@/views/notice/notice-detail.vue')
|
||||
component: () => import('@/views/business/notice/notice-detail.vue')
|
||||
}
|
||||
]
|
||||
}
|
||||
49
smart-admin-web/src/router/module/business/peony.js
Normal file
49
smart-admin-web/src/router/module/business/peony.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import Main from '@/components/main';
|
||||
// t_peony路由
|
||||
export const peony = [
|
||||
{
|
||||
path: '/peony',
|
||||
name: 'Peony',
|
||||
component: Main,
|
||||
meta: {
|
||||
title: '牡丹管理',
|
||||
icon: 'icon iconfont iconyoujianguanli'
|
||||
},
|
||||
children: [
|
||||
// 牡丹花 列表
|
||||
{
|
||||
path: '/peony/peony-list',
|
||||
name: 'PeonyList',
|
||||
meta: {
|
||||
title: '牡丹花列表',
|
||||
privilege: [
|
||||
{ title: '查询', name: 'peony-list-query' },
|
||||
{ title: '新增', name: 'peony-list-add' },
|
||||
{ title: '编辑', name: 'peony-list-update' },
|
||||
{ title: '批量删除', name: 'peony-list-batch-delete' },
|
||||
{ title: '批量导出', name: 'peony-list-batch-export' },
|
||||
{ title: '导出全部', name: 'peony-list-export-all' }
|
||||
]
|
||||
},
|
||||
component: () => import('@/views/business/peony/peony-list.vue')
|
||||
},
|
||||
// 牡丹花 列表 1
|
||||
{
|
||||
path: '/peony/peony-list1',
|
||||
name: 'PeonyList1',
|
||||
meta: {
|
||||
title: '牡丹花列表1',
|
||||
privilege: [
|
||||
{ title: '查询', name: 'peony1-list-query' },
|
||||
{ title: '新增', name: 'peony1-list-add' },
|
||||
{ title: '编辑', name: 'peony1-list-update' },
|
||||
{ title: '批量删除', name: 'peony1-list-batch-delete' },
|
||||
{ title: '批量导出', name: 'peony1-list-batch-export' },
|
||||
{ title: '导出全部', name: 'peony1-list-export-all' }
|
||||
]
|
||||
},
|
||||
component: () => import('@/views/business/peony/peony-list.vue')
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
@@ -17,7 +17,6 @@ export const threeRouter = [
|
||||
meta: {
|
||||
title: '三级菜单'
|
||||
},
|
||||
component: () => import('@/views/home'),
|
||||
children: [
|
||||
{
|
||||
path: '/three-router/level-two/level-three1',
|
||||
@@ -29,7 +28,7 @@ export const threeRouter = [
|
||||
{ title: '删除', name: 'roleOneTwo-delete' }
|
||||
]
|
||||
},
|
||||
component: () => import('@/views/home')
|
||||
component: () => import('@/views/system/system-setting/system-config/system-config.vue')
|
||||
},
|
||||
{
|
||||
path: '/three-router/level-two/level-three2',
|
||||
@@ -41,7 +40,7 @@ export const threeRouter = [
|
||||
{ title: '删除', name: 'roleTwoTwo-delete' }
|
||||
]
|
||||
},
|
||||
component: () => import('@/views/home')
|
||||
component: () => import('@/views/support/monitor/sql.vue')
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -55,7 +54,7 @@ export const threeRouter = [
|
||||
{ title: '删除', name: 'roleOneOne-delete' }
|
||||
]
|
||||
},
|
||||
component: () => import('@/views/home')
|
||||
component: () => import('@/views/support/monitor/sql.vue')
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -5,6 +5,7 @@ export const error = [
|
||||
name: 'Error401',
|
||||
meta: {
|
||||
hideInMenu: true,
|
||||
access: true,
|
||||
noValidatePrivilege: true
|
||||
},
|
||||
component: () => import('@/views/error-page/401.vue')
|
||||
@@ -14,6 +15,7 @@ export const error = [
|
||||
name: 'Error500',
|
||||
meta: {
|
||||
hideInMenu: true,
|
||||
access: true,
|
||||
noValidatePrivilege: true
|
||||
},
|
||||
component: () => import('@/views/error-page/500.vue')
|
||||
@@ -23,6 +25,7 @@ export const error = [
|
||||
name: 'http://localhost:8080/#employee/role-employee-manage',
|
||||
meta: {
|
||||
hideInMenu: true,
|
||||
access: true,
|
||||
noValidatePrivilege: true
|
||||
},
|
||||
component: () => import('@/views/error-page/404.vue')
|
||||
|
||||
@@ -18,7 +18,7 @@ export const apiDoc = [
|
||||
title: 'Swagger接口文档',
|
||||
icon: 'icon iconfont iconjiekouwendang'
|
||||
},
|
||||
component: () => import('@/views/api-doc/swagger.vue')
|
||||
component: () => import('@/views/support/api-doc/swagger.vue')
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -24,7 +24,7 @@ export const heartBeat = [
|
||||
}
|
||||
]
|
||||
},
|
||||
component: () => import('@/views/heart-beat/heart-beat-list.vue')
|
||||
component: () => import('@/views/support/heart-beat/heart-beat-list.vue')
|
||||
}
|
||||
]
|
||||
}
|
||||
30
smart-admin-web/src/router/module/support/index.js
Normal file
30
smart-admin-web/src/router/module/support/index.js
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
import Main from '@/components/main';
|
||||
|
||||
|
||||
import { apiDoc } from './api-doc';
|
||||
import { heartBeat } from './heart-beat';
|
||||
import { monitor } from './monitor';
|
||||
import { reload } from './reload';
|
||||
import { task } from './task';
|
||||
|
||||
// 业务
|
||||
export const support = [
|
||||
{
|
||||
path: '/support',
|
||||
name: 'Support',
|
||||
component: Main,
|
||||
meta: {
|
||||
title: '开发专用',
|
||||
topMenu: true,
|
||||
icon: 'icon iconfont iconjiekouwendang'
|
||||
},
|
||||
children: [
|
||||
...apiDoc,
|
||||
...heartBeat,
|
||||
...monitor,
|
||||
...reload,
|
||||
...task
|
||||
]
|
||||
}
|
||||
];
|
||||
@@ -18,7 +18,7 @@ export const monitor = [
|
||||
title: '在线人数',
|
||||
privilege: [{ title: '查询', name: 'online-user-search' }]
|
||||
},
|
||||
component: () => import('@/views/monitor/online-user.vue')
|
||||
component: () => import('@/views/support/monitor/online-user.vue')
|
||||
},
|
||||
// SQL监控
|
||||
{
|
||||
@@ -27,7 +27,7 @@ export const monitor = [
|
||||
meta: {
|
||||
title: 'SQL监控'
|
||||
},
|
||||
component: () => import('@/views/monitor/sql.vue')
|
||||
component: () => import('@/views/support/monitor/sql.vue')
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -33,7 +33,7 @@ export const reload = [
|
||||
]
|
||||
},
|
||||
component: () =>
|
||||
import('@/views/reload/smart-reload/smart-reload-list.vue')
|
||||
import('@/views/support/reload/smart-reload/smart-reload-list.vue')
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -56,7 +56,7 @@ export const task = [
|
||||
}
|
||||
]
|
||||
},
|
||||
component: () => import('@/views/task/task-list.vue')
|
||||
component: () => import('@/views/support/task/task-list.vue')
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -59,7 +59,7 @@ export const employee = [
|
||||
}
|
||||
]
|
||||
},
|
||||
component: () => import('@/views/employee/role/role-manage.vue')
|
||||
component: () => import('@/views/system/employee/role/role-manage.vue')
|
||||
},
|
||||
// 岗位管理页面路由 新
|
||||
{
|
||||
@@ -86,7 +86,7 @@ export const employee = [
|
||||
}
|
||||
]
|
||||
},
|
||||
component: () => import('@/views/employee/position/position-list.vue')
|
||||
component: () => import('@/views/system/employee/position/position-list.vue')
|
||||
},
|
||||
// 人员管理页面路由
|
||||
{
|
||||
@@ -142,7 +142,7 @@ export const employee = [
|
||||
]
|
||||
},
|
||||
component: () =>
|
||||
import('@/views/employee/role-employee/role-employee-manage.vue')
|
||||
import('@/views/system/employee/role-employee/role-employee-manage.vue')
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -22,7 +22,7 @@ export const file = [
|
||||
{ title: '下载', name: 'file-filePage-download' }
|
||||
]
|
||||
},
|
||||
component: () => import('@/views/file/file-list.vue')
|
||||
component: () => import('@/views/system/file/file-list.vue')
|
||||
}
|
||||
]
|
||||
}
|
||||
28
smart-admin-web/src/router/module/system/index.js
Normal file
28
smart-admin-web/src/router/module/system/index.js
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
import Main from '@/components/main';
|
||||
|
||||
|
||||
import { employee } from './employee';
|
||||
import { file } from './file';
|
||||
import { userLog } from './user-log';
|
||||
import { systemSetting } from './system-setting';
|
||||
|
||||
// 业务
|
||||
export const system = [
|
||||
{
|
||||
path: '/system',
|
||||
name: 'System',
|
||||
component: Main,
|
||||
meta: {
|
||||
title: '系统设置',
|
||||
topMenu: true,
|
||||
icon: 'icon iconfont iconxitongshezhi'
|
||||
},
|
||||
children: [
|
||||
...employee,
|
||||
...file,
|
||||
...userLog,
|
||||
...systemSetting
|
||||
]
|
||||
}
|
||||
];
|
||||
@@ -36,7 +36,7 @@ export const systemSetting = [
|
||||
]
|
||||
},
|
||||
component: () =>
|
||||
import('@/views/system-setting/system-config/system-config.vue')
|
||||
import('@/views/system/system-setting/system-config/system-config.vue')
|
||||
},
|
||||
{
|
||||
path: '/system-setting/system-privilege',
|
||||
@@ -54,8 +54,7 @@ export const systemSetting = [
|
||||
}
|
||||
]
|
||||
},
|
||||
component: () =>
|
||||
import('@/views/system-setting/system-privilege/system-privilege.vue')
|
||||
component: () => import('@/views/system/system-setting/system-privilege/system-privilege.vue')
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -22,7 +22,7 @@ export const userLog = [
|
||||
{ title: '删除', name: 'user-operate-log-delete' }
|
||||
]
|
||||
},
|
||||
component: () => import('@/views/user-log/user-operate-log.vue')
|
||||
component: () => import('@/views/system/user-log/user-operate-log.vue')
|
||||
},
|
||||
// 人员管理页面路由
|
||||
{
|
||||
@@ -35,7 +35,7 @@ export const userLog = [
|
||||
{ title: '删除', name: 'user-login-log-delete' }
|
||||
]
|
||||
},
|
||||
component: () => import('@/views/user-log/user-login-log.vue')
|
||||
component: () => import('@/views/system/user-log/user-login-log.vue')
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,18 +1,8 @@
|
||||
import { home } from './module/home';
|
||||
import { employee } from './module/employee';
|
||||
import { systemSetting } from './module/system-setting';
|
||||
import { notice } from './module/notice';
|
||||
import { emailSetting } from './module/email';
|
||||
import { monitor } from './module/monitor';
|
||||
import { userLog } from './module/user-log';
|
||||
import { error } from './module/error';
|
||||
import { task } from './module/task';
|
||||
import { reload } from './module/reload';
|
||||
import { apiDoc } from './module/api-doc';
|
||||
import { threeRouter } from './module/three-router';
|
||||
import { keepAlive } from './module/keep-alive';
|
||||
import { heartBeat } from './module/heart-beat';
|
||||
import { file } from './module/file';
|
||||
import { business } from './module/business';
|
||||
import { support } from './module/support';
|
||||
import { system } from './module/system';
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -27,6 +17,7 @@ import { file } from './module/file';
|
||||
* privilegeExtend:{String} 同一功能模块下子页面的功能点权限继承菜单模块创建的路由权限 by lihaifan&lipeng
|
||||
* noKeepAlive: (false) 设为true后页面在切换标签后不会缓存,如果需要缓存,无需设置这个字段,而且需要设置页面组件name属性和路由配置的name一致
|
||||
* noValidatePrivilege: (true) 表示此路由不需要验证权限
|
||||
* topMenu:(true),表示为顶级菜单
|
||||
* }
|
||||
*/
|
||||
// 登录模块
|
||||
@@ -36,7 +27,7 @@ export const login = {
|
||||
meta: {
|
||||
hideInMenu: true,
|
||||
title: 'Login - 登录',
|
||||
noValidatePrivilege:true
|
||||
noValidatePrivilege: true
|
||||
},
|
||||
component: () => import('@/views/login/login.vue')
|
||||
};
|
||||
@@ -45,18 +36,8 @@ export const login = {
|
||||
export const routers = [
|
||||
login,
|
||||
...home,
|
||||
...employee,
|
||||
...systemSetting,
|
||||
...notice,
|
||||
...emailSetting,
|
||||
...userLog,
|
||||
...monitor,
|
||||
...error,
|
||||
...task,
|
||||
...reload,
|
||||
...apiDoc,
|
||||
...threeRouter,
|
||||
...keepAlive,
|
||||
...heartBeat,
|
||||
...file
|
||||
...business,
|
||||
...system,
|
||||
...support
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user