mirror of
https://github.com/vbenjs/gf-vben-admin.git
synced 2025-02-03 03:32:59 +08:00
fix: hasPermission
not work in ROLE
Mode
This commit is contained in:
parent
49e72a8e76
commit
76a5f87c0c
@ -1,6 +1,7 @@
|
||||
### ✨ Features
|
||||
|
||||
- **Axios** 新增`withToken`配置,用于控制请求是否携带 token
|
||||
- **BasicUpload** 新增在预览 `Modal` 中删除文件时触发`preview-delete` 事件
|
||||
|
||||
### 🐛 Bug Fixes
|
||||
|
||||
@ -14,6 +15,8 @@
|
||||
- **LockScreen** 修复锁屏功能可以通过刷新页面或复制 URL 打开新的浏览器标签来跳过锁定状态的问题
|
||||
- 修复多个窗口同时打开页面时,`Token` 不会同步的问题
|
||||
- **Menu** 修复路由映射模式下,单级菜单刷新不会激活
|
||||
- 修复`ROLE`权限模式下`hasPermission`不工作的问题
|
||||
- **Table** 修复启用`clickToRowSelect`时,点击行不会触发`selection-change`事件的问题
|
||||
|
||||
## 2.5.2(2021-06-27)
|
||||
|
||||
|
@ -57,13 +57,14 @@ export function usePermission() {
|
||||
* Determine whether there is permission
|
||||
*/
|
||||
function hasPermission(value?: RoleEnum | RoleEnum[] | string | string[], def = true): boolean {
|
||||
// Visible by default
|
||||
if (!value) {
|
||||
return def;
|
||||
}
|
||||
|
||||
const permMode = projectSetting.permissionMode;
|
||||
|
||||
if (PermissionModeEnum.ROUTE_MAPPING === permMode) {
|
||||
// Visible by default
|
||||
if (!value) {
|
||||
return def;
|
||||
}
|
||||
if ([PermissionModeEnum.ROUTE_MAPPING, PermissionModeEnum.ROLE].includes(permMode)) {
|
||||
if (!isArray(value)) {
|
||||
return userStore.getRoleList?.includes(value as RoleEnum);
|
||||
}
|
||||
@ -71,10 +72,6 @@ export function usePermission() {
|
||||
}
|
||||
|
||||
if (PermissionModeEnum.BACK === permMode) {
|
||||
// Visible by default
|
||||
if (!value) {
|
||||
return def;
|
||||
}
|
||||
const allCodeList = permissionStore.getPermCodeList as string[];
|
||||
if (!isArray(value)) {
|
||||
return allCodeList.includes(value);
|
||||
|
Loading…
Reference in New Issue
Block a user