index.js 6.2 KB

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