You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

157 lines
4.1 KiB

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 = ['/ErrorAccess','/login']; //头部导航黑名单
const whiteFooterList = ['/','/doctorInformation' ,'/hosInformation','/addNewTreatment']; //底部白名单
const routes = [
{
path: '/login',
name: '登录',
component: () => import('../views/login.vue'),
meta: {
hideBreadcrumb: true, // 首页不显示面包屑
requiresAuth:true
}
},
{
path: '/',
name: '首页',
component: HomeView,
meta: {
title: '医生列表',
hideBreadcrumb: true // 首页不显示面包屑
}
},
{
path: '/hospitalManage',
name: '医院管理',
component: HomeView,
props:{
onlyHosFlag:true
},
meta: {
title: '医院管理',
hideBreadcrumb: true, // 首页不显示面包屑
requiresAuth:true
}
},
{
path: '/doctorInformation',
name: '医生信息',
component: () => import('../views/DoctorInformation.vue'),
meta: {
title: '编辑信息',
breadcrumbParent: '首页' // 手动指定父级
}
},
{
path: '/ErrorAccess',
name: '访问出错',
component: () => import('../views/ErrorAccess.vue'),
meta: {
title: '访问出错',
hideBreadcrumb: true // 首页不显示面包屑
}
},
{
path: '/hosInformation',
name: '医院信息',
component: () => import('../views/HosInformation.vue'),
meta: {
title: '编辑医院',
breadcrumbParent: '医生信息' // 手动指定父级
}
},
{
path: '/weChatPayment',
name: '微信收款',
component: () => import('../views/weChatPayment.vue'),
meta: {
title: '微信收款',
breadcrumbParent: '编辑医院' // 手动指定父级
}
},
{
path: '/addNewTreatment',
component: () => import( /* webpackChunkName: "addNewTreatment" */ '../views/AddNewTreatment.vue'),
name: '新增套餐',
meta: {
hideBreadcrumb: true // 首页不显示面包屑
}
},
{
path: '/ui',
name: 'ui组件',
component: () => import( /* webpackChunkName: "ui" */ '../views/elementGroups.vue'),
meta: {
title: 'ui示例',
breadcrumbTitle: route => `ui ${route.params.userId}` // 自定义面包屑标题
}
},
{
path: '/paymentMethod',
component: () => import( /* webpackChunkName: "paymentMethod" */ '../views/paymentMethod.vue'),
name: '收款方式',
meta: {
title: '收款管理',
hideBreadcrumb: true, // 首页不显示面包屑
requiresAuth:true
}
},
{
path: '/setPaymentForm',
name: '收款设置',
component: () => import('../views/setPaymentForm.vue'),
meta: {
title: '收款设置',
breadcrumbParent: '编辑医院' // 手动指定父级
}
},
]
const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes
})
router.beforeEach((to, from, next) => {
// 检查本地存储是否有nick
const hasNick = localStorage.getItem('nick');
// 如果有nick且访问的是根路径,则重定向到/hospitalManage
if (hasNick && to.path === '/') {
next('/hospitalManage');
return;
}
// 如果没有nick且尝试访问需要认证的页面(如/hospitalManage),则重定向到首页
if (!hasNick && to.meta.requiresAuth) {
next('/');
return;
}
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