index.js 6.5 KB

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