import VueRouter from 'vue-router' import Vue from 'vue' // 懒加载引入页面组件,es6语法 // ******************************************************************************************************************** // 应用主页 const Home = () => import('views/home/Index') const TimelineIndex = () => import('views/home/Timeline') const StatusPage = () => import('views/home/Status') const VideoIndex = () => import('views/home/Video') const ShortVideoIndex = () => import('views/home/ShortVideo') const VideoPage = () => import('views/home/VideoPage') const VideoList = () => import('views/home/VideoList') const LivePage = () => import('views/home/LivePage') const AudioIndex = () => import('views/home/Audio') const AudioPage = () => import('views/home/AudioPage') const ImageIndex = () => import('views/home/Image') const ImagePage = () => import('views/home/ImagePage') const ArticleIndex = () => import('views/home/Article') const ArticlePage = () => import('views/home/ArticlePage') const MessageStream = () => import('views/home/MessageStream1') const Search = () => import('views/home/Search') const DiscoverIndex = () => import('views/home/Discover') const BdMap = () => import('views/home/BdMap') const AMap = () => import('views/home/AMap') const Vip = () => import('views/vip/Vip') // ******************************************************************************************************************** // 用户前台主页 const UserHome = () => import('views/user/Home') const UserVideo = () => import('views/user/Home') const UserImage = () => import('views/user/Home') const UserAudio = () => import('views/user/Home') const UserArticle = () => import('views/user/Home') const UserRelation = () => import('views/user/UserRelation') // ******************************************************************************************************************** // 用户后台主页 const My = () => import('views/my/My') const MyProfile = () => import('views/my/MyProfile') const MyVip = () => import('views/my/MyVip') // 收藏夹 const FavlistVideo = () => import('views/my/FavlistVideo') const FavlistImage = () => import('views/my/FavlistImage') // 浏览记录 const HistoryIndex = () => import('views/my/History') // 消息 const MessageIndex = () => import('views/my/Message') // 发布稿件 const PostPublishVideo = () => import('components/upload/PublishVideo') const PostPublishAudio = () => import('components/upload/PublishAudio') const PostPublishAlbum = () => import('components/upload/PublishImage') const PostPublishArticle = () => import('components/upload/PublishArticle') const PostPublishFile = () => import('components/upload/PublishFile') // 稿件列表 const UserPostVideo = () => import('views/post/VideoPost') const PostEditVideo = () => import('components/upload/EditVideo') const UserPostAudio = () => import('views/post/AudioPost') const PostEditAudio = () => import('components/upload/EditAudio') const UserPostImage = () => import('views/post/ImagePost') const PostEditAlbum = () => import('components/upload/EditImage') const UserPostArticle = () => import('views/post/ArticlePost') const PostEditArticle = () => import('components/upload/EditArticle') const PostPublish = () => import('views/post/PostPublish') const PostList = () => import('views/post/PostList') const PostAnalysis = () => import('views/post/PostAnalysis') // 使用安装路由插件 Vue.use(VueRouter) const routes = [ { path: '/my', name: 'My', component: My, meta: { needAuth: true } }, { path: '/my/account', name: 'MyAccount', component: My, meta: { needAuth: true }, children: [ { path: '/my/account/profile', name: '个人资料', component: MyProfile, meta: { needAuth: true } }, { path: '/my/account/vip', name: '小会员', component: MyVip, meta: { needAuth: true } } ] }, { path: '/my/post/publish', name: 'MyPostPublish', component: My, meta: { needAuth: true }, children: [ { path: '/my/post/publish/video', name: '发布视频', component: PostPublishVideo, meta: { needAuth: true } }, { path: '/my/post/publish/audio', name: '发布音频', component: PostPublishAudio, meta: { needAuth: true } }, { path: '/my/post/publish/image', name: '发布相册', component: PostPublishAlbum, meta: { needAuth: true } }, { path: '/my/post/publish/article', name: '发布文章', component: PostPublishArticle, meta: { needAuth: true } }, { path: '/my/post/publish/file', name: '发布文件', component: PostPublishFile, meta: { needAuth: true } } ] }, { path: '/my/post/list', name: 'MyPostList', component: My, meta: { needAuth: true }, children: [ { path: '/my/post/list/video', name: '视频稿件', component: UserPostVideo, meta: { needAuth: true } }, { path: '/my/post/list/audio', name: '音频稿件', component: UserPostAudio, meta: { needAuth: true } }, { path: '/my/post/list/image', name: '相册稿件', component: UserPostImage, meta: { needAuth: true } }, { path: '/my/post/list/article', name: '文章稿件', component: UserPostArticle, meta: { needAuth: true } } ] }, { path: '/my/favlist', name: 'MyFavlist', component: My, meta: { needAuth: true }, children: [ { path: '/my/favlist/video', name: '视频收藏', component: FavlistVideo, meta: { needAuth: true } }, { path: '/my/favlist/image', name: '相册收藏', component: FavlistImage, meta: { needAuth: true } } ] }, { path: '/my/visit', name: 'MyVisit', component: My, meta: { needAuth: true }, children: [ { path: '/my/visit', name: '浏览记录', component: HistoryIndex, meta: { needAuth: true } } ] }, { path: '/my/message', name: 'MyMessage', component: My, meta: { needAuth: true }, children: [ { path: '/my/message/send', name: '发出的消息', component: MessageIndex, meta: { needAuth: true } }, { path: '/my/message/receive', name: '收到的消息', component: MessageIndex, meta: { needAuth: true } }, { path: '/my/message/private', name: '私信', component: MessageIndex, meta: { needAuth: true } } ] }, { path: '/timeline', name: 'TimelineIndex', component: TimelineIndex, meta: { needAuth: true } }, { path: '/live/:id', name: 'LivePage', component: LivePage, meta: { needAuth: true } }, { path: '/my/post/edit/video/:videoId', name: 'PostEditVideo', component: PostEditVideo, meta: { needAuth: true } }, { path: '/', name: 'index', component: Home, meta: { needAuth: false } }, { path: '/video', name: 'VideoIndex', component: VideoIndex, meta: { needAuth: false } }, { path: '/shortvideo', name: 'ShortVideoIndex', component: ShortVideoIndex, meta: { needAuth: false } }, { path: '/video/:id', name: 'VideoPage', component: VideoPage, meta: { needAuth: false } }, { path: '/vidlist/:id', name: 'VideoList', component: VideoList, meta: { needAuth: false } }, { path: '/audio', name: 'AudioIndex', component: AudioIndex, meta: { needAuth: false } }, { path: '/audio/:audioId', name: 'AudioPage', component: AudioPage, meta: { needAuth: false } }, { path: '/image', name: 'ImageIndex', component: ImageIndex, meta: { needAuth: false } }, { path: '/image/album/:albumId', name: 'ImagePage', component: ImagePage, meta: { needAuth: false } }, { path: '/article', name: 'ArticleIndex', component: ArticleIndex, meta: { needAuth: false } }, { path: '/stream', name: 'MessageStream', component: MessageStream, meta: { needAuth: false } }, { path: '/article/:articleId', name: 'ArticlePage', component: ArticlePage, meta: { needAuth: false } }, { path: '/discover', name: 'DiscoverIndex', component: DiscoverIndex, meta: { needAuth: false } }, { path: '/search', name: 'search', component: Search, meta: { needAuth: false } }, { path: '/user/:id', name: 'UserHome', component: UserHome, meta: { needAuth: false } }, { path: '/user/:id/video', name: 'UserVideo', component: UserVideo, meta: { needAuth: false } }, { path: '/user/:id/image', name: 'UserImage', component: UserImage, meta: { needAuth: false } }, { path: '/user/:id/audio', name: 'UserAudio', component: UserAudio, meta: { needAuth: false } }, { path: '/user/:id/article', name: 'UserArticle', component: UserArticle, meta: { needAuth: false } }, { path: '/user/:id/following', name: 'UserRelation', component: UserRelation, meta: { needAuth: false } }, { path: '/user/:id/follower', name: 'UserRelation', component: UserRelation, meta: { needAuth: false } }, { path: '/map', name: 'AMap', component: AMap, meta: { needAuth: false } }, { path: '/bdmap', name: 'BdMap', component: BdMap, meta: { needAuth: false } }, { path: '/amap', name: 'AMap', component: AMap, meta: { needAuth: false } }, { path: '/vip', name: 'Vip', component: Vip, meta: { needAuth: false } }, { path: '/login', name: 'Login', component: () => import('@/views/login.vue'), meta: { needAuth: false } }, { path: '*', name: '404', component: () => import('@/views/404.vue'), meta: { needAuth: false } } ] // 创建路由对象 const router = new VueRouter({ mode: 'history', routes, scrollBehavior(to, from, savedPosition) { return { x: 0, y: 0 } } }) // 导出router export default router