由于本次代码变更内容为空,无法生成有效的提交信息。请提供具体的代码变更内容以便生成合适的提交信息。
This commit is contained in:
@@ -98,6 +98,18 @@ const routes: RouteRecordRaw[] = [
|
||||
layout: 'main' // 添加布局信息
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/permission',
|
||||
name: 'Permission',
|
||||
component: () => import('@/pages/permission/index.vue'),
|
||||
meta: {
|
||||
requiresAuth: true,
|
||||
title: '权限管理',
|
||||
icon: 'LockOutlined',
|
||||
permissions: ['system:read'],
|
||||
layout: 'main' // 添加布局信息
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/system',
|
||||
name: 'System',
|
||||
@@ -110,6 +122,12 @@ const routes: RouteRecordRaw[] = [
|
||||
layout: 'main' // 添加布局信息
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/no-permission',
|
||||
name: 'NoPermission',
|
||||
component: () => import('@/pages/NoPermission.vue'),
|
||||
meta: { requiresAuth: true }
|
||||
},
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
name: 'NotFound',
|
||||
@@ -147,6 +165,18 @@ router.beforeEach(async (to, from, next) => {
|
||||
return
|
||||
}
|
||||
|
||||
// 检查权限
|
||||
if (meta.requiresAuth && isAuthenticated && meta.permissions) {
|
||||
// 检查用户是否拥有访问该路由所需的权限
|
||||
const requiredPermissions = Array.isArray(meta.permissions) ? meta.permissions : [meta.permissions]
|
||||
|
||||
// 如果用户没有所有必需的权限,则重定向到无权限页面
|
||||
if (!appStore.hasAllPermissions(requiredPermissions)) {
|
||||
next({ name: 'NoPermission' })
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
next()
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user