index.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. path: '/example',
  28. component: Layout,
  29. redirect: 'noredirect',
  30. name: 'Example',
  31. icon: 'example',
  32. children: [
  33. { path: 'index', name: 'Form', icon: 'form', component: _import('page/form') }
  34. ]
  35. },
  36. {
  37. path: '/table',
  38. component: Layout,
  39. redirect: '/table/index',
  40. icon: 'table',
  41. noDropdown: true,
  42. children: [{ path: 'index', name: 'Table', component: _import('table/index'), meta: { role: ['admin'] }}]
  43. },
  44. { path: '*', redirect: '/404', hidden: true }
  45. ]
  46. export default new Router({
  47. // mode: 'history', //后端支持可开
  48. scrollBehavior: () => ({ y: 0 }),
  49. routes: constantRouterMap
  50. })