index.js 5.0 KB

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