index.js 4.6 KB

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