提交 76a5f87c 编写于 作者: 无木

fix: `hasPermission` not work in `ROLE` Mode

上级 49e72a8e
### ✨ 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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册