index.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. import VueRouter from 'vue-router'
  2. import Vue from 'vue'
  3. // 懒加载引入页面组件,es6语法
  4. const Home = () => import('views/home/Index')
  5. const TimelineIndex = () => import('views/home/Timeline')
  6. const StatusPage = () => import('views/home/Status')
  7. const VideoIndex = () => import('views/home/Video')
  8. const VideoPage = () => import('views/home/VideoPage')
  9. const AudioIndex = () => import('views/home/Audio')
  10. const ImageIndex = () => import('views/home/Image')
  11. const ImagePage = () => import('views/home/ImagePage')
  12. const ArticleIndex = () => import('views/home/Article')
  13. const Search = () => import('views/home/Search')
  14. const UserHome = () => import('views/user/Home')
  15. const UserVideo = () => import('views/user/Home')
  16. const UserImage = () => import('views/user/Home')
  17. const UserAudio = () => import('views/user/Home')
  18. const UserArticle = () => import('views/user/Home')
  19. const UserFollowing = () => import('views/user/Home')
  20. const UserFollower = () => import('views/user/Home')
  21. const CollectionIndex = () => import('views/user/Collection')
  22. const HistoryIndex = () => import('views/user/History')
  23. const PostPublish = () => import('views/post/PostPublish')
  24. const PostPublishVideo = () => import('views/post/PostPublish')
  25. const PostPublishAudio = () => import('views/post/PostPublish')
  26. const PostPublishImage = () => import('views/post/PostPublish')
  27. const PostPublishArticle = () => import('views/post/PostPublish')
  28. const PostList = () => import('views/post/PostList')
  29. const UserPostVideo = () => import('views/post/PostList')
  30. const UserPostAudio = () => import('views/post/PostList')
  31. const UserPostImage = () => import('views/post/PostList')
  32. const UserPostArticle = () => import('views/post/PostList')
  33. const PostAnalysis = () => import('views/post/PostAnalysis')
  34. const MessageIndex = () => import('views/message/Message')
  35. const DiscoverIndex = () => import('views/home/Discover')
  36. // 使用安装路由插件
  37. Vue.use(VueRouter)
  38. const routes = [
  39. {
  40. path: '/sso',
  41. name: 'sso',
  42. redirect: '/sso/login',
  43. component: () => import('@/views/sso/layout'),
  44. children: [
  45. {
  46. path: '/sso/login',
  47. meta: {
  48. title: '验证码登录',
  49. needLogin: false,
  50. },
  51. component: () => import('@/views/sso/login'),
  52. },
  53. {
  54. path: '/sso/login1',
  55. meta: {
  56. title: '密码登录',
  57. needLogin: false,
  58. },
  59. component: () => import('@/views/sso/login1'),
  60. },
  61. {
  62. path: '/sso/register',
  63. meta: {
  64. title: '账号注册?',
  65. needLogin: false,
  66. },
  67. component: () => import('@/views/sso/register'),
  68. },
  69. {
  70. path: '/sso/forget',
  71. meta: {
  72. title: '找回密码?',
  73. needLogin: false,
  74. },
  75. component: () => import('@/views/sso/forget'),
  76. },
  77. ],
  78. },
  79. {
  80. path: '/',
  81. name: 'index',
  82. component: Home
  83. },
  84. {
  85. path: '/status',
  86. name: 'TimelineIndex',
  87. component: TimelineIndex
  88. },
  89. {
  90. path: '/status/:statusId',
  91. name: 'StatusPage',
  92. component: StatusPage
  93. },
  94. {
  95. path: '/video',
  96. name: 'VideoIndex',
  97. component: VideoIndex
  98. },
  99. {
  100. path: '/video/:id',
  101. name: 'VideoPage',
  102. component: VideoPage
  103. },
  104. {
  105. path: '/audio',
  106. name: 'AudioIndex',
  107. component: AudioIndex
  108. },
  109. {
  110. path: '/image',
  111. name: 'ImageIndex',
  112. component: ImageIndex
  113. },
  114. {
  115. path: '/image/:id',
  116. name: 'ImagePage',
  117. component: ImagePage
  118. },
  119. {
  120. path: '/article',
  121. name: 'ArticleIndex',
  122. component: ArticleIndex
  123. },
  124. {
  125. path: '/discover',
  126. name: 'DiscoverIndex',
  127. component: DiscoverIndex
  128. },
  129. {
  130. path: '/search',
  131. name: 'search',
  132. component: Search
  133. },
  134. {
  135. path: '/user/:id',
  136. name: 'UserHome',
  137. component: UserHome
  138. },
  139. {
  140. path: '/user/:id/video',
  141. name: 'UserVideo',
  142. component: UserVideo
  143. },
  144. {
  145. path: '/user/:id/image',
  146. name: 'UserImage',
  147. component: UserImage
  148. },
  149. {
  150. path: '/user/:id/audio',
  151. name: 'UserAudio',
  152. component: UserAudio
  153. },
  154. {
  155. path: '/user/:id/article',
  156. name: 'UserArticle',
  157. component: UserArticle
  158. },
  159. {
  160. path: '/user/:id/following',
  161. name: 'UserFollowing',
  162. component: UserFollowing
  163. },
  164. {
  165. path: '/user/:id/follower',
  166. name: 'UserFollower',
  167. component: UserFollower
  168. },
  169. {
  170. path: '/u/collection',
  171. name: 'CollectionIndex',
  172. component: CollectionIndex
  173. },
  174. {
  175. path: '/u/history',
  176. name: 'HistoryIndex',
  177. component: HistoryIndex
  178. },
  179. {
  180. path: '/post/publish',
  181. name: 'PostPublish',
  182. component: PostPublish
  183. },
  184. {
  185. path: '/post/publish/video',
  186. name: 'PostPublishVideo',
  187. component: PostPublishVideo
  188. },
  189. {
  190. path: '/post/publish/audio',
  191. name: 'PostPublishAudio',
  192. component: PostPublishAudio
  193. },
  194. {
  195. path: '/post/publish/image',
  196. name: 'PostPublishImage',
  197. component: PostPublishImage
  198. },
  199. {
  200. path: '/post/publish/article',
  201. name: 'PostPublishArticle',
  202. component: PostPublishArticle
  203. },
  204. {
  205. path: '/post/list',
  206. name: 'PostList',
  207. component: PostList
  208. },
  209. {
  210. path: '/post/video',
  211. name: 'UserPostVideo',
  212. component: UserPostVideo
  213. },
  214. {
  215. path: '/post/audio',
  216. name: 'UserPostAudio',
  217. component: UserPostAudio
  218. },
  219. {
  220. path: '/post/image',
  221. name: 'UserPostImage',
  222. component: UserPostImage
  223. },
  224. {
  225. path: '/post/article',
  226. name: 'UserPostArticle',
  227. component: UserPostArticle
  228. },
  229. {
  230. path: '/post/analysis',
  231. name: 'PostAnalysis',
  232. component: PostAnalysis
  233. },
  234. {
  235. path: '/message',
  236. name: 'MessageIndex',
  237. component: MessageIndex
  238. },
  239. {
  240. path: '*',
  241. name: '404',
  242. component: () => import('@/views/404.vue'),
  243. meta: {
  244. title: '404'
  245. }
  246. }
  247. ]
  248. // 创建路由对象
  249. const router = new VueRouter({
  250. mode: 'history',
  251. routes
  252. })
  253. // 导出router
  254. export default router