vue-admin-template/src/router/index.js

343 lines
8.1 KiB
JavaScript

import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
/* Layout */
import Layout from '@/layout'
/**
* Note: sub-menu only appear when route children.length >= 1
* Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
*
* hidden: true if set true, item will not show in the sidebar(default is false)
* alwaysShow: true if set true, will always show the root menu
* if not set alwaysShow, when item has more than one children route,
* it will becomes nested mode, otherwise not show the root menu
* redirect: noRedirect if set noRedirect will no redirect in the breadcrumb
* name:'router-name' the name is used by <keep-alive> (must set!!!)
* meta : {
roles: ['admin','editor'] control the page roles (you can set multiple roles)
title: 'title' the name show in sidebar and breadcrumb (recommend set)
icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
}
*/
/**
* constantRoutes
* a base page that does not have permission requirements
* all roles can be accessed
*/
export const constantRoutes = [
{
path: '/login',
component: () => import('@/views/login/index'),
hidden: true
},
{
path: '/404',
component: () => import('@/views/404'),
hidden: true
},
{
path: '/',
component: Layout,
redirect: '/dashboard',
children: [{
path: 'dashboard',
name: 'Dashboard',
component: () => import('@/views/dashboard/index'),
meta: { title: '首页', icon: '首页' }
}]
},
// {
// path: '/priority',
// component: Layout,
// children: [{
// path: 'priority',
// name: 'priority',
// component: () => import('@/views/priority/priority'),
// meta: {
// title: '管理员专用',
// icon: '权限'
// }
// }]
// },
{
path: '/job',
component: Layout,
redirect: '/job/show',
name: 'Job',
meta: {
title: '岗位',
icon: '岗位'
},
children: [
{
path: 'show',
name: 'JobShow',
component: () => import('@/views/job/show'),
meta: { title: '岗位总览' }
},
{
path: 'search',
name: 'JobSearch',
component: () => import('@/views/job/search'),
meta: { title: '岗位标签搜索' }
},
{
path: 'evaluation',
name: 'JobEvaluation',
component: () => import('@/views/job/evaluation'),
meta: { title: '岗位胜任度评价标准' }
},
{
path: 'score',
name: 'score',
component: () => import('@/views/job/score'),
meta: { title: 'score' }
}
]
},
{
path: '/person',
component: Layout,
redirect: '/person/information',
name: 'Person',
meta: {
title: '员工',
icon: '员工'
},
children: [
{
path: 'information',
name: 'PersonInformation',
component: () => import('@/views/person/information'),
meta: { title: '员工信息' }
},
{
path: 'train',
name: 'PersonTrain',
component: () => import('@/views/person/train'),
meta: { title: '培训档案' }
},
{
path: 'review',
name: 'PersonReview',
component: () => import('@/views/person/review'),
meta: { title: '人才盘点' }
},
]
},
{
path: '/event',
component: Layout,
redirect: '/event/select',
name: 'Event',
meta: {
title: '事件',
icon: '事件'
},
children: [
{
path: 'select',
name: 'EventSelect',
component: () => import('@/views/event/select'),
meta: {
title: '事件查询'
}
}]
},
{
path: '/analysis',
component: Layout,
redirect: '/analysis/show',
name: 'Analysis',
meta: {
title: '统计与分析',
icon: '统计'
},
children: [
{
path: 'show',
name: 'AnalysisShow',
component: () => import('@/views/analysis/show'),
meta: {
title: '统计与分析展示'
}
}]
},
{
path: '/user',
component: Layout,
children: [{
path: 'manage',
name: 'User',
component: () => import('@/views/user/manage'),
meta: {
title: '账户',
icon: '用户'
}
}]
},
{
path: '/manage',
component: Layout,
redirect: '/manage/job',
name: 'Manage',
meta: {
title: '管理',
icon: '管理'
},
children: [
{
path: 'job',
component: () => import('@/views/manage/job/index'),
name: 'ManageJob',
meta: { title: '岗位管理' },
children: [
{
path: 'basic',
component: () => import('@/views/manage/job/basic'),
name: 'ManageJobBasic',
meta: { title: '基本信息' }
},
{
path: 'evaluation',
component: () => import('@/views/manage/job/evaluation'),
name: 'ManageJobEvaluation',
meta: { title: '胜任度标准' }
},
]
},
{
path: 'person',
component: () => import('@/views/manage/person/index'),
name: 'ManagePerson',
meta: { title: '员工管理' },
children: [
{
path: 'basic',
component: () => import('@/views/manage/person/basic'),
name: 'ManagePersonBasic',
meta: { title: '基本信息' }
},
{
path: 'tag',
component: () => import('@/views/manage/person/tag'),
name: 'ManagePersonTag',
meta: { title: '人才标签' }
},
]
},
{
path: 'event',
component: () => import('@/views/manage/event/index'),
name: 'ManageEvent',
meta: { title: '事件' },
children: [
{
path: 'basic',
component: () => import('@/views/manage/event/basic'),
name: 'ManageEventBasic',
meta: { title: '事件管理' }
}
]
},
{
path: 'user',
component: () => import('@/views/manage/user/index'),
name: 'ManageUser',
meta: { title: '账户' },
children: [
{
path: 'basic',
component: () => import('@/views/manage/user/basic'),
name: 'ManageUserBasic',
meta: { title: '账户管理' }
}
]
},
]
},
{
path: '/supermanage',
component: Layout,
redirect: '/supermanage/basic',
name: 'SuperManage',
meta: {
title: '超级管理',
icon: '超级管理'
},
children: [
{
path: 'basic',
name: 'SuperManageBasic',
component: () => import('@/views/supermanage/basic'),
meta: {
title: '超级管理'
}
}]
},
{
path: '/test',
component: Layout,
redirect: '/test/test1',
name: 'Test',
meta: {
title: '测试',
icon: '测试'
},
children: [
{
path: 'test1',
name: 'Test1',
component: () => import('@/views/Test/test1'),
meta: { title: '测试1' }
},
{
path: 'test2',
name: 'Test2',
component: () => import('@/views/Test/test2'),
meta: { title: '测试2' }
},
]
},
// 404 page must be placed at the end !!!
{ path: '*', redirect: '/404', hidden: true }
]
const createRouter = () => new Router({
// mode: 'history', // require service support
scrollBehavior: () => ({ y: 0 }),
routes: constantRoutes
})
const router = createRouter()
// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
const newRouter = createRouter()
router.matcher = newRouter.matcher // reset router
}
export default router