import Vue from 'vue'; import VueRouter from 'vue-router'; import store from '../store'; import HomeView from '../views/HomeView.vue'; Vue.use(VueRouter) const whiteSlideList = [ '/ui', '/hosInformation']; //侧边导航白名单 const blackHeaderList = [ ]; //头部导航黑名单 const whiteFooterList = ['/','/doctorInformation' ,'/hosInformation','/addNewTreatment' ]; //底部白名单 const routes = [ { path: '/', name: '首页', component: HomeView, meta: { title: '医生列表', hideBreadcrumb: true // 首页不显示面包屑 } }, { path: '/doctorInformation', name: '医生信息', component: () => import('../views/DoctorInformation.vue'), meta: { title: '编辑信息', breadcrumbParent: '首页' // 手动指定父级 } }, { path: '/hosInformation', name: '医院信息', component: () => import('../views/HosInformation.vue'), meta: { title: '编辑医院', breadcrumbParent: '医生信息' // 手动指定父级 // r如果想隐藏中间层级 // breadcrumbParent: '首页', // 跳过医生信息 // hideInBreadcrumb: true // 可选:隐藏当前项 } }, { path: '/addNewTreatment', component: () => import( /* webpackChunkName: "addNewTreatment" */ '../views/AddNewTreatment.vue'), name: '新增套餐', children: [ ] }, { path: '/ui', name: 'ui组件', component: () => import( /* webpackChunkName: "ui" */ '../views/elementGroups.vue'), meta: { title: 'ui示例', breadcrumbTitle: route => `ui ${route.params.userId}` // 自定义面包屑标题 } }, { path: '/super/ranking', component: () => import( /* webpackChunkName: "Ranking" */ '../views/super/Ranking/Ranking.vue'), children: [ { path: 'checkProfit', name: '产品毛利润排行', component: () => import( /* webpackChunkName: "Ranking" */ '../views/super/Ranking/RankBatchList.vue'), props: {pageTitle:'产品 - 毛利润排行', rank_type: 1, type: 'check_type'} }, ] }, ] const router = new VueRouter({ mode: 'history', base: process.env.BASE_URL, routes }) router.beforeEach((to, from, next) => { if (whiteSlideList.includes(to.path)) { store.commit('SET_SIDEBAR', true); // 登录页面不显示侧边栏 } else { store.commit('SET_SIDEBAR', false); // 其他页面显示侧边栏 } if (whiteFooterList.includes(to.path)) { store.commit('SET_FOOTER', true); // 登录页面不显示底部信息 } else { store.commit('SET_FOOTER', false); // 其他页面显示底部信息 } if (blackHeaderList.includes(to.path)) { store.commit('SET_HEADER', false); // 登录页面不显示顶部 } else { store.commit('SET_HEADER', true); // 其他页面显示顶部 } next(); }); export default router