index.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. Vue.use(Router)
  4. /* Layout */
  5. import Layout from '@/layout'
  6. /**
  7. * Note: sub-menu only appear when route children.length >= 1
  8. * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
  9. *
  10. * hidden: true if set true, item will not show in the sidebar(default is false)
  11. * alwaysShow: true if set true, will always show the root menu
  12. * if not set alwaysShow, when item has more than one children route,
  13. * it will becomes nested mode, otherwise not show the root menu
  14. * redirect: noRedirect if set noRedirect will no redirect in the breadcrumb
  15. * name:'router-name' the name is used by <keep-alive> (must set!!!)
  16. * meta : {
  17. roles: ['admin','editor'] control the page roles (you can set multiple roles)
  18. title: 'title' the name show in sidebar and breadcrumb (recommend set)
  19. icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
  20. breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
  21. activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
  22. }
  23. */
  24. /**
  25. * constantRoutes
  26. * a base page that does not have permission requirements
  27. * all roles can be accessed
  28. */
  29. export const constantRoutes = [
  30. {
  31. path: '/login',
  32. component: () => import('@/views/login/index'),
  33. hidden: true
  34. },
  35. {
  36. path: '/external/open_engin',
  37. name: 'open_engin',
  38. component: () => import('@/views/external/open_engin'),
  39. hidden: true
  40. },
  41. {
  42. path: '/404',
  43. component: () => import('@/views/404'),
  44. hidden: true
  45. }
  46. ]
  47. const createRouter = () =>
  48. new Router({
  49. // mode: 'history', // require service support
  50. scrollBehavior: () => ({ y: 0 }),
  51. routes: constantRoutes
  52. })
  53. const router = createRouter()
  54. // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
  55. export function resetRouter() {
  56. const newRouter = createRouter()
  57. router.matcher = newRouter.matcher // reset router
  58. }
  59. export default router