修复权限(前端路由):将敏感管理路由移至动态路由并对齐操作权限
This commit is contained in:
1 parent
1df99f28ca
commit
99cac94a5f
3 files changed
+38
-21
No files matched your search
@@ -97,31 +97,34 @@ export const constantRoutes = [
|
||||
meta: { title: '个人中心', icon: 'user' }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/train',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
redirect: '/train/auth',
|
||||
children: [
|
||||
{
|
||||
path: 'auth',
|
||||
component: () => import('@/views/train/auth/index'),
|
||||
name: 'DoorAuth',
|
||||
meta: { title: '门禁授权', icon: 'lock' }
|
||||
},
|
||||
{
|
||||
path: 'accommodation',
|
||||
component: () => import('@/views/train/accommodation/index'),
|
||||
name: 'TrainAccommodation',
|
||||
meta: { title: '住宿管理', icon: 'home' }
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
// 动态路由,基于用户权限动态去加载
|
||||
export const dynamicRoutes = [
|
||||
{
|
||||
path: '/train',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
redirect: '/train/auth',
|
||||
permissions: ['system:auth:list', 'train:accommodation:list'],
|
||||
children: [
|
||||
{
|
||||
path: 'auth',
|
||||
component: () => import('@/views/train/auth/index'),
|
||||
name: 'DoorAuth',
|
||||
meta: { title: '门禁授权', icon: 'lock' },
|
||||
permissions: ['system:auth:list']
|
||||
},
|
||||
{
|
||||
path: 'accommodation',
|
||||
component: () => import('@/views/train/accommodation/index'),
|
||||
name: 'TrainAccommodation',
|
||||
meta: { title: '住宿管理', icon: 'home' },
|
||||
permissions: ['train:accommodation:list']
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/system/user-auth',
|
||||
component: Layout,
|
||||
|
||||
@@ -112,7 +112,16 @@ export function filterDynamicRoutes(routes) {
|
||||
routes.forEach(route => {
|
||||
if (route.permissions) {
|
||||
if (auth.hasPermiOr(route.permissions)) {
|
||||
res.push(route)
|
||||
const copyRoute = { ...route }
|
||||
if (copyRoute.children && copyRoute.children.length) {
|
||||
copyRoute.children = copyRoute.children.filter(child => {
|
||||
if (child.permissions) {
|
||||
return auth.hasPermiOr(child.permissions)
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
res.push(copyRoute)
|
||||
}
|
||||
} else if (route.roles) {
|
||||
if (auth.hasRoleOr(route.roles)) {
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
v-hasPermi="['system:info:add']"
|
||||
@click="handleAdd"
|
||||
>新增成绩</el-button>
|
||||
</el-col>
|
||||
@@ -48,6 +49,7 @@
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
v-hasPermi="['system:info:edit']"
|
||||
@click="handleUpdate"
|
||||
>修改</el-button>
|
||||
</el-col>
|
||||
@@ -58,6 +60,7 @@
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
v-hasPermi="['system:info:remove']"
|
||||
@click="handleDelete"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
@@ -88,12 +91,14 @@
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
v-hasPermi="['system:info:edit']"
|
||||
@click="handleUpdate(scope.row)"
|
||||
>修改</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
v-hasPermi="['system:info:remove']"
|
||||
@click="handleDelete(scope.row)"
|
||||
>删除</el-button>
|
||||
</template>
|
||||
|
||||
Reference in new issue
Block a user