Skip to content

Commit d4fdfba

Browse files
committed
releases 4.0.0
1 parent d23d4c8 commit d4fdfba

File tree

2 files changed

+36
-14
lines changed

2 files changed

+36
-14
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vxe-ui/core",
3-
"version": "1.0.13",
3+
"version": "4.0.0",
44
"description": "Vxe UI core library",
55
"scripts": {
66
"update": "npm install --legacy-peer-deps",

packages/src/permission.ts

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,45 @@ import XEUtils from 'xe-utils'
33

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

6-
export function handleCheckInfo (code?: VxeComponentPermissionCodeType, permissionMethod?: VxeComponentPermissionMethod) {
7-
let visible = true
8-
let disabled = false
6+
export function handleCheckInfo (permissionCode?: VxeComponentPermissionCodeType, permissionMethod?: VxeComponentPermissionMethod) {
7+
let checkVisible = true
8+
let checkDisabled = false
99
const checkMethod = permissionMethod || globalConfigStore.permissionMethod
10-
if (code && checkMethod) {
11-
const rest = checkMethod({ code })
12-
if (XEUtils.isBoolean(rest)) {
13-
visible = rest
14-
} else if (rest) {
15-
visible = !!rest.visible
16-
disabled = !!rest.disabled
10+
if (permissionCode && checkMethod) {
11+
checkVisible = false
12+
checkDisabled = true
13+
let vDone = false
14+
let dDone = false
15+
// 或 使用 | 隔开:任意一个为可视,则可视;任意一个禁用,则禁用
16+
const codeList = String(permissionCode).split('|')
17+
for (let i = 0; i < codeList.length; i++) {
18+
const code = codeList[i]
19+
let visible = true
20+
let disabled = false
21+
const rest = checkMethod({ code })
22+
if (XEUtils.isBoolean(rest)) {
23+
visible = rest
24+
} else if (rest) {
25+
visible = !!rest.visible
26+
disabled = !!rest.disabled
27+
}
28+
if (!disabled && !dDone) {
29+
dDone = true
30+
checkDisabled = disabled
31+
}
32+
if (visible && !vDone) {
33+
vDone = true
34+
checkVisible = visible
35+
}
36+
if (vDone && dDone) {
37+
break
38+
}
1739
}
1840
}
1941
const info: VxeComponentPermissionInfo = {
20-
code,
21-
visible,
22-
disabled
42+
code: permissionCode,
43+
visible: checkVisible,
44+
disabled: checkDisabled
2345
}
2446
return info
2547
}

0 commit comments

Comments
 (0)