You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.8 KiB
JavaScript

8 years ago
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 too many pages will cause webpack hot update too slow.so only in production use Lazy Loading
8 years ago
/* layout */
8 years ago
import Layout from '../views/layout/Layout'
8 years ago
/* login */
8 years ago
const Login = _import('login/index')
8 years ago
/* dashboard */
8 years ago
const dashboard = _import('dashboard/index')
8 years ago
/* error page */
8 years ago
const Err404 = _import('404')
8 years ago
8 years ago
/* demo page */
8 years ago
const Form = _import('page/form')
const Table = _import('table/index')
8 years ago
8 years ago
Vue.use(Router)
8 years ago
/**
* icon : the icon show in the sidebar
8 years ago
* 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 in the sidebar
* meta : `{ role: ['admin'] }` will control the page role
8 years ago
**/
export const constantRouterMap = [
8 years ago
{ path: '/login', component: Login, hidden: true },
8 years ago
{ path: '/404', component: Err404, hidden: true },
{
path: '/',
component: Layout,
redirect: '/dashboard',
8 years ago
name: 'Home',
8 years ago
hidden: true,
children: [{ path: 'dashboard', component: dashboard }]
}
]
export default new Router({
// mode: 'history', //后端支持可开
scrollBehavior: () => ({ y: 0 }),
routes: constantRouterMap
8 years ago
})
8 years ago
export const asyncRouterMap = [
{
path: '/example',
component: Layout,
redirect: 'noredirect',
8 years ago
name: 'Example',
icon: 'zujian',
8 years ago
children: [
8 years ago
{ path: 'index', component: Form, name: 'Form', icon: 'zonghe' }
8 years ago
]
},
8 years ago
8 years ago
{
path: '/table',
component: Layout,
redirect: '/table/index',
8 years ago
icon: 'tubiao',
8 years ago
noDropdown: true,
8 years ago
children: [{ path: 'index', component: Table, name: 'Table', meta: { role: ['admin'] }}]
8 years ago
},
8 years ago
8 years ago
{ path: '*', redirect: '/404', hidden: true }
8 years ago
]