index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. import VueRouter from 'vue-router'
  2. import Vue from 'vue'
  3. // 懒加载引入页面组件,es6语法
  4. const Home = () => import('views/home/Index')
  5. const StatusIndex = () => import('views/home/Status')
  6. const VideoIndex = () => import('views/home/Video')
  7. const AudioIndex = () => import('views/home/Audio')
  8. const ImageIndex = () => import('views/home/Image')
  9. const ImagePage = () => import('views/home/ImagePage')
  10. const ArticleIndex = () => import('views/home/Article')
  11. const Search = () => import('views/home/Search')
  12. const VideoPage = () => import('views/home/VideoPage')
  13. const HomeIndex = () => import('views/user/Home')
  14. const FollowIndex = () => import('views/user/follow')
  15. const ProfileIndex = () => import('views/user/Profile')
  16. const CollectionIndex = () => import('views/user/Collection')
  17. const HistoryIndex = () => import('views/user/History')
  18. const PostList = () => import('views/post/PostList')
  19. const PostPublish = () => import('views/post/PostPublish')
  20. const PostAnalysis = () => import('views/post/PostAnalysis')
  21. // 使用安装路由插件
  22. Vue.use(VueRouter)
  23. const routes = [
  24. {
  25. path: '/',
  26. name: 'index',
  27. component: Home
  28. },
  29. {
  30. path: '/status/:id',
  31. name: 'StatusIndex',
  32. component: StatusIndex
  33. },
  34. {
  35. path: '/video',
  36. name: 'VideoIndex',
  37. component: VideoIndex
  38. },
  39. {
  40. path: '/video/:id',
  41. name: 'VideoPage',
  42. component: VideoPage
  43. },
  44. {
  45. path: '/audio',
  46. name: 'AudioIndex',
  47. component: AudioIndex
  48. },
  49. {
  50. path: '/image',
  51. name: 'ImageIndex',
  52. component: ImageIndex
  53. },
  54. {
  55. path: '/image/:id',
  56. name: 'ImagePage',
  57. component: ImagePage
  58. },
  59. {
  60. path: '/article',
  61. name: 'ArticleIndex',
  62. component: ArticleIndex
  63. },
  64. {
  65. path: '/search',
  66. name: 'search',
  67. component: Search
  68. },
  69. {
  70. path: '/user/:id',
  71. name: 'HomeIndex',
  72. component: HomeIndex
  73. },
  74. {
  75. path: '/user/:id/follow',
  76. name: 'FollowIndex',
  77. component: FollowIndex
  78. },
  79. {
  80. path: '/u/profile',
  81. name: 'ProfileIndex',
  82. component: ProfileIndex
  83. },
  84. {
  85. path: '/u/collection',
  86. name: 'CollectionIndex',
  87. component: CollectionIndex
  88. },
  89. {
  90. path: '/u/history',
  91. name: 'HistoryIndex',
  92. component: HistoryIndex
  93. },
  94. {
  95. path: '/user/post/list',
  96. name: 'PostList',
  97. component: PostList
  98. },
  99. {
  100. path: '/user/post/publish',
  101. name: 'PostPublish',
  102. component: PostPublish
  103. },
  104. {
  105. path: '/user/post/analysis',
  106. name: 'PostAnalysis',
  107. component: PostAnalysis
  108. },
  109. {
  110. path: '*',
  111. name: '404',
  112. component: () => import('@/views/404.vue'),
  113. meta: {
  114. title: '404'
  115. }
  116. }
  117. ]
  118. // 创建路由对象
  119. const router = new VueRouter({
  120. mode: 'history',
  121. routes
  122. })
  123. // 导出router
  124. export default router