index.js 4.9 KB

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