import VueRouter from 'vue-router' import Vue from 'vue' import MyRouter from './my' import AdminRouter from './admin' import UserRouter from './user' import MallRouter from './mall' import DiskRouter from './disk' import PostRouter from './post' import CamRouter from './cam' // 懒加载引入页面组件,es6语法 // ******************************************************************************************************************** const Index = () => import('views/Index') const Login = () => import('views/Login') const Register = () => import('views/Register') const Forgot = () => import('views/Forgot') const Home = () => import('views/home/Index') const TimelineIndex = () => import('views/home/Timeline') 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 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/MessageStream2') const Search = () => import('views/home/Search') const DiscoverIndex = () => import('views/home/Discover') const BdMap = () => import('views/home/BdMap') const AMap = () => import('views/home/AMap') // ******************************************************************************************************************** // 使用安装路由插件 Vue.use(VueRouter) const routes = [ MyRouter, AdminRouter, UserRouter, MallRouter, DiskRouter, PostRouter, CamRouter, { path: '/', name: 'Index', component: Index, meta: { needAuth: true }, children: [ { path: '', name: 'Home', component: Home, meta: { needAuth: false } }, { path: '/timeline', name: 'TimelineIndex', component: TimelineIndex, meta: { needAuth: true } }, { path: '/stream', name: 'MessageStream', component: MessageStream, meta: { needAuth: false } }, { path: '/discover', name: 'DiscoverIndex', component: DiscoverIndex, meta: { needAuth: false } }, { path: '/search', name: 'search', component: Search, 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: '/shortvideo', name: 'ShortVideoIndex', component: ShortVideoIndex, meta: { needAuth: false } }, { path: '/video', name: 'VideoIndex', component: VideoIndex, 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: '/article/:articleId', name: 'ArticlePage', component: ArticlePage, meta: { needAuth: false } } ] }, { path: '/login', name: 'Login', component: Login, meta: { needAuth: false } }, { path: '/register', name: 'Register', component: Register, meta: { needAuth: false } }, { path: '/forgot', name: 'Forgot', component: Forgot, 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