@@ -26,6 +26,7 @@ const routes = [
|
||||
{ path: 'users', name: 'admin-users', component: () => import('@/views/admin/Users.vue'), meta: { title: '用户管理' } },
|
||||
{ path: 'roles', name: 'admin-roles', component: () => import('@/views/admin/Roles.vue'), meta: { title: '角色管理' } },
|
||||
{ path: 'projects', name: 'admin-projects', component: () => import('@/views/manager/Projects.vue'), meta: { title: '项目管理' } },
|
||||
{ path: 'projects/detail/:projectId', name: 'admin-projects-detail', component: () => import('@/views/manager/ManagerProjectDetail.vue'), meta: { title: '项目详情' } },
|
||||
{ path: 'meetings', name: 'admin-meetings', component: () => import('@/views/meetings/Meetings.vue'), meta: { title: '会议管理' } },
|
||||
{ path: 'meetings/detail/:meetingId', name: 'admin-meetings-detail', component: () => import('@/views/meetings/MeetingDetail.vue'), meta: { title: '会议详情' } },
|
||||
{ path: 'meetings/view/:meetingId', name: 'admin-meetings-view', component: () => import('@/views/meetings/MeetingDetail.vue'), meta: { title: '会议详情', readonly: true } },
|
||||
@@ -49,6 +50,7 @@ const routes = [
|
||||
{ path: 'article', name: 'admin-article', component: () => import('@/views/admin/BizArticleAdmin.vue'), meta: { title: '协议管理' } },
|
||||
{ path: 'article/edit/:id', name: 'admin-article-edit', component: () => import('@/views/admin/BizArticleEdit.vue'), meta: { title: '编辑文章' } },
|
||||
{ path: 'special-plan', name: 'admin-special-plan', component: () => import('@/views/admin/BizSpecialPlanAdmin.vue'), meta: { title: '专项计划管理' } },
|
||||
{ path: 'special-plan/new', name: 'admin-special-plan-new', component: () => import('@/views/admin/BizSpecialPlanEdit.vue'), meta: { title: '新建专项计划' } },
|
||||
{ path: 'special-plan/edit/:id', name: 'admin-special-plan-edit', component: () => import('@/views/admin/BizSpecialPlanEdit.vue'), meta: { title: '编辑专项计划' } },
|
||||
{ path: 'project-category', name: 'admin-project-category', component: () => import('@/views/admin/ProjectCategory.vue'), meta: { title: '项目类别管理' } },
|
||||
{ path: 'labor-protocol', name: 'admin-labor-protocol', component: () => import('@/views/admin/LaborProtocol.vue'), meta: { title: '劳务协议配置' } },
|
||||
@@ -109,7 +111,7 @@ const routes = [
|
||||
]
|
||||
},
|
||||
{ path: '/executor', component: AdminLayout, meta: { role: 'executor' }, children: [
|
||||
{ path: '', redirect: { name: 'executor-submissions' } },
|
||||
{ path: '', redirect: { name: 'executor-overview' } },
|
||||
{ path: 'overview', name: 'executor-overview', component: () => import('@/views/executor/Overview.vue'), meta: { title: '首页' } },
|
||||
{ path: 'submissions', name: 'executor-submissions', component: () => import('@/views/doctor/Submissions.vue'), meta: { title: '我的项目策划方案' } },
|
||||
{ path: 'submission/new', name: 'executor-submission-new', component: () => import('@/views/doctor/SubmissionNew.vue'), meta: { title: '新建项目策划方案' } },
|
||||
@@ -159,6 +161,15 @@ const router = createRouter({
|
||||
routes
|
||||
})
|
||||
|
||||
// 各角色首页映射 (role_type → 首页, 与 Login.vue roleHome 保持一致)
|
||||
const ROLE_HOME = {
|
||||
admin: '/admin/workbench',
|
||||
manager: '/manager/workbench',
|
||||
doctor: '/doctor/home',
|
||||
executor: '/executor/overview',
|
||||
sponsor: '/sponsor/home'
|
||||
}
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
document.title = (to.meta?.title || 'BAHIM') + ' - 合规系统'
|
||||
// 公开路由 (无 role meta) 不拦截
|
||||
@@ -168,7 +179,11 @@ router.beforeEach((to, from, next) => {
|
||||
// 扫码带 token 直登 (签劳务): 放行, 由页面 onMounted 用 token 完成登录
|
||||
if (!user && to.query?.token) return next()
|
||||
if (!user) return next({ name: 'login', query: { redirect: to.fullPath } })
|
||||
// 已登录: role 不匹配由后端 401 拦截, 不在前端强跳 (避免误判让用户卡死)
|
||||
// 已登录: 前端校验角色匹配 (role_type 单一可信源), 不匹配跳回自己角色首页
|
||||
const userRole = user.role
|
||||
if (userRole && to.meta.role !== userRole) {
|
||||
return next(ROLE_HOME[userRole] || '/')
|
||||
}
|
||||
next()
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user