index.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. import VueRouter from 'vue-router'
  2. import Vue from 'vue'
  3. import MyRouter from './my'
  4. import UserRouter from './user'
  5. import ExamRouter from './exam'
  6. import MallRouter from './mall'
  7. import VodRouter from './vod'
  8. import MapRouter from './map'
  9. // 懒加载引入页面组件,es6语法
  10. // ********************************************************************************************************************
  11. const Login = () => import('views/Login')
  12. const Register = () => import('views/Register')
  13. const Forgot = () => import('views/Forgot')
  14. const Index = () => import('views/Index')
  15. const Home = () => import('views/home/Home')
  16. const TimelineIndex = () => import('views/home/Timeline')
  17. const VideoIndex = () => import('views/home/Video')
  18. const ShortVideoIndex = () => import('views/home/ShortVideo')
  19. const VideoPage = () => import('views/home/VideoPage')
  20. const AudioIndex = () => import('views/home/Audio')
  21. const AudioPage = () => import('views/home/AudioPage')
  22. const ImagePage = () => import('views/home/ImagePage')
  23. const ArticleIndex = () => import('views/home/Article')
  24. const ArticlePage = () => import('views/home/ArticlePage')
  25. const Chat = () => import('views/home/Chat')
  26. const Search = () => import('views/home/Search')
  27. const PlaylistIndex = () => import('views/home/PlaylistIndex')
  28. const PlaylistView = () => import('views/home/PlaylistView')
  29. // ********************************************************************************************************************
  30. // 使用安装路由插件
  31. Vue.use(VueRouter)
  32. const routes = [
  33. MyRouter,
  34. ExamRouter,
  35. UserRouter,
  36. MallRouter,
  37. MapRouter,
  38. VodRouter,
  39. {
  40. path: '/login',
  41. name: 'Login',
  42. component: Login,
  43. meta: { needAuth: false }
  44. },
  45. {
  46. path: '/register',
  47. name: 'Register',
  48. component: Register,
  49. meta: { needAuth: false }
  50. },
  51. {
  52. path: '/forgot',
  53. name: 'Forgot',
  54. component: Forgot,
  55. meta: { needAuth: false }
  56. },
  57. {
  58. path: '*',
  59. name: '404',
  60. component: () => import('@/views/404.vue'),
  61. meta: { needAuth: false }
  62. },
  63. {
  64. path: '/',
  65. name: 'Index',
  66. component: Index,
  67. meta: { needAuth: true },
  68. children: [
  69. {
  70. path: '',
  71. name: 'Home',
  72. component: Home,
  73. meta: { needAuth: false }
  74. },
  75. {
  76. path: '/timeline',
  77. name: 'TimelineIndex',
  78. component: TimelineIndex,
  79. meta: { needAuth: true }
  80. },
  81. {
  82. path: '/chat',
  83. name: 'Chat',
  84. component: Chat,
  85. meta: { needAuth: false }
  86. },
  87. {
  88. path: '/search',
  89. name: 'search',
  90. component: Search,
  91. meta: { needAuth: false }
  92. },
  93. {
  94. path: '/shortvideo',
  95. name: 'ShortVideoIndex',
  96. component: ShortVideoIndex,
  97. meta: { needAuth: false }
  98. },
  99. {
  100. path: '/video',
  101. name: 'VideoIndex',
  102. component: VideoIndex,
  103. meta: { needAuth: false }
  104. },
  105. {
  106. path: '/video/:id',
  107. name: 'VideoPage',
  108. component: VideoPage,
  109. meta: { needAuth: false }
  110. },
  111. {
  112. path: '/audio',
  113. name: 'AudioIndex',
  114. component: AudioIndex,
  115. meta: { needAuth: false }
  116. },
  117. {
  118. path: '/audio/:audioId',
  119. name: 'AudioPage',
  120. component: AudioPage,
  121. meta: { needAuth: false }
  122. },
  123. {
  124. path: '/image/:albumId',
  125. name: 'ImagePage',
  126. component: ImagePage,
  127. meta: { needAuth: false }
  128. },
  129. {
  130. path: '/article',
  131. name: 'ArticleIndex',
  132. component: ArticleIndex,
  133. meta: { needAuth: false }
  134. },
  135. {
  136. path: '/article/:articleId',
  137. name: 'ArticlePage',
  138. component: ArticlePage,
  139. meta: { needAuth: false }
  140. },
  141. {
  142. path: '/playlist',
  143. name: 'PlaylistIndex',
  144. component: PlaylistIndex,
  145. meta: { needAuth: false }
  146. },
  147. {
  148. path: '/playlist/:albumId',
  149. name: 'PlaylistView',
  150. component: PlaylistView,
  151. meta: { needAuth: false }
  152. }
  153. ]
  154. }
  155. ]
  156. // 创建路由对象
  157. const router = new VueRouter({
  158. mode: 'history',
  159. routes,
  160. scrollBehavior(to, from, savedPosition) {
  161. return { x: 0, y: 0 }
  162. }
  163. })
  164. // 导出router
  165. export default router