index.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import { createRouter, createWebHashHistory } from 'vue-router'
  2. import LoginView from "../views/LoginView.vue"
  3. import HomeView from '../views/HomeView.vue'
  4. import RelicSearch from '../views/RelicSearch.vue'
  5. // import store from '@/store/index.js'
  6. const routes = [
  7. {
  8. path: '/',
  9. redirect: '/tab-1',
  10. },
  11. {
  12. path: '/login',
  13. name: 'LoginView',
  14. component: LoginView,
  15. },
  16. {
  17. path: '/tab-1',
  18. name: 'HomeView',
  19. component: HomeView,
  20. meta: {
  21. tabIdx: 1
  22. },
  23. children: [
  24. {
  25. path: '/relic-search',
  26. name: 'RelicSearch',
  27. component: RelicSearch,
  28. },
  29. ],
  30. },
  31. // {
  32. // path: '/tab-2',
  33. // name: 'HomeView',
  34. // component: HomeView,
  35. // meta: {
  36. // tabIdx: 2
  37. // }
  38. // },
  39. // {
  40. // path: '/tab-3',
  41. // name: 'HomeView',
  42. // component: HomeView,
  43. // meta: {
  44. // tabIdx: 3
  45. // }
  46. // },
  47. // {
  48. // path: '/tab-4',
  49. // name: 'HomeView',
  50. // component: HomeView,
  51. // meta: {
  52. // tabIdx: 4
  53. // }
  54. // },
  55. // {
  56. // path: '/tab-5',
  57. // name: 'HomeView',
  58. // component: HomeView,
  59. // meta: {
  60. // tabIdx: 5
  61. // }
  62. // },
  63. // {
  64. // path: '/tab-6',
  65. // name: 'HomeView',
  66. // component: HomeView,
  67. // meta: {
  68. // tabIdx: 6
  69. // }
  70. // },
  71. // {
  72. // path: '/tab-7',
  73. // name: 'HomeView',
  74. // component: HomeView,
  75. // meta: {
  76. // tabIdx: 7
  77. // }
  78. // },
  79. // {
  80. // path: '/tab-8',
  81. // name: 'HomeView',
  82. // component: HomeView,
  83. // meta: {
  84. // tabIdx: 8
  85. // }
  86. // },
  87. ]
  88. const router = createRouter({
  89. history: createWebHashHistory(),
  90. routes
  91. })
  92. router.beforeEach((to, from) => {
  93. // 生产环境下强制每次都从首页进入
  94. if (process.env.NODE_ENV === 'production' && !from.name && to.name !== 'HomeView') {
  95. return '/'
  96. }
  97. })
  98. export default router