路由封装

This commit is contained in:
熊猫 2024-02-18 16:47:11 +08:00
parent 6aa352cc47
commit 2854993c42
2 changed files with 133 additions and 130 deletions

View File

@ -1,139 +1,11 @@
import { createRouter, createWebHistory } from 'vue-router' import { createRouter, createWebHistory } from 'vue-router'
import { useLoginStore } from '@/stores/user-info-store' import { useLoginStore } from '@/stores/user-info-store'
import { ElMessage, ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import { constantRoute } from './routes'
const router = createRouter({ const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL), history: createWebHistory(import.meta.env.BASE_URL),
routes: [ routes: constantRoute,
{ path: '/:pathMatch(.*)*', name: 'not-found', redirect: '/home' },
{
path: '/login',
name: '登录',
component: () => import('@/views/login/login.vue'),
},
{
path: '/',
redirect: '/home',
component: () => import('@/views/index.vue'),
children: [
{
path: '/home',
name: '首页',
component: () => import('@/views/home/index.vue'),
},
{
path: '/permissions-manage',
name: '权限管理',
redirect: '/permissions-manage/doctor-manage',
component: () => import('@/views/permissions-manage/index.vue'),
children: [
{
path: '/permissions-manage/doctor-manage',
name: '医生管理',
component: () => import('@/views/permissions-manage/doctor-manage.vue'),
},
{
path: '/permissions-manage/role-manage',
name: '角色管理',
component: () => import('@/views/permissions-manage/role-manage.vue'),
},
{
path: '/permissions-manage/menu-manage',
name: '菜单管理',
component: () => import('@/views/permissions-manage/menu-manage.vue'),
}
]
},
{
path: '/patients-manage',
name: '患者管理',
redirect: '/patients-manage/patients-manage',
component: () => import('@/views/patients-manage/index.vue'),
children: [
{
path: '/patients-manage/patients-manage',
name: '患者管理',
component: () => import('@/views/patients-manage/patients-manage.vue'),
},
{
path: '/patients-manage/surgery-info',
name: '手术信息',
component: () => import('@/views/patients-manage/surgery-info.vue'),
}
]
},
{
path: '/remote-manage',
name: '远程管理',
redirect: '/remote-manage/remote-manage',
component: () => import('@/views/remote-manage/index.vue'),
children: [
{
path: '/remote-manage/remote-manage',
name: '远程管理',
component: () => import('@/views/remote-manage/remote-manage.vue'),
},
{
path: '/remote-manage/remote-thumbnail',
name: '预览缩略图',
component: () => import('@/views/remote-manage/remote-thumbnail.vue'),
},
{
path: '/remote-manage/remote-control',
name: '远程控制',
component: () => import('@/views/remote-manage/remote-control.vue'),
}
]
},
{
path: '/system-manage',
name: '后台管理',
redirect: '/system-manage/system-home',
component: () => import('@/views/system-manage/index.vue'),
children: [
{
path: '/system-manage/system-home',
name: '后台首页',
component: () => import('@/views/system-manage/system-home.vue'),
},
{
path: '/system-manage/hospitals',
name: '合作医院',
component: () => import('@/views/system-manage/hospitals.vue'),
},
{
path: '/system-manage/hospitals-map',
name: '合作医院地图',
component: () => import('@/views/system-manage/hospitals-map.vue'),
},
{
path: '/system-manage/user-list',
name: '用户列表',
component: () => import('@/views/system-manage/user-list.vue'),
}
]
},
{
path: '/logs-manage',
name: '日志管理',
redirect: '/logs-manage/message-manage',
component: () => import('@/views/logs-manage/index.vue'),
children: [
{
path: '/logs-manage/message-manage',
name: '消息管理',
component: () => import('@/views/logs-manage/message-manage.vue'),
},
{
path: '/logs-manage/logs-manage',
name: '日志管理',
component: () => import('@/views/logs-manage/logs-manage.vue'),
}
]
}
]
}
]
}) })
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {

131
src/router/routes.ts Normal file
View File

@ -0,0 +1,131 @@
export const constantRoute=[
{ path: '/:pathMatch(.*)*', name: 'not-found', redirect: '/home' },
{
path: '/login',
name: '登录',
component: () => import('@/views/login/login.vue'),
},
{
path: '/',
redirect: '/home',
component: () => import('@/views/index.vue'),
children: [
{
path: '/home',
name: '首页',
component: () => import('@/views/home/index.vue'),
},
{
path: '/permissions-manage',
name: '权限管理',
redirect: '/permissions-manage/doctor-manage',
component: () => import('@/views/permissions-manage/index.vue'),
children: [
{
path: '/permissions-manage/doctor-manage',
name: '医生管理',
component: () => import('@/views/permissions-manage/doctor-manage.vue'),
},
{
path: '/permissions-manage/role-manage',
name: '角色管理',
component: () => import('@/views/permissions-manage/role-manage.vue'),
},
{
path: '/permissions-manage/menu-manage',
name: '菜单管理',
component: () => import('@/views/permissions-manage/menu-manage.vue'),
}
]
},
{
path: '/patients-manage',
name: '患者管理',
redirect: '/patients-manage/patients-manage',
component: () => import('@/views/patients-manage/index.vue'),
children: [
{
path: '/patients-manage/patients-manage',
name: '患者管理',
component: () => import('@/views/patients-manage/patients-manage.vue'),
},
{
path: '/patients-manage/surgery-info',
name: '手术信息',
component: () => import('@/views/patients-manage/surgery-info.vue'),
}
]
},
{
path: '/remote-manage',
name: '远程管理',
redirect: '/remote-manage/remote-manage',
component: () => import('@/views/remote-manage/index.vue'),
children: [
{
path: '/remote-manage/remote-manage',
name: '远程管理',
component: () => import('@/views/remote-manage/remote-manage.vue'),
},
{
path: '/remote-manage/remote-thumbnail',
name: '预览缩略图',
component: () => import('@/views/remote-manage/remote-thumbnail.vue'),
},
{
path: '/remote-manage/remote-control',
name: '远程控制',
component: () => import('@/views/remote-manage/remote-control.vue'),
}
]
},
{
path: '/system-manage',
name: '后台管理',
redirect: '/system-manage/system-home',
component: () => import('@/views/system-manage/index.vue'),
children: [
{
path: '/system-manage/system-home',
name: '后台首页',
component: () => import('@/views/system-manage/system-home.vue'),
},
{
path: '/system-manage/hospitals',
name: '合作医院',
component: () => import('@/views/system-manage/hospitals.vue'),
},
{
path: '/system-manage/hospitals-map',
name: '合作医院地图',
component: () => import('@/views/system-manage/hospitals-map.vue'),
},
{
path: '/system-manage/user-list',
name: '用户列表',
component: () => import('@/views/system-manage/user-list.vue'),
}
]
},
{
path: '/logs-manage',
name: '日志管理',
redirect: '/logs-manage/message-manage',
component: () => import('@/views/logs-manage/index.vue'),
children: [
{
path: '/logs-manage/message-manage',
name: '消息管理',
component: () => import('@/views/logs-manage/message-manage.vue'),
},
{
path: '/logs-manage/logs-manage',
name: '日志管理',
component: () => import('@/views/logs-manage/logs-manage.vue'),
}
]
}
]
}
]