123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- import Vue from 'vue'
- import Router from 'vue-router'
- Vue.use(Router)
- import Layout from '@/layout'
- export const constantRoutes = [
- {
- path: '/login',
- component: () => import('@/views/login/index'),
- hidden: true
- },
- {
- path: '/404',
- component: () => import('@/views/404'),
- hidden: true
- }
- ]
- export const asyncRoutes = [
- {
- path: '/',
- component: Layout,
- redirect: '/dashboard',
- children: [{
- path: 'dashboard',
- name: 'Dashboard',
- component: () => import('@/views/dashboard/index'),
- meta: { title: '首页', icon: 'dashboard' }
- }]
- },
- {
- path: '/project',
- component: Layout,
- redirect: '/project/list',
- meta: { title: '项目管理', icon: 'table', roleValue: 'project_list_show' },
- children: [{
- path: 'list',
- name: 'project',
- component: () => import('@/views/project/index'),
- meta: { title: '项目列表', roleValue: 'project_list_show' }
- }]
- },
- {
- path: '/department',
- component: Layout,
- redirect: '/department/list',
- meta: { title: '部门管理', icon: 'el-icon-s-check', roleValue: 'department_list_show' },
- children: [{
- path: 'list',
- name: 'department',
- component: () => import('@/views/department/index'),
- meta: { title: '部门列表', roleValue: 'department_list_show' }
- }]
- },
- {
- path: '/roles',
- component: Layout,
- redirect: '/roles/list',
- meta: { title: '角色管理', icon: 'peoples', roleValue: 'roles_list_show' },
- children: [{
- path: 'list',
- name: 'roles',
- component: () => import('@/views/roles/index'),
- meta: { title: '角色列表', roleValue: 'roles_list_show' }
- }]
- },
- {
- path: '/user',
- component: Layout,
- redirect: '/user/list',
- meta: { title: '用户管理', icon: 'user', roleValue: 'user_list_show' },
- children: [{
- path: 'list',
- name: 'user',
- component: () => import('@/views/user/index'),
- meta: { title: '用户列表', roleValue: 'user_list_show' }
- }]
- },
- {
- path: '/icon',
- component: Layout,
- redirect: '/icon/list',
- hidden: true,
- children: [{
- path: 'list',
- name: 'icon',
- component: () => import('@/views/icons/index'),
- meta: { title: 'icon', icon: 'el-icon-s-grid' }
- }]
- },
- { path: '*', redirect: '/404', hidden: true }
- ]
- const createRouter = () => new Router({
- mode: 'history',
- scrollBehavior (to, from, savedPosition) {
- if (to.hash) {
- return {
- selector: to.hash
- }
- }
-
- if (savedPosition && to.meta.keepAlive) {
- return savedPosition
- }
-
- return new Promise((resolve) => {
- setTimeout(() => {
- resolve({ x: 0, y: 1 })
- }, 0)
- })
- },
- routes: constantRoutes
- })
- const router = createRouter()
- export function resetRouter () {
- const newRouter = createRouter()
- router.matcher = newRouter.matcher
- }
- export default router
|