import Vue from 'vue' import Router from 'vue-router' Vue.use(Router) /* Layout */ import Layout from '@/layout' /** * Note: sub-menu only appear when route children.length >= 1 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html * * hidden: true if set true, item will not show in the sidebar(default is false) * alwaysShow: true if set true, will always show the root menu * if not set alwaysShow, when item has more than one children route, * it will becomes nested mode, otherwise not show the root menu * redirect: noRedirect if set noRedirect will no redirect in the breadcrumb * name:'router-name' the name is used by (must set!!!) * meta : { roles: ['admin','editor'] control the page roles (you can set multiple roles) title: 'title' the name show in sidebar and breadcrumb (recommend set) icon: 'svg-name'/'el-icon-x' the icon show in the sidebar breadcrumb: false if set false, the item will hidden in breadcrumb(default is true) activeMenu: '/example/list' if set path, the sidebar will highlight the path you set } */ /** * constantRoutes * a base page that does not have permission requirements * all roles can be accessed */ export const constantRoutes = [ { path: '/login', component: () => import('@/views/login/index'), hidden: true }, { path: '/404', component: () => import('@/views/404'), hidden: true }, { path: '/', component: Layout, redirect: '/home', children: [{ path: 'home', name: 'home', component: () => import('@/views/home/index'), meta: { title: 'Home', icon: 'dashboard' } }] }, { path: '/homePage', component: Layout, alwaysShow: true, redirect: '/homePage/carousel', name: 'homePage', meta: { title: '首页', icon: 'nested' }, children: [ { path: 'carousel', component: () => import('@/views/homePage/carousel'), meta: { title: '轮播' } }, { path: 'carHot', component: () => import('@/views/homePage/carHot'), meta: { title: '汽车资讯热门' } }, { path: 'banner1', component: () => import('@/views/homePage/banner1'), meta: { title: '广告位1' } }, { path: 'yyzHot', component: () => import('@/views/homePage/yyzHot'), meta: { title: '元宇宙日爆热门' } }, { path: 'banner2', component: () => import('@/views/homePage/banner2'), meta: { title: '广告位2' } }, { path: 'link', component: () => import('@/views/homePage/link'), meta: { title: '外链' } } ] }, { path: '/car', component: Layout, alwaysShow: true, redirect: '/car/carousel', name: 'car', meta: { title: '汽车资讯', icon: 'nested' }, children: [ { path: 'carousel', component: () => import('@/views/car/carousel'), meta: { title: '轮播' } }, { path: 'news', component: () => import('@/views/car/news'), meta: { title: '热点新闻配置' } }, { path: 'banner1', component: () => import('@/views/car/banner1'), meta: { title: '广告位1' } }, { path: 'video', component: () => import('@/views/car/video'), meta: { title: '视频轮播' } }, { path: 'banner2', component: () => import('@/views/car/banner2'), meta: { title: '广告位2' } } ] }, { path: '/yyzrb', component: Layout, alwaysShow: true, redirect: '/yyzrb/carousel', name: 'yyzrb', meta: { title: '元宇宙日爆', icon: 'nested' }, children: [ { path: 'carousel', component: () => import('@/views/yyzrb/carousel'), meta: { title: '轮播' } }, { path: 'news', component: () => import('@/views/yyzrb/news'), meta: { title: '热点新闻配置' } }, { path: 'banner1', component: () => import('@/views/yyzrb/banner1'), meta: { title: '广告位1' } }, { path: 'banner2', component: () => import('@/views/yyzrb/banner2'), meta: { title: '广告位2' } } ] }, { path: '/about', component: Layout, alwaysShow: true, redirect: '/about/company', name: 'about', meta: { title: '关于我们', icon: 'nested' }, children: [ { path: 'company', component: () => import('@/views/about/company'), meta: { title: '公司介绍' } }, { path: 'member', component: () => import('@/views/about/member'), meta: { title: '成员介绍' } } ] } // 404 page must be placed at the end !!! // { path: '*', redirect: '/404', hidden: true } ] const createRouter = () => new Router({ base: '/', mode: 'history', // require service support scrollBehavior: () => ({ y: 0 }), routes: constantRoutes }) const router = createRouter() // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465 export function resetRouter() { const newRouter = createRouter() router.matcher = newRouter.matcher // reset router } export default router