index.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. const _import = require('./_import_' + process.env.NODE_ENV)
  4. // 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
  5. /* layout */
  6. import Layout from '../views/layout/Layout'
  7. Vue.use(Router)
  8. /**
  9. * icon : the icon show in the sidebar
  10. * hidden : if `hidden:true` will not show in the sidebar
  11. * redirect : if `redirect:noredirect` will not redirct in the levelbar
  12. * noDropdown : if `noDropdown:true` will not has submenu in the sidebar
  13. * meta : `{ role: ['admin'] }` will control the page role
  14. **/
  15. export const constantRouterMap = [
  16. { path: '/login', component: _import('login/index'), hidden: true },
  17. { path: '/404', component: _import('404'), hidden: true },
  18. {
  19. path: '/',
  20. component: Layout,
  21. redirect: '/dashboard',
  22. name: 'Dashboard',
  23. hidden: true,
  24. children: [{ path: 'dashboard', component: _import('dashboard/index') }]
  25. }
  26. ]
  27. export default new Router({
  28. // mode: 'history', //后端支持可开
  29. scrollBehavior: () => ({ y: 0 }),
  30. routes: constantRouterMap
  31. })
  32. export const asyncRouterMap = [
  33. {
  34. path: '/example',
  35. component: Layout,
  36. redirect: 'noredirect',
  37. name: 'Example',
  38. icon: 'zujian',
  39. children: [
  40. { path: 'index', name: 'Form', icon: 'zonghe', component: _import('page/form') }
  41. ]
  42. },
  43. {
  44. path: '/table',
  45. component: Layout,
  46. redirect: '/table/index',
  47. icon: 'tubiao',
  48. noDropdown: true,
  49. children: [{ path: 'index', name: 'Table', component: _import('table/index'), meta: { role: ['admin'] }}]
  50. },
  51. { path: '*', redirect: '/404', hidden: true }
  52. ]