index.js 2.0 KB

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