2017-06-26 13:38:24 +08:00
|
|
|
import Vue from 'vue';
|
|
|
|
import Router from 'vue-router';
|
|
|
|
const _import = require('./_import_' + process.env.NODE_ENV);
|
|
|
|
// in development env not use Lazy Loading,because Lazy Loading large page will cause webpack hot update too slow
|
|
|
|
// so only in production use Lazy Loading
|
|
|
|
|
|
|
|
/* layout */
|
|
|
|
import Layout from '../views/layout/Layout';
|
|
|
|
|
|
|
|
/* login */
|
|
|
|
const Login = _import('login/index');
|
|
|
|
|
|
|
|
/* dashboard */
|
|
|
|
const dashboard = _import('dashboard/index');
|
|
|
|
|
|
|
|
/* error page */
|
|
|
|
const Err404 = _import('404');
|
|
|
|
|
2017-06-26 18:45:30 +08:00
|
|
|
const Form = _import('page/form');
|
|
|
|
const Table = _import('table/index');
|
2017-06-26 13:38:24 +08:00
|
|
|
|
|
|
|
Vue.use(Router);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* icon : the icon show in the sidebar
|
|
|
|
* hidden : if hidden:true will not show in the sidebar
|
|
|
|
* redirect : if redirect:noredirect will not redirct in the levelbar
|
|
|
|
* noDropdown : if noDropdown:true will not has submenu
|
|
|
|
* meta : { role: ['admin'] } will control the page role
|
|
|
|
**/
|
|
|
|
export const constantRouterMap = [
|
2017-06-26 15:43:11 +08:00
|
|
|
{ path: '/login', component: Login, hidden: true },
|
2017-06-26 13:38:24 +08:00
|
|
|
{ path: '/404', component: Err404, hidden: true },
|
|
|
|
{
|
|
|
|
path: '/',
|
|
|
|
component: Layout,
|
|
|
|
redirect: '/dashboard',
|
|
|
|
name: '首页',
|
|
|
|
hidden: true,
|
|
|
|
children: [{ path: 'dashboard', component: dashboard }]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
export default new Router({
|
|
|
|
// mode: 'history', //后端支持可开
|
|
|
|
scrollBehavior: () => ({ y: 0 }),
|
|
|
|
routes: constantRouterMap
|
|
|
|
});
|
|
|
|
|
|
|
|
export const asyncRouterMap = [
|
|
|
|
{
|
|
|
|
path: '/example',
|
|
|
|
component: Layout,
|
|
|
|
redirect: 'noredirect',
|
2017-06-26 18:45:30 +08:00
|
|
|
name: 'Example',
|
|
|
|
icon: 'zujian',
|
2017-06-26 13:38:24 +08:00
|
|
|
children: [
|
2017-06-26 18:45:30 +08:00
|
|
|
{ path: 'index', component: Form, name: 'Form', icon: 'zonghe' }
|
2017-06-26 13:38:24 +08:00
|
|
|
]
|
|
|
|
},
|
2017-06-26 18:45:30 +08:00
|
|
|
{
|
|
|
|
path: '/table',
|
|
|
|
component: Layout,
|
|
|
|
redirect: '/table/index',
|
|
|
|
name: 'Table',
|
|
|
|
icon: 'tubiaoleixingzhengchang',
|
|
|
|
noDropdown: true,
|
|
|
|
children: [{ path: 'index', component: Table, name: 'Table', meta: { role: ['admin'] } }]
|
|
|
|
},
|
2017-06-26 13:38:24 +08:00
|
|
|
{ path: '*', redirect: '/404', hidden: true }
|
|
|
|
];
|