Skip to content

Commit

Permalink
releases 4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Aug 5, 2024
1 parent d23d4c8 commit d4fdfba
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vxe-ui/core",
"version": "1.0.13",
"version": "4.0.0",
"description": "Vxe UI core library",
"scripts": {
"update": "npm install --legacy-peer-deps",
Expand Down
48 changes: 35 additions & 13 deletions packages/src/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,45 @@ import XEUtils from 'xe-utils'

import type { VxeGlobalPermission, VxeComponentPermissionCodeType, VxeComponentPermissionInfo, VxeComponentPermissionMethod } from '../../types'

export function handleCheckInfo (code?: VxeComponentPermissionCodeType, permissionMethod?: VxeComponentPermissionMethod) {
let visible = true
let disabled = false
export function handleCheckInfo (permissionCode?: VxeComponentPermissionCodeType, permissionMethod?: VxeComponentPermissionMethod) {
let checkVisible = true
let checkDisabled = false
const checkMethod = permissionMethod || globalConfigStore.permissionMethod
if (code && checkMethod) {
const rest = checkMethod({ code })
if (XEUtils.isBoolean(rest)) {
visible = rest
} else if (rest) {
visible = !!rest.visible
disabled = !!rest.disabled
if (permissionCode && checkMethod) {
checkVisible = false
checkDisabled = true
let vDone = false
let dDone = false
// 或 使用 | 隔开:任意一个为可视,则可视;任意一个禁用,则禁用
const codeList = String(permissionCode).split('|')
for (let i = 0; i < codeList.length; i++) {
const code = codeList[i]
let visible = true
let disabled = false
const rest = checkMethod({ code })
if (XEUtils.isBoolean(rest)) {
visible = rest
} else if (rest) {
visible = !!rest.visible
disabled = !!rest.disabled
}
if (!disabled && !dDone) {
dDone = true
checkDisabled = disabled
}
if (visible && !vDone) {
vDone = true
checkVisible = visible
}
if (vDone && dDone) {
break
}
}
}
const info: VxeComponentPermissionInfo = {
code,
visible,
disabled
code: permissionCode,
visible: checkVisible,
disabled: checkDisabled
}
return info
}
Expand Down

0 comments on commit d4fdfba

Please sign in to comment.