From e8225fbdee782bbabecda08d6d1a285e39c5ca3b Mon Sep 17 00:00:00 2001 From: MichelleChung <1242874891@qq.com> Date: 星期四, 02 二月 2023 16:15:52 +0800 Subject: [PATCH] !282 System 相关表请求响应参数优化 * update 更新 system 相关表接口 (sys_role) 新增 Bo | Vo 类, 更改请求以及响应参数 ; * update 更新 system 相关表接口 (sys_notice, sys_post) 新增 Bo | Vo 类, 更改请求以及响应参数 ; * update 更新 system 相关表接口 (sys_menu) 新增 Bo | Vo 类, 更改请求以及响应参数 ; * update 更新 system 相关表接口 (sys_dict_data, sys_dict_type) 新增 Bo | Vo 类, 更改请求以及响应参数 ; * update 更新 system 相关表接口 (sys_config, sys_dept) 新增 Bo | Vo 类, 更改请求以及响应参数 ; --- ruoyi-ui/src/utils/permission.js | 75 +++++++++++++++++++++++++------------ 1 files changed, 51 insertions(+), 24 deletions(-) diff --git a/ruoyi-ui/src/utils/permission.js b/ruoyi-ui/src/utils/permission.js index efb4cc8..bd4c066 100644 --- a/ruoyi-ui/src/utils/permission.js +++ b/ruoyi-ui/src/utils/permission.js @@ -1,24 +1,51 @@ -import store from '@/store' - -/** - * @param {Array} value - * @returns {Boolean} - */ -export default function checkPermission(value) { - if (value && value instanceof Array && value.length > 0) { - const roles = store.getters && store.getters.roles - const permissionRoles = value - - const hasPermission = roles.some(role => { - return permissionRoles.includes(role) - }) - - if (!hasPermission) { - return false - } - return true - } else { - console.error(`need roles! Like v-permission="['admin','editor']"`) - return false - } -} +import store from '@/store' + +/** + * 瀛楃鏉冮檺鏍¢獙 + * @param {Array} value 鏍¢獙鍊� + * @returns {Boolean} + */ +export function checkPermi(value) { + if (value && value instanceof Array && value.length > 0) { + const permissions = store.getters && store.getters.permissions + const permissionDatas = value + const all_permission = "*:*:*"; + + const hasPermission = permissions.some(permission => { + return all_permission === permission || permissionDatas.includes(permission) + }) + + if (!hasPermission) { + return false + } + return true + } else { + console.error(`need roles! Like checkPermi="['system:user:add','system:user:edit']"`) + return false + } +} + +/** + * 瑙掕壊鏉冮檺鏍¢獙 + * @param {Array} value 鏍¢獙鍊� + * @returns {Boolean} + */ +export function checkRole(value) { + if (value && value instanceof Array && value.length > 0) { + const roles = store.getters && store.getters.roles + const permissionRoles = value + const super_admin = "admin"; + + const hasRole = roles.some(role => { + return super_admin === role || permissionRoles.includes(role) + }) + + if (!hasRole) { + return false + } + return true + } else { + console.error(`need roles! Like checkRole="['admin','editor']"`) + return false + } +} -- Gitblit v1.9.3