2017-08-22 07:43:34 +00:00
import Vue from 'vue'
import Router from 'vue-router'
const _import = require ( './_import_' + process . env . NODE _ENV )
2017-11-17 06:57:39 +00:00
// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading
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 */
2017-08-22 07:43:34 +00:00
import Layout from '../views/layout/Layout'
2017-05-17 08:26:33 +00:00
2017-12-29 08:07:42 +00:00
/ * * n o t e : s u b m e n u o n l y a p p p e a r w h e n c h i l d r e n . l e n g t h > = 1
* detail see https : //panjiachen.github.io/vue-element-admin-site/#/router-and-nav?id=sidebar
* * /
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 )
* redirect : noredirect if ` redirect:noredirect ` will no redirct in the breadcrumb
* name : 'router-name' the name is used by < keep - alive > ( must set ! ! ! )
2017-10-31 02:49:24 +00:00
* meta : {
2017-11-17 06:57:39 +00:00
role : [ 'admin' , 'editor' ] will control the page role ( you can set multiple roles )
title : 'title' the name show in submenu and breadcrumb ( recommend set )
icon : 'svg-name' the icon show in the sidebar ,
noCache : true if fasle , the page will no be cached ( default is false )
2017-10-31 02:49:24 +00:00
}
2017-07-28 07:12:32 +00:00
* * /
2017-05-17 08:26:33 +00:00
export const constantRouterMap = [
2017-10-26 10:27:39 +00:00
{ path : '/login' , component : _import ( 'login/index' ) , hidden : true } ,
{ path : '/authredirect' , component : _import ( 'login/authredirect' ) , hidden : true } ,
{ path : '/404' , component : _import ( 'errorPage/404' ) , hidden : true } ,
{ path : '/401' , component : _import ( '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' ,
2017-10-26 10:27:39 +00:00
children : [ {
path : 'dashboard' ,
component : _import ( 'dashboard/index' ) ,
name : 'dashboard' ,
2017-11-22 02:01:53 +00:00
meta : { title : 'dashboard' , icon : 'dashboard' , noCache : true }
2017-10-26 10:27:39 +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 ,
2017-11-17 06:57:39 +00:00
redirect : '/documentation/index' ,
2017-10-26 10:27:39 +00:00
children : [ {
path : 'index' ,
2017-11-17 06:57:39 +00:00
component : _import ( 'documentation/index' ) ,
name : 'documentation' ,
meta : { title : 'documentation' , icon : 'documentation' , noCache : true }
2017-10-26 10:27:39 +00:00
} ]
2017-05-17 08:26:33 +00:00
}
]
export default new Router ( {
// mode: 'history', //后端支持可开
scrollBehavior : ( ) => ( { y : 0 } ) ,
routes : constantRouterMap
2017-08-22 07:43:34 +00:00
} )
2017-05-17 08:26:33 +00:00
export const asyncRouterMap = [
{
path : '/permission' ,
component : Layout ,
redirect : '/permission/index' ,
meta : { role : [ 'admin' ] } ,
2017-10-26 10:27:39 +00:00
children : [ {
path : 'index' ,
component : _import ( 'permission/index' ) ,
name : 'permission' ,
meta : {
2017-11-03 10:37:49 +00:00
title : 'permission' ,
2017-10-26 10:27:39 +00:00
icon : 'lock' ,
role : [ 'admin' ]
}
} ]
2017-05-17 08:26:33 +00:00
} ,
2017-10-26 10:27:39 +00:00
2017-08-29 09:53:41 +00:00
{
path : '/icon' ,
component : Layout ,
2017-10-26 10:27:39 +00:00
children : [ {
path : 'index' ,
component : _import ( 'svg-icons/index' ) ,
name : 'icons' ,
2017-11-17 06:57:39 +00:00
meta : { title : 'icons' , icon : 'icon' , noCache : true }
2017-10-26 10:27:39 +00:00
} ]
2017-08-29 09:53:41 +00:00
} ,
2017-10-26 10:27:39 +00:00
2017-05-17 08:26:33 +00:00
{
path : '/components' ,
component : Layout ,
2017-11-24 07:35:38 +00:00
redirect : 'noredirect' ,
2017-11-17 09:51:41 +00:00
name : 'component-demo' ,
2017-10-26 10:27:39 +00:00
meta : {
2017-11-03 10:37:49 +00:00
title : 'components' ,
2017-10-26 10:27:39 +00:00
icon : 'component'
} ,
2017-05-17 08:26:33 +00:00
children : [
2017-11-17 09:51:41 +00:00
{ path : 'tinymce' , component : _import ( 'components-demo/tinymce' ) , name : 'tinymce-demo' , meta : { title : 'tinymce' } } ,
{ path : 'markdown' , component : _import ( 'components-demo/markdown' ) , name : 'markdown-demo' , meta : { title : 'markdown' } } ,
{ path : 'json-editor' , component : _import ( 'components-demo/jsonEditor' ) , name : 'jsonEditor-demo' , meta : { title : 'jsonEditor' } } ,
{ path : 'dnd-list' , component : _import ( 'components-demo/dndList' ) , name : 'dndList-demo' , meta : { title : 'dndList' } } ,
{ path : 'splitpane' , component : _import ( 'components-demo/splitpane' ) , name : 'splitpane-demo' , meta : { title : 'splitPane' } } ,
{ path : 'avatar-upload' , component : _import ( 'components-demo/avatarUpload' ) , name : 'avatarUpload-demo' , meta : { title : 'avatarUpload' } } ,
{ path : 'dropzone' , component : _import ( 'components-demo/dropzone' ) , name : 'dropzone-demo' , meta : { title : 'dropzone' } } ,
{ path : 'sticky' , component : _import ( 'components-demo/sticky' ) , name : 'sticky-demo' , meta : { title : 'sticky' } } ,
{ path : 'count-to' , component : _import ( 'components-demo/countTo' ) , name : 'countTo-demo' , meta : { title : 'countTo' } } ,
{ path : 'mixin' , component : _import ( 'components-demo/mixin' ) , name : 'componentMixin-demo' , meta : { title : 'componentMixin' } } ,
{ path : 'back-to-top' , component : _import ( 'components-demo/backToTop' ) , name : 'backToTop-demo' , meta : { title : 'backToTop' } }
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 : '/charts' ,
component : Layout ,
2017-11-24 07:35:38 +00:00
redirect : 'noredirect' ,
2017-10-26 10:27:39 +00:00
name : 'charts' ,
meta : {
2017-11-03 10:37:49 +00:00
title : 'charts' ,
2017-10-26 10:27:39 +00:00
icon : 'chart'
} ,
2017-05-17 08:26:33 +00:00
children : [
2017-11-17 07:07:21 +00:00
{ path : 'keyboard' , component : _import ( 'charts/keyboard' ) , name : 'keyboardChart' , meta : { title : 'keyboardChart' , noCache : true } } ,
{ path : 'line' , component : _import ( 'charts/line' ) , name : 'lineChart' , meta : { title : 'lineChart' , noCache : true } } ,
{ path : 'mixchart' , component : _import ( 'charts/mixChart' ) , name : 'mixChart' , meta : { title : 'mixChart' , noCache : true } }
2017-07-28 07:12:32 +00:00
]
} ,
2017-10-26 10:27:39 +00:00
2017-07-28 07:12:32 +00:00
{
path : '/example' ,
component : Layout ,
2017-11-24 07:35:38 +00:00
redirect : '/example/table/complex-table' ,
2017-10-26 10:27:39 +00:00
name : 'example' ,
meta : {
2017-11-03 10:37:49 +00:00
title : 'example' ,
2017-10-26 10:27:39 +00:00
icon : 'example'
} ,
2017-07-28 07:12:32 +00:00
children : [
{
path : '/example/table' ,
component : _import ( 'example/table/index' ) ,
2017-11-24 07:35:38 +00:00
redirect : '/example/table/complex-table' ,
2017-07-28 07:12:32 +00:00
name : 'Table' ,
2017-10-26 10:27:39 +00:00
meta : {
title : 'Table' ,
icon : 'table'
} ,
2017-07-28 07:12:32 +00:00
children : [
2017-11-03 10:37:49 +00:00
{ path : 'dynamic-table' , component : _import ( 'example/table/dynamicTable/index' ) , name : 'dynamicTable' , meta : { title : 'dynamicTable' } } ,
{ path : 'drag-table' , component : _import ( 'example/table/dragTable' ) , name : 'dragTable' , meta : { title : 'dragTable' } } ,
{ path : 'inline-edit-table' , component : _import ( 'example/table/inlineEditTable' ) , name : 'inlineEditTable' , meta : { title : 'inlineEditTable' } } ,
2017-11-06 05:46:29 +00:00
{ path : 'complex-table' , component : _import ( 'example/table/complexTable' ) , name : 'complexTable' , meta : { title : 'complexTable' } }
2017-07-28 07:12:32 +00:00
]
} ,
2017-11-03 10:37:49 +00:00
{ path : 'tab/index' , icon : 'tab' , component : _import ( 'example/tab/index' ) , name : 'tab' , meta : { title : 'tab' } }
2017-10-31 02:49:24 +00:00
]
} ,
{
path : '/form' ,
component : Layout ,
redirect : 'noredirect' ,
name : 'form' ,
meta : {
2017-11-03 10:37:49 +00:00
title : 'form' ,
2017-10-31 02:49:24 +00:00
icon : 'form'
} ,
children : [
2017-11-03 10:37:49 +00:00
{ path : 'create-form' , component : _import ( 'form/create' ) , name : 'createForm' , meta : { title : 'createForm' , icon : 'table' } } ,
{ path : 'edit-form' , component : _import ( 'form/edit' ) , name : 'editForm' , meta : { title : 'editForm' , icon : 'table' } }
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-08-22 10:47:23 +00:00
path : '/error' ,
2017-05-17 08:26:33 +00:00
component : Layout ,
redirect : 'noredirect' ,
2017-10-26 10:27:39 +00:00
name : 'errorPages' ,
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 : [
2017-11-03 10:37:49 +00:00
{ path : '401' , component : _import ( 'errorPage/401' ) , name : 'page401' , meta : { title : 'page401' , noCache : true } } ,
{ path : '404' , component : _import ( 'errorPage/404' ) , name : 'page404' , 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' ,
2017-11-03 10:37:49 +00:00
children : [ { path : 'log' , component : _import ( 'errorLog/index' ) , name : 'errorLog' , 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' ,
2017-05-17 08:26:33 +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 : [
2017-11-23 02:35:54 +00:00
{ path : 'export-excel' , component : _import ( 'excel/exportExcel' ) , name : 'exportExcel' , meta : { title : 'exportExcel' } } ,
{ path : 'export-selected-excel' , component : _import ( 'excel/selectExcel' ) , name : 'selectExcel' , meta : { title : 'selectExcel' } } ,
{ path : 'upload-excel' , component : _import ( 'excel/uploadExcel' ) , name : 'uploadExcel' , 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' ,
2017-11-03 10:37:49 +00:00
children : [ { path : 'download' , component : _import ( 'zip/index' ) , name : 'exportZip' , meta : { title : 'exportZip' , icon : 'zip' } } ]
2017-09-26 05:40:07 +00:00
} ,
2017-10-26 10:27:39 +00:00
2017-05-17 08:26:33 +00:00
{
path : '/theme' ,
component : Layout ,
redirect : 'noredirect' ,
2017-11-03 10:37:49 +00:00
children : [ { path : 'index' , component : _import ( 'theme/index' ) , name : 'theme' , 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' ,
2017-11-03 10:37:49 +00:00
children : [ { path : 'index' , component : _import ( 'clipboard/index' ) , name : 'clipboardDemo' , meta : { title : 'clipboardDemo' , icon : 'clipboard' } } ]
} ,
{
path : '/i18n' ,
component : Layout ,
2017-11-17 03:36:49 +00:00
children : [ { path : 'index' , component : _import ( 'i18n-demo/index' ) , name : 'i18n' , meta : { title : 'i18n' , icon : 'international' } } ]
2017-09-27 02:03:42 +00:00
} ,
2017-06-15 06:33:02 +00:00
2017-05-17 08:26:33 +00:00
{ path : '*' , redirect : '/404' , hidden : true }
2017-08-22 07:43:34 +00:00
]