index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import { createRouter, createWebHashHistory } from 'vue-router'
  2. import HomeView from '../views/HomeView.vue'
  3. import MoreContent from '../views/MoreContent.vue'
  4. import PoemList from '../views/PoemList.vue'
  5. import PaintingList from '../views/PaintingList.vue'
  6. import PaintingDetailList from '../views/PaintingDetailList.vue'
  7. import GameView from '../views/GameView.vue'
  8. import BambooBookView from '../views/BambooBookView.vue'
  9. // import store from '@/store/index.js'
  10. const routes = [
  11. // {
  12. // path: '/',
  13. // redirect: '/home',
  14. // },
  15. {
  16. path: '/',
  17. name: 'HomeView',
  18. component: HomeView,
  19. },
  20. {
  21. path: '/more-content',
  22. name: 'MoreContent',
  23. component: MoreContent,
  24. },
  25. {
  26. path: '/poem-list',
  27. name: 'PoemList',
  28. component: PoemList,
  29. },
  30. {
  31. path: '/painting-list',
  32. name: 'PaintingList',
  33. component: PaintingList,
  34. },
  35. {
  36. path: '/painting-detail-list',
  37. name: 'PaintingDetailList',
  38. component: PaintingDetailList,
  39. },
  40. {
  41. path: '/game',
  42. name: 'Game',
  43. component: GameView,
  44. },
  45. // 竹谱
  46. {
  47. path: '/bambooBook',
  48. name: 'BambooBook',
  49. component: BambooBookView,
  50. },
  51. ]
  52. const router = createRouter({
  53. history: createWebHashHistory(),
  54. routes
  55. })
  56. router.beforeEach((to, from) => {
  57. // 生产环境下强制每次都从首页进入
  58. if (process.env.NODE_ENV === 'production' && !from.name && to.name !== 'HomeView') {
  59. return '/'
  60. }
  61. })
  62. export default router