2017-08-22 07:43:34 +00:00
|
|
|
import Vue from 'vue'
|
|
|
|
import Router from 'vue-router'
|
2017-04-18 07:09:13 +00:00
|
|
|
|
2017-08-22 07:43:34 +00:00
|
|
|
Vue.use(Router)
|
2017-04-18 07:09:13 +00:00
|
|
|
|
2017-11-17 06:57:39 +00:00
|
|
|
/* Layout */
|
2019-04-01 09:07:16 +00:00
|
|
|
import Layout from '@/layout'
|
2017-05-17 08:26:33 +00:00
|
|
|
|
2018-08-15 09:29:15 +00:00
|
|
|
/* Router Modules */
|
|
|
|
import componentsRouter from './modules/components'
|
|
|
|
import chartsRouter from './modules/charts'
|
|
|
|
import tableRouter from './modules/table'
|
|
|
|
import nestedRouter from './modules/nested'
|
|
|
|
|
2019-02-15 06:54:57 +00:00
|
|
|
/** note: sub-menu only appear when children.length>=1
|
2018-08-15 09:29:15 +00:00
|
|
|
* detail see https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
|
|
|
|
**/
|
2017-12-29 08:07:42 +00:00
|
|
|
|
2017-07-28 07:12:32 +00:00
|
|
|
/**
|
2017-11-17 06:57:39 +00:00
|
|
|
* hidden: true if `hidden:true` will not show in the sidebar(default is false)
|
2018-01-24 06:47:20 +00:00
|
|
|
* alwaysShow: true if set true, will always show the root menu, whatever its child routes length
|
|
|
|
* if not set alwaysShow, only more than one route under the children
|
|
|
|
* it will becomes nested mode, otherwise not show the root menu
|
2018-09-03 07:03:00 +00:00
|
|
|
* redirect: noredirect if `redirect:noredirect` will no redirect in the breadcrumb
|
2017-11-17 06:57:39 +00:00
|
|
|
* name:'router-name' the name is used by <keep-alive> (must set!!!)
|
2017-10-31 02:49:24 +00:00
|
|
|
* meta : {
|
2018-12-24 03:12:24 +00:00
|
|
|
roles: ['admin','editor'] will control the page roles (you can set multiple roles)
|
2019-02-15 06:54:57 +00:00
|
|
|
title: 'title' the name show in sub-menu and breadcrumb (recommend set)
|
2018-12-24 03:12:24 +00:00
|
|
|
icon: 'svg-name' the icon show in the sidebar
|
|
|
|
noCache: true if true, the page will no be cached(default is false)
|
|
|
|
breadcrumb: false if false, the item will hidden in breadcrumb(default is true)
|
2019-02-15 07:26:48 +00:00
|
|
|
affix: true if true, the tag will affix in the tags-view
|
2017-10-31 02:49:24 +00:00
|
|
|
}
|
2017-07-28 07:12:32 +00:00
|
|
|
**/
|
2019-04-01 09:07:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* constantRoutes
|
|
|
|
* a base page that does not have permission requirements
|
|
|
|
* all roles can be accessed
|
|
|
|
* */
|
2019-03-15 10:08:12 +00:00
|
|
|
export const constantRoutes = [
|
2018-08-29 07:24:47 +00:00
|
|
|
{
|
|
|
|
path: '/redirect',
|
|
|
|
component: Layout,
|
|
|
|
hidden: true,
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
path: '/redirect/:path*',
|
|
|
|
component: () => import('@/views/redirect/index')
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2018-08-15 09:29:15 +00:00
|
|
|
{
|
|
|
|
path: '/login',
|
|
|
|
component: () => import('@/views/login/index'),
|
|
|
|
hidden: true
|
|
|
|
},
|
|
|
|
{
|
2018-09-03 07:03:00 +00:00
|
|
|
path: '/auth-redirect',
|
2019-04-04 04:58:37 +00:00
|
|
|
component: () => import('@/views/login/authRedirect'),
|
2018-08-15 09:29:15 +00:00
|
|
|
hidden: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/404',
|
|
|
|
component: () => import('@/views/errorPage/404'),
|
|
|
|
hidden: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/401',
|
|
|
|
component: () => import('@/views/errorPage/401'),
|
|
|
|
hidden: true
|
|
|
|
},
|
2017-05-17 08:26:33 +00:00
|
|
|
{
|
2017-11-02 09:58:35 +00:00
|
|
|
path: '',
|
2017-05-17 08:26:33 +00:00
|
|
|
component: Layout,
|
2017-11-02 09:58:35 +00:00
|
|
|
redirect: 'dashboard',
|
2018-08-15 09:29:15 +00:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
path: 'dashboard',
|
|
|
|
component: () => import('@/views/dashboard/index'),
|
2018-08-19 08:55:24 +00:00
|
|
|
name: 'Dashboard',
|
2019-02-15 07:26:48 +00:00
|
|
|
meta: { title: 'dashboard', icon: 'dashboard', noCache: true, affix: true }
|
2018-08-15 09:29:15 +00:00
|
|
|
}
|
|
|
|
]
|
2017-05-17 08:26:33 +00:00
|
|
|
},
|
|
|
|
{
|
2017-11-17 06:57:39 +00:00
|
|
|
path: '/documentation',
|
2017-05-17 08:26:33 +00:00
|
|
|
component: Layout,
|
2018-08-15 09:29:15 +00:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
path: 'index',
|
|
|
|
component: () => import('@/views/documentation/index'),
|
2018-08-19 08:55:24 +00:00
|
|
|
name: 'Documentation',
|
2019-02-15 07:26:48 +00:00
|
|
|
meta: { title: 'documentation', icon: 'documentation', affix: true }
|
2018-08-15 09:29:15 +00:00
|
|
|
}
|
|
|
|
]
|
2018-05-28 06:36:06 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/guide',
|
|
|
|
component: Layout,
|
|
|
|
redirect: '/guide/index',
|
2018-08-15 09:29:15 +00:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
path: 'index',
|
|
|
|
component: () => import('@/views/guide/index'),
|
2018-08-19 08:55:24 +00:00
|
|
|
name: 'Guide',
|
2018-08-15 09:29:15 +00:00
|
|
|
meta: { title: 'guide', icon: 'guide', noCache: true }
|
|
|
|
}
|
|
|
|
]
|
2017-05-17 08:26:33 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2019-04-01 09:07:16 +00:00
|
|
|
/**
|
|
|
|
* asyncRoutes
|
|
|
|
* the routes that need to be dynamically loaded based on user roles
|
|
|
|
*/
|
2019-03-15 10:08:12 +00:00
|
|
|
export const asyncRoutes = [
|
2017-05-17 08:26:33 +00:00
|
|
|
{
|
|
|
|
path: '/permission',
|
|
|
|
component: Layout,
|
|
|
|
redirect: '/permission/index',
|
2018-05-08 14:15:34 +00:00
|
|
|
alwaysShow: true, // will always show the root menu
|
|
|
|
meta: {
|
|
|
|
title: 'permission',
|
|
|
|
icon: 'lock',
|
|
|
|
roles: ['admin', 'editor'] // you can set roles in root nav
|
|
|
|
},
|
2017-05-17 08:26:33 +00:00
|
|
|
children: [
|
2018-08-15 09:29:15 +00:00
|
|
|
{
|
|
|
|
path: 'page',
|
|
|
|
component: () => import('@/views/permission/page'),
|
2018-08-19 08:55:24 +00:00
|
|
|
name: 'PagePermission',
|
2018-08-15 09:29:15 +00:00
|
|
|
meta: {
|
|
|
|
title: 'pagePermission',
|
|
|
|
roles: ['admin'] // or you can only set roles in sub nav
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'directive',
|
|
|
|
component: () => import('@/views/permission/directive'),
|
2018-08-19 08:55:24 +00:00
|
|
|
name: 'DirectivePermission',
|
2018-08-15 09:29:15 +00:00
|
|
|
meta: {
|
|
|
|
title: 'directivePermission'
|
|
|
|
// if do not set roles, means: this page does not require permission
|
|
|
|
}
|
2019-03-15 10:08:12 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'role',
|
|
|
|
component: () => import('@/views/permission/role'),
|
|
|
|
name: 'RolePermission',
|
|
|
|
meta: {
|
|
|
|
title: 'rolePermission',
|
|
|
|
roles: ['admin']
|
|
|
|
}
|
2018-08-15 09:29:15 +00:00
|
|
|
}
|
2017-05-17 08:26:33 +00:00
|
|
|
]
|
|
|
|
},
|
2017-10-26 10:27:39 +00:00
|
|
|
|
2017-05-17 08:26:33 +00:00
|
|
|
{
|
2018-08-15 09:29:15 +00:00
|
|
|
path: '/icon',
|
2017-05-17 08:26:33 +00:00
|
|
|
component: Layout,
|
|
|
|
children: [
|
2018-08-15 09:29:15 +00:00
|
|
|
{
|
|
|
|
path: 'index',
|
|
|
|
component: () => import('@/views/svg-icons/index'),
|
2018-08-19 08:55:24 +00:00
|
|
|
name: 'Icons',
|
2018-08-15 09:29:15 +00:00
|
|
|
meta: { title: 'icons', icon: 'icon', noCache: true }
|
|
|
|
}
|
2017-07-28 07:12:32 +00:00
|
|
|
]
|
|
|
|
},
|
2017-10-26 10:27:39 +00:00
|
|
|
|
2019-04-01 09:07:16 +00:00
|
|
|
/** when your routing map is too long, you can split it into small modules **/
|
2018-08-15 09:29:15 +00:00
|
|
|
componentsRouter,
|
|
|
|
chartsRouter,
|
|
|
|
nestedRouter,
|
|
|
|
tableRouter,
|
2017-10-31 02:49:24 +00:00
|
|
|
|
|
|
|
{
|
2018-05-30 07:25:08 +00:00
|
|
|
path: '/example',
|
2017-10-31 02:49:24 +00:00
|
|
|
component: Layout,
|
2018-05-30 07:25:08 +00:00
|
|
|
redirect: '/example/list',
|
2018-08-19 08:55:24 +00:00
|
|
|
name: 'Example',
|
2017-10-31 02:49:24 +00:00
|
|
|
meta: {
|
2018-05-30 07:25:08 +00:00
|
|
|
title: 'example',
|
|
|
|
icon: 'example'
|
2017-10-31 02:49:24 +00:00
|
|
|
},
|
|
|
|
children: [
|
2018-08-15 09:29:15 +00:00
|
|
|
{
|
|
|
|
path: 'create',
|
|
|
|
component: () => import('@/views/example/create'),
|
2018-08-19 08:55:24 +00:00
|
|
|
name: 'CreateArticle',
|
2018-08-15 09:29:15 +00:00
|
|
|
meta: { title: 'createArticle', icon: 'edit' }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'edit/:id(\\d+)',
|
|
|
|
component: () => import('@/views/example/edit'),
|
2018-08-19 08:55:24 +00:00
|
|
|
name: 'EditArticle',
|
2018-08-15 09:29:15 +00:00
|
|
|
meta: { title: 'editArticle', noCache: true },
|
|
|
|
hidden: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'list',
|
|
|
|
component: () => import('@/views/example/list'),
|
2018-08-19 08:55:24 +00:00
|
|
|
name: 'ArticleList',
|
2018-08-15 09:29:15 +00:00
|
|
|
meta: { title: 'articleList', icon: 'list' }
|
|
|
|
}
|
2017-05-17 08:26:33 +00:00
|
|
|
]
|
|
|
|
},
|
2017-10-26 10:27:39 +00:00
|
|
|
|
2018-06-21 06:26:25 +00:00
|
|
|
{
|
2018-08-15 09:29:15 +00:00
|
|
|
path: '/tab',
|
2018-06-21 06:26:25 +00:00
|
|
|
component: Layout,
|
|
|
|
children: [
|
|
|
|
{
|
2018-08-15 09:29:15 +00:00
|
|
|
path: 'index',
|
|
|
|
component: () => import('@/views/tab/index'),
|
2018-08-19 08:55:24 +00:00
|
|
|
name: 'Tab',
|
2018-08-15 09:29:15 +00:00
|
|
|
meta: { title: 'tab', icon: 'tab' }
|
2018-06-21 06:26:25 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
2017-05-17 08:26:33 +00:00
|
|
|
{
|
2017-08-22 10:47:23 +00:00
|
|
|
path: '/error',
|
2017-05-17 08:26:33 +00:00
|
|
|
component: Layout,
|
|
|
|
redirect: 'noredirect',
|
2018-08-19 08:55:24 +00:00
|
|
|
name: 'ErrorPages',
|
2017-10-26 10:27:39 +00:00
|
|
|
meta: {
|
2017-11-03 10:37:49 +00:00
|
|
|
title: 'errorPages',
|
2017-10-26 10:27:39 +00:00
|
|
|
icon: '404'
|
|
|
|
},
|
2017-05-17 08:26:33 +00:00
|
|
|
children: [
|
2018-08-15 09:29:15 +00:00
|
|
|
{
|
|
|
|
path: '401',
|
|
|
|
component: () => import('@/views/errorPage/401'),
|
2018-08-19 08:55:24 +00:00
|
|
|
name: 'Page401',
|
2018-08-15 09:29:15 +00:00
|
|
|
meta: { title: 'page401', noCache: true }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '404',
|
|
|
|
component: () => import('@/views/errorPage/404'),
|
2018-08-19 08:55:24 +00:00
|
|
|
name: 'Page404',
|
2018-08-15 09:29:15 +00:00
|
|
|
meta: { title: 'page404', noCache: true }
|
|
|
|
}
|
2017-05-17 08:26:33 +00:00
|
|
|
]
|
|
|
|
},
|
2017-10-26 10:27:39 +00:00
|
|
|
|
2017-05-17 08:26:33 +00:00
|
|
|
{
|
2017-10-26 10:27:39 +00:00
|
|
|
path: '/error-log',
|
2017-05-17 08:26:33 +00:00
|
|
|
component: Layout,
|
|
|
|
redirect: 'noredirect',
|
2018-08-15 09:29:15 +00:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
path: 'log',
|
|
|
|
component: () => import('@/views/errorLog/index'),
|
2018-08-19 08:55:24 +00:00
|
|
|
name: 'ErrorLog',
|
2018-08-15 09:29:15 +00:00
|
|
|
meta: { title: 'errorLog', icon: 'bug' }
|
|
|
|
}
|
|
|
|
]
|
2017-05-17 08:26:33 +00:00
|
|
|
},
|
2017-10-26 10:27:39 +00:00
|
|
|
|
2017-05-17 08:26:33 +00:00
|
|
|
{
|
|
|
|
path: '/excel',
|
|
|
|
component: Layout,
|
2017-11-24 07:35:38 +00:00
|
|
|
redirect: '/excel/export-excel',
|
2018-08-19 08:55:24 +00:00
|
|
|
name: 'Excel',
|
2017-10-26 10:27:39 +00:00
|
|
|
meta: {
|
|
|
|
title: 'excel',
|
|
|
|
icon: 'excel'
|
|
|
|
},
|
2017-07-25 08:51:43 +00:00
|
|
|
children: [
|
2018-08-15 09:29:15 +00:00
|
|
|
{
|
|
|
|
path: 'export-excel',
|
|
|
|
component: () => import('@/views/excel/exportExcel'),
|
2018-08-19 08:55:24 +00:00
|
|
|
name: 'ExportExcel',
|
2018-08-15 09:29:15 +00:00
|
|
|
meta: { title: 'exportExcel' }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: 'export-selected-excel',
|
|
|
|
component: () => import('@/views/excel/selectExcel'),
|
2018-08-31 06:45:29 +00:00
|
|
|
name: 'SelectExcel',
|
2018-08-15 09:29:15 +00:00
|
|
|
meta: { title: 'selectExcel' }
|
|
|
|
},
|
2019-03-17 08:52:11 +00:00
|
|
|
{
|
|
|
|
path: 'export-merge-header',
|
|
|
|
component: () => import('@/views/excel/mergeHeader'),
|
|
|
|
name: 'MergeHeader',
|
|
|
|
meta: { title: 'mergeHeader' }
|
|
|
|
},
|
2018-08-15 09:29:15 +00:00
|
|
|
{
|
|
|
|
path: 'upload-excel',
|
|
|
|
component: () => import('@/views/excel/uploadExcel'),
|
2018-08-19 08:55:24 +00:00
|
|
|
name: 'UploadExcel',
|
2018-08-15 09:29:15 +00:00
|
|
|
meta: { title: 'uploadExcel' }
|
|
|
|
}
|
2017-07-25 08:51:43 +00:00
|
|
|
]
|
2017-05-17 08:26:33 +00:00
|
|
|
},
|
2017-10-26 10:27:39 +00:00
|
|
|
|
2017-09-26 05:40:07 +00:00
|
|
|
{
|
|
|
|
path: '/zip',
|
|
|
|
component: Layout,
|
|
|
|
redirect: '/zip/download',
|
2018-01-24 06:47:20 +00:00
|
|
|
alwaysShow: true,
|
|
|
|
meta: { title: 'zip', icon: 'zip' },
|
2018-08-15 09:29:15 +00:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
path: 'download',
|
|
|
|
component: () => import('@/views/zip/index'),
|
2018-08-19 08:55:24 +00:00
|
|
|
name: 'ExportZip',
|
2018-08-15 09:29:15 +00:00
|
|
|
meta: { title: 'exportZip' }
|
|
|
|
}
|
|
|
|
]
|
2017-09-26 05:40:07 +00:00
|
|
|
},
|
2017-10-26 10:27:39 +00:00
|
|
|
|
2018-12-27 05:42:10 +00:00
|
|
|
{
|
|
|
|
path: '/pdf',
|
|
|
|
component: Layout,
|
|
|
|
redirect: '/pdf/index',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
path: 'index',
|
|
|
|
component: () => import('@/views/pdf/index'),
|
|
|
|
name: 'PDF',
|
2019-02-11 06:51:09 +00:00
|
|
|
meta: { title: 'pdf', icon: 'pdf' }
|
2018-12-27 05:42:10 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/pdf/download',
|
|
|
|
component: () => import('@/views/pdf/download'),
|
|
|
|
hidden: true
|
|
|
|
},
|
|
|
|
|
2017-05-17 08:26:33 +00:00
|
|
|
{
|
|
|
|
path: '/theme',
|
|
|
|
component: Layout,
|
|
|
|
redirect: 'noredirect',
|
2018-08-15 09:29:15 +00:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
path: 'index',
|
|
|
|
component: () => import('@/views/theme/index'),
|
2018-08-19 08:55:24 +00:00
|
|
|
name: 'Theme',
|
2018-08-15 09:29:15 +00:00
|
|
|
meta: { title: 'theme', icon: 'theme' }
|
|
|
|
}
|
|
|
|
]
|
2017-05-17 08:26:33 +00:00
|
|
|
},
|
2017-10-26 10:27:39 +00:00
|
|
|
|
2017-09-27 02:03:42 +00:00
|
|
|
{
|
|
|
|
path: '/clipboard',
|
|
|
|
component: Layout,
|
|
|
|
redirect: 'noredirect',
|
2018-08-15 09:29:15 +00:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
path: 'index',
|
|
|
|
component: () => import('@/views/clipboard/index'),
|
2018-08-19 08:55:24 +00:00
|
|
|
name: 'ClipboardDemo',
|
2018-08-15 09:29:15 +00:00
|
|
|
meta: { title: 'clipboardDemo', icon: 'clipboard' }
|
|
|
|
}
|
|
|
|
]
|
2017-11-03 10:37:49 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
path: '/i18n',
|
|
|
|
component: Layout,
|
2018-08-15 09:29:15 +00:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
path: 'index',
|
|
|
|
component: () => import('@/views/i18n-demo/index'),
|
2018-08-19 08:55:24 +00:00
|
|
|
name: 'I18n',
|
2018-08-15 09:29:15 +00:00
|
|
|
meta: { title: 'i18n', icon: 'international' }
|
|
|
|
}
|
|
|
|
]
|
2017-09-27 02:03:42 +00:00
|
|
|
},
|
2017-06-15 06:33:02 +00:00
|
|
|
|
2018-08-24 02:06:09 +00:00
|
|
|
{
|
|
|
|
path: 'external-link',
|
|
|
|
component: Layout,
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
path: 'https://github.com/PanJiaChen/vue-element-admin',
|
|
|
|
meta: { title: 'externalLink', icon: 'link' }
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
2017-05-17 08:26:33 +00:00
|
|
|
{ path: '*', redirect: '/404', hidden: true }
|
2017-08-22 07:43:34 +00:00
|
|
|
]
|
2019-04-01 09:07:16 +00:00
|
|
|
|
|
|
|
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
|