index.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 PostRouter from './post'
  8. // TODO 待删除
  9. import DiskRouter from './disk'
  10. // TODO 待删除
  11. import CamRouter from './cam'
  12. // 懒加载引入页面组件,es6语法
  13. // ********************************************************************************************************************
  14. const Login = () => import('views/Login')
  15. const Register = () => import('views/Register')
  16. const Forgot = () => import('views/Forgot')
  17. const Index = () => import('views/Index')
  18. const Home = () => import('views/home/Home')
  19. const TimelineIndex = () => import('views/home/Timeline')
  20. const VideoIndex = () => import('views/home/Video')
  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 ImageIndex = () => import('views/home/Image')
  26. const ImagePage = () => import('views/home/ImagePage')
  27. const ArticleIndex = () => import('views/home/Article')
  28. const ArticlePage = () => import('views/home/ArticlePage')
  29. const MessageStream = () => import('views/home/MessageStream2')
  30. const Search = () => import('views/home/Search')
  31. const DiscoverIndex = () => import('views/home/Discover')
  32. // ********************************************************************************************************************
  33. // 使用安装路由插件
  34. Vue.use(VueRouter)
  35. const routes = [
  36. MyRouter,
  37. ExamRouter,
  38. UserRouter,
  39. MallRouter,
  40. DiskRouter,
  41. PostRouter,
  42. CamRouter,
  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: '*',
  63. name: '404',
  64. component: () => import('@/views/404.vue'),
  65. meta: { needAuth: false }
  66. },
  67. {
  68. path: '/',
  69. name: 'Index',
  70. component: Index,
  71. meta: { needAuth: true },
  72. children: [
  73. {
  74. path: '',
  75. name: 'Home',
  76. component: Home,
  77. meta: { needAuth: false }
  78. },
  79. {
  80. path: '/timeline',
  81. name: 'TimelineIndex',
  82. component: TimelineIndex,
  83. meta: { needAuth: true }
  84. },
  85. {
  86. path: '/stream',
  87. name: 'MessageStream',
  88. component: MessageStream,
  89. meta: { needAuth: false }
  90. },
  91. {
  92. path: '/discover',
  93. name: 'DiscoverIndex',
  94. component: DiscoverIndex,
  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: '/audio',
  123. name: 'AudioIndex',
  124. component: AudioIndex,
  125. meta: { needAuth: false }
  126. },
  127. {
  128. path: '/audio/:audioId',
  129. name: 'AudioPage',
  130. component: AudioPage,
  131. meta: { needAuth: false }
  132. },
  133. {
  134. path: '/image',
  135. name: 'ImageIndex',
  136. component: ImageIndex,
  137. meta: { needAuth: false }
  138. },
  139. {
  140. path: '/image/album/: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. }
  159. ]
  160. // 创建路由对象
  161. const router = new VueRouter({
  162. mode: 'history',
  163. routes,
  164. scrollBehavior(to, from, savedPosition) {
  165. return { x: 0, y: 0 }
  166. }
  167. })
  168. // 导出router
  169. export default router