import VueRouter from 'vue-router' import Vue from 'vue' import DiskRouter from './disk' import UserRouter from './user' import SearchRouter from './search' import BlogRouter from './blog' import VodRouter from './vod' import BackgroundDevopsRouter from './background_devops' import BackgroundAccountRouter from './background_account' import BackgroundMyRouter from './background_my' import BackgroundPostRouter from './background_post' import BackgroundSiteRouter from './background_site' import BackgroundAdminRouter from './background_admin' import BackgroundBackendRouter from './background_backend' import BackgroundOssRouter from './background_oss' import BackgroundBlogRouter from './background_blog' import BackgroundFileRouter from './background_file' // 懒加载引入页面组件,es6语法 // ******************************************************************************************************************** const Login = () => import('views/Login1') const Register = () => import('views/Register') const Forgot = () => import('views/Forgot') const Index = () => import('views/Index') const Background = () => import('views/admin/Background') const Dashboard = () => import('views/devops/Dashboard') // ******************************************************************************************************************** // 使用安装路由插件 Vue.use(VueRouter) export const constantRoutes = [ DiskRouter, UserRouter, SearchRouter, BlogRouter, VodRouter, { path: '/', redirect: '/bg', name: 'Index', component: Index, meta: { needAuth: false } }, { path: '/bg', name: 'BackgroundIndex', component: Background, meta: { needAuth: false }, children: [ { path: '', name: 'Dashboard', component: Dashboard, meta: { needAuth: true, roles: ['admin'] } } ] }, { 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 } } ] export const asyncRoutes = [ BackgroundDevopsRouter, BackgroundAccountRouter, BackgroundMyRouter, BackgroundPostRouter, BackgroundSiteRouter, BackgroundAdminRouter, BackgroundBackendRouter, BackgroundOssRouter, BackgroundBlogRouter, BackgroundFileRouter, { path: '*', name: '404', component: () => import('@/views/404.vue'), meta: { needAuth: false } } ] // 创建路由对象并导出 export default new VueRouter({ mode: 'history', routes: constantRoutes, scrollBehavior(to, from, savedPosition) { return { x: 0, y: 0 } } })