@vxe-ui/core 4.4.42 → 4.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all.esm.js +1594 -1389
- package/dist/all.esm.min.js +1 -0
- package/es/index.d.ts +138 -0
- package/es/index.esm.js +138 -125
- package/es/index.js +150 -0
- package/es/src/base-utils.d.ts +2 -0
- package/es/src/base-utils.js +40 -37
- package/es/src/clipboard.d.ts +2 -0
- package/es/src/clipboard.js +48 -45
- package/es/src/commands.d.ts +2 -0
- package/es/src/commands.js +47 -48
- package/es/src/config.d.ts +13 -0
- package/es/src/config.js +21 -23
- package/es/src/configStore.d.ts +2 -0
- package/es/src/configStore.js +8 -5
- package/es/src/core.d.ts +3 -0
- package/es/src/core.js +11 -7
- package/es/src/dataStore.d.ts +2 -0
- package/es/src/dataStore.js +4 -1
- package/es/src/db-utils.d.ts +2 -0
- package/es/src/db-utils.js +234 -0
- package/es/src/dom-utils.d.ts +2 -0
- package/es/src/dom-utils.js +65 -68
- package/es/src/event.d.ts +4 -0
- package/es/src/event.js +133 -147
- package/es/src/formats.d.ts +2 -0
- package/es/src/formats.js +47 -48
- package/es/src/hooks.d.ts +2 -0
- package/es/src/hooks.js +5 -2
- package/es/src/i18n.d.ts +6 -0
- package/es/src/i18n.js +51 -44
- package/es/src/i18nStore.d.ts +5 -0
- package/es/src/i18nStore.js +7 -4
- package/es/src/icon.d.ts +9 -0
- package/es/src/icon.js +28 -22
- package/es/src/iconStore.d.ts +2 -0
- package/es/src/iconStore.js +4 -1
- package/es/src/interceptor.d.ts +2 -0
- package/es/src/interceptor.js +52 -54
- package/es/src/log.d.ts +2 -0
- package/es/src/log.js +14 -11
- package/es/src/menus.d.ts +2 -0
- package/es/src/menus.js +47 -48
- package/es/src/permission.d.ts +3 -0
- package/es/src/permission.js +57 -55
- package/es/src/popper-utils.d.ts +2 -0
- package/es/src/popper-utils.js +159 -179
- package/es/src/renderer.d.ts +5 -0
- package/es/src/renderer.js +37 -42
- package/es/src/resize.d.ts +2 -0
- package/es/src/resize.js +60 -70
- package/es/src/scrollbar-utils.d.ts +2 -0
- package/es/src/scrollbar-utils.js +57 -54
- package/es/src/store.d.ts +13 -0
- package/es/src/store.js +43 -45
- package/es/src/theme.d.ts +3 -0
- package/es/src/theme.js +17 -13
- package/es/src/themeStore.d.ts +4 -0
- package/es/src/themeStore.js +5 -2
- package/es/src/useFns.d.ts +40 -0
- package/es/src/useFns.js +212 -231
- package/es/src/validators.d.ts +2 -0
- package/es/src/validators.js +6 -3
- package/es/src/vm.d.ts +2 -0
- package/es/src/vm.js +9 -6
- package/es/src/z-index.d.ts +2 -0
- package/es/src/z-index.js +29 -26
- package/lib/index.common.js +136 -365
- package/lib/index.js +181 -0
- package/lib/index.umd.js +819 -3343
- package/lib/index.umd.min.js +1 -1
- package/lib/src/base-utils.js +39 -13
- package/lib/src/clipboard.js +50 -23
- package/lib/src/commands.js +46 -27
- package/lib/src/config.js +43 -23
- package/lib/src/configStore.js +24 -7
- package/lib/src/core.js +29 -11
- package/lib/src/dataStore.js +22 -5
- package/lib/src/db-utils.js +263 -0
- package/lib/src/dom-utils.js +40 -20
- package/lib/src/event.js +95 -102
- package/lib/src/formats.js +46 -27
- package/lib/src/hooks.js +33 -7
- package/lib/src/i18n.js +53 -38
- package/lib/src/i18nStore.js +25 -8
- package/lib/src/icon.js +46 -22
- package/lib/src/iconStore.js +22 -5
- package/lib/src/interceptor.js +40 -18
- package/lib/src/log.js +29 -12
- package/lib/src/menus.js +46 -27
- package/lib/src/permission.js +40 -17
- package/lib/src/popper-utils.js +71 -71
- package/lib/src/renderer.js +40 -21
- package/lib/src/resize.js +48 -42
- package/lib/src/scrollbar-utils.js +23 -6
- package/lib/src/store.js +44 -25
- package/lib/src/theme.js +31 -14
- package/lib/src/themeStore.js +24 -7
- package/lib/src/useFns.js +87 -124
- package/lib/src/validators.js +34 -10
- package/lib/src/vm.js +34 -8
- package/lib/src/z-index.js +38 -12
- package/package.json +14 -3
- package/packages/index.ts +171 -168
- package/packages/src/base-utils.ts +42 -43
- package/packages/src/clipboard.ts +56 -56
- package/packages/src/commands.ts +56 -56
- package/packages/src/config.ts +30 -30
- package/packages/src/configStore.ts +8 -8
- package/packages/src/core.ts +11 -11
- package/packages/src/dataStore.ts +3 -4
- package/packages/src/db-utils.ts +267 -0
- package/packages/src/dom-utils.ts +86 -87
- package/packages/src/event.ts +161 -161
- package/packages/src/formats.ts +56 -56
- package/packages/src/hooks.ts +5 -5
- package/packages/src/i18n.ts +63 -63
- package/packages/src/i18nStore.ts +11 -11
- package/packages/src/icon.ts +32 -32
- package/packages/src/iconStore.ts +3 -3
- package/packages/src/interceptor.ts +64 -64
- package/packages/src/log.ts +19 -19
- package/packages/src/menus.ts +56 -56
- package/packages/src/permission.ts +61 -61
- package/packages/src/popper-utils.ts +197 -194
- package/packages/src/renderer.ts +50 -50
- package/packages/src/resize.ts +89 -89
- package/packages/src/scrollbar-utils.ts +58 -58
- package/packages/src/store.ts +47 -47
- package/packages/src/theme.ts +20 -20
- package/packages/src/themeStore.ts +7 -7
- package/packages/src/useFns.ts +270 -275
- package/packages/src/validators.ts +7 -7
- package/packages/src/vm.ts +10 -10
- package/packages/src/z-index.ts +30 -30
- package/types/core/base-utils.d.ts +39 -40
- package/types/core/clipboard.d.ts +22 -22
- package/types/core/commands.d.ts +17 -19
- package/types/core/components.d.ts +5 -5
- package/types/core/db-utils.d.ts +44 -0
- package/types/core/dom-utils.d.ts +36 -37
- package/types/core/formats.d.ts +17 -19
- package/types/core/global-config.d.ts +67 -74
- package/types/core/global-data.d.ts +7 -7
- package/types/core/global-event.d.ts +48 -48
- package/types/core/global-icon.d.ts +10 -10
- package/types/core/global-lang.d.ts +28 -27
- package/types/core/global-resize.d.ts +3 -3
- package/types/core/global-theme.d.ts +1 -1
- package/types/core/hooks.d.ts +12 -14
- package/types/core/index.d.ts +343 -336
- package/types/core/interceptor.d.ts +20 -22
- package/types/core/log.d.ts +8 -8
- package/types/core/menus.d.ts +17 -19
- package/types/core/permission.d.ts +10 -10
- package/types/core/popper-utils.d.ts +44 -44
- package/types/core/renderer.d.ts +14 -14
- package/types/core/scrollbar-utils.d.ts +37 -38
- package/types/core/useFn.d.ts +121 -126
- package/types/core/validators.d.ts +17 -19
- package/types/core/z-index.d.ts +18 -18
- package/types/index.d.ts +13 -13
- package/types/tool/common.d.ts +146 -155
- package/types/tool/index.d.ts +2 -2
- package/types/tool/util.d.ts +4 -4
- package/lib/src/base-utils.min.js +0 -1
- package/lib/src/clipboard.min.js +0 -1
- package/lib/src/commands.min.js +0 -1
- package/lib/src/config.min.js +0 -1
- package/lib/src/configStore.min.js +0 -1
- package/lib/src/core.min.js +0 -1
- package/lib/src/dataStore.min.js +0 -1
- package/lib/src/dom-utils.min.js +0 -1
- package/lib/src/event.min.js +0 -1
- package/lib/src/formats.min.js +0 -1
- package/lib/src/hooks.min.js +0 -1
- package/lib/src/i18n.min.js +0 -1
- package/lib/src/i18nStore.min.js +0 -1
- package/lib/src/icon.min.js +0 -1
- package/lib/src/iconStore.min.js +0 -1
- package/lib/src/interceptor.min.js +0 -1
- package/lib/src/log.min.js +0 -1
- package/lib/src/menus.min.js +0 -1
- package/lib/src/permission.min.js +0 -1
- package/lib/src/popper-utils.min.js +0 -1
- package/lib/src/renderer.min.js +0 -1
- package/lib/src/resize.min.js +0 -1
- package/lib/src/scrollbar-utils.min.js +0 -1
- package/lib/src/store.min.js +0 -1
- package/lib/src/theme.min.js +0 -1
- package/lib/src/themeStore.min.js +0 -1
- package/lib/src/useFns.min.js +0 -1
- package/lib/src/validators.min.js +0 -1
- package/lib/src/vm.min.js +0 -1
- package/lib/src/z-index.min.js +0 -1
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
import XEUtils from 'xe-utils'
|
|
2
|
-
import { log } from './log'
|
|
3
|
-
|
|
4
|
-
import { VxeGlobalInterceptor, VxeGlobalInterceptorHandles } from '../../types'
|
|
5
|
-
|
|
6
|
-
const storeMap: { [type: string]: VxeGlobalInterceptorHandles.InterceptorCallback[] } = {}
|
|
7
|
-
|
|
8
|
-
export const interceptor: VxeGlobalInterceptor = {
|
|
9
|
-
mixin
|
|
10
|
-
XEUtils.each(options, (render, type) => {
|
|
11
|
-
interceptor.add(type, render)
|
|
12
|
-
})
|
|
13
|
-
return interceptor
|
|
14
|
-
},
|
|
15
|
-
get
|
|
16
|
-
if (type) {
|
|
17
|
-
return storeMap[type] || []
|
|
18
|
-
}
|
|
19
|
-
return []
|
|
20
|
-
},
|
|
21
|
-
add
|
|
22
|
-
// 兼容
|
|
23
|
-
if (XEUtils.isFunction(render)) {
|
|
24
|
-
// log.warn('vxe.error.delProp', ['interceptor -> callback', 'tableInterceptorMethod'])
|
|
25
|
-
render = {
|
|
26
|
-
tableInterceptorMethod: render
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
const callback = render.tableInterceptorMethod
|
|
30
|
-
|
|
31
|
-
if (callback) {
|
|
32
|
-
let eList = storeMap[type]
|
|
33
|
-
if (!eList) {
|
|
34
|
-
eList = storeMap[type] = []
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// 检测重复
|
|
38
|
-
if (eList.indexOf(callback) > -1) {
|
|
39
|
-
log.warn('vxe.error.coverProp', ['Interceptor', type])
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
eList.push(callback)
|
|
43
|
-
}
|
|
44
|
-
return interceptor
|
|
45
|
-
},
|
|
46
|
-
delete
|
|
47
|
-
const eList = storeMap[type]
|
|
48
|
-
if (eList) {
|
|
49
|
-
// 兼容
|
|
50
|
-
if (XEUtils.isFunction(render)) {
|
|
51
|
-
render = {
|
|
52
|
-
tableInterceptorMethod: render
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
const callback = render ? render.tableInterceptorMethod : null
|
|
56
|
-
|
|
57
|
-
if (callback) {
|
|
58
|
-
XEUtils.remove(eList, fn => fn === callback)
|
|
59
|
-
} else {
|
|
60
|
-
delete storeMap[type]
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
1
|
+
import XEUtils from 'xe-utils'
|
|
2
|
+
import { log } from './log'
|
|
3
|
+
|
|
4
|
+
import { VxeGlobalInterceptor, VxeGlobalInterceptorHandles } from '../../types'
|
|
5
|
+
|
|
6
|
+
const storeMap: { [type: string]: VxeGlobalInterceptorHandles.InterceptorCallback[] } = {}
|
|
7
|
+
|
|
8
|
+
export const interceptor: VxeGlobalInterceptor = {
|
|
9
|
+
mixin(options) {
|
|
10
|
+
XEUtils.each(options, (render, type) => {
|
|
11
|
+
interceptor.add(type, render)
|
|
12
|
+
})
|
|
13
|
+
return interceptor
|
|
14
|
+
},
|
|
15
|
+
get(type) {
|
|
16
|
+
if (type) {
|
|
17
|
+
return storeMap[type] || []
|
|
18
|
+
}
|
|
19
|
+
return []
|
|
20
|
+
},
|
|
21
|
+
add(type, render) {
|
|
22
|
+
// 兼容
|
|
23
|
+
if (XEUtils.isFunction(render)) {
|
|
24
|
+
// log.warn('vxe.error.delProp', ['interceptor -> callback', 'tableInterceptorMethod'])
|
|
25
|
+
render = {
|
|
26
|
+
tableInterceptorMethod: render
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const callback = render.tableInterceptorMethod
|
|
30
|
+
|
|
31
|
+
if (callback) {
|
|
32
|
+
let eList = storeMap[type]
|
|
33
|
+
if (!eList) {
|
|
34
|
+
eList = storeMap[type] = []
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// 检测重复
|
|
38
|
+
if (eList.indexOf(callback) > -1) {
|
|
39
|
+
log.warn('vxe.error.coverProp', ['Interceptor', type])
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
eList.push(callback)
|
|
43
|
+
}
|
|
44
|
+
return interceptor
|
|
45
|
+
},
|
|
46
|
+
delete(type: string, render) {
|
|
47
|
+
const eList = storeMap[type]
|
|
48
|
+
if (eList) {
|
|
49
|
+
// 兼容
|
|
50
|
+
if (XEUtils.isFunction(render)) {
|
|
51
|
+
render = {
|
|
52
|
+
tableInterceptorMethod: render
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const callback = render ? render.tableInterceptorMethod : null
|
|
56
|
+
|
|
57
|
+
if (callback) {
|
|
58
|
+
XEUtils.remove(eList, (fn) => fn === callback)
|
|
59
|
+
} else {
|
|
60
|
+
delete storeMap[type]
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
package/packages/src/log.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { getI18n } from './i18n'
|
|
2
|
-
|
|
3
|
-
import { VxeGlobalLog } from '../../types'
|
|
4
|
-
|
|
5
|
-
function createLog
|
|
6
|
-
return function (key: string, args?: any) {
|
|
7
|
-
const msg = `[vxe ${name || ''}] ${getI18n(key, args)}`
|
|
8
|
-
console[type](msg)
|
|
9
|
-
return msg
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const version = process.env.VUE_APP_VXE_VERSION
|
|
14
|
-
|
|
15
|
-
export const log: VxeGlobalLog = {
|
|
16
|
-
create: createLog,
|
|
17
|
-
warn: createLog('warn', `v${version}`),
|
|
18
|
-
err: createLog('error', `v${version}`)
|
|
19
|
-
}
|
|
1
|
+
import { getI18n } from './i18n'
|
|
2
|
+
|
|
3
|
+
import { VxeGlobalLog } from '../../types'
|
|
4
|
+
|
|
5
|
+
function createLog(type: 'log' | 'warn' | 'error', name?: string) {
|
|
6
|
+
return function (key: string, args?: any) {
|
|
7
|
+
const msg = `[vxe ${name || ''}] ${getI18n(key, args)}`
|
|
8
|
+
console[type](msg)
|
|
9
|
+
return msg
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const version = process.env.VUE_APP_VXE_VERSION
|
|
14
|
+
|
|
15
|
+
export const log: VxeGlobalLog = {
|
|
16
|
+
create: createLog,
|
|
17
|
+
warn: createLog('warn', `v${version}`),
|
|
18
|
+
err: createLog('error', `v${version}`)
|
|
19
|
+
}
|
package/packages/src/menus.ts
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import XEUtils from 'xe-utils'
|
|
2
|
-
import { log } from './log'
|
|
3
|
-
|
|
4
|
-
import { VxeGlobalMenus } from '../../types'
|
|
5
|
-
|
|
6
|
-
class VXEMenusStore {
|
|
7
|
-
private store: any = {}
|
|
8
|
-
|
|
9
|
-
mixin
|
|
10
|
-
XEUtils.each(options, (item, key) => {
|
|
11
|
-
this.add(key, item)
|
|
12
|
-
})
|
|
13
|
-
return this
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
has
|
|
17
|
-
return !!this.get(name)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
get
|
|
21
|
-
return this.store[name]
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
add
|
|
25
|
-
const conf = this.store[name]
|
|
26
|
-
// 兼容
|
|
27
|
-
if (XEUtils.isFunction(render)) {
|
|
28
|
-
log.warn('vxe.error.delProp', ['menus -> callback', 'menuMethod'])
|
|
29
|
-
render = {
|
|
30
|
-
menuMethod: render
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// 检测是否覆盖
|
|
35
|
-
const confKeys = XEUtils.keys(conf)
|
|
36
|
-
XEUtils.each(render, (item, key) => {
|
|
37
|
-
if (confKeys.includes(key)) {
|
|
38
|
-
log.warn('vxe.error.coverProp', [name, key])
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
this.store[name] = conf ? XEUtils.merge(conf, render) : render
|
|
42
|
-
return this
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
delete
|
|
46
|
-
delete this.store[name]
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
forEach
|
|
50
|
-
XEUtils.objectEach(this.store, callback)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export const menus = new VXEMenusStore() as VxeGlobalMenus
|
|
55
|
-
|
|
56
|
-
Object.assign(menus, { _name: 'Menus' })
|
|
1
|
+
import XEUtils from 'xe-utils'
|
|
2
|
+
import { log } from './log'
|
|
3
|
+
|
|
4
|
+
import { VxeGlobalMenus } from '../../types'
|
|
5
|
+
|
|
6
|
+
class VXEMenusStore {
|
|
7
|
+
private store: any = {}
|
|
8
|
+
|
|
9
|
+
mixin(options: any): VXEMenusStore {
|
|
10
|
+
XEUtils.each(options, (item, key) => {
|
|
11
|
+
this.add(key, item)
|
|
12
|
+
})
|
|
13
|
+
return this
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
has(name: string): boolean {
|
|
17
|
+
return !!this.get(name)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get(name: string): any {
|
|
21
|
+
return this.store[name]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
add(name: string, render: any): VXEMenusStore {
|
|
25
|
+
const conf = this.store[name]
|
|
26
|
+
// 兼容
|
|
27
|
+
if (XEUtils.isFunction(render)) {
|
|
28
|
+
log.warn('vxe.error.delProp', ['menus -> callback', 'menuMethod'])
|
|
29
|
+
render = {
|
|
30
|
+
menuMethod: render
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 检测是否覆盖
|
|
35
|
+
const confKeys = XEUtils.keys(conf)
|
|
36
|
+
XEUtils.each(render, (item, key) => {
|
|
37
|
+
if (confKeys.includes(key)) {
|
|
38
|
+
log.warn('vxe.error.coverProp', [name, key])
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
this.store[name] = conf ? XEUtils.merge(conf, render) : render
|
|
42
|
+
return this
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
delete(name: string): void {
|
|
46
|
+
delete this.store[name]
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
forEach(callback: any): void {
|
|
50
|
+
XEUtils.objectEach(this.store, callback)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const menus = new VXEMenusStore() as VxeGlobalMenus
|
|
55
|
+
|
|
56
|
+
Object.assign(menus, { _name: 'Menus' })
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import { globalConfigStore } from './configStore'
|
|
2
|
-
import XEUtils from 'xe-utils'
|
|
3
|
-
|
|
4
|
-
import type { VxeGlobalPermission, VxeComponentPermissionCodeType, VxeComponentPermissionInfo, VxeComponentPermissionMethod } from '../../types'
|
|
5
|
-
|
|
6
|
-
export function handleCheckInfo
|
|
7
|
-
let checkVisible = true
|
|
8
|
-
let checkDisabled = false
|
|
9
|
-
const checkMethod = permissionMethod || globalConfigStore.permissionMethod
|
|
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
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
const info: VxeComponentPermissionInfo = {
|
|
42
|
-
code: permissionCode,
|
|
43
|
-
visible: checkVisible,
|
|
44
|
-
disabled: checkDisabled
|
|
45
|
-
}
|
|
46
|
-
return info
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const permission: VxeGlobalPermission = {
|
|
50
|
-
getCheckInfo
|
|
51
|
-
return handleCheckInfo(code)
|
|
52
|
-
},
|
|
53
|
-
checkVisible
|
|
54
|
-
const permissionInfo = handleCheckInfo(code)
|
|
55
|
-
return permissionInfo.visible
|
|
56
|
-
},
|
|
57
|
-
checkDisable
|
|
58
|
-
const permissionInfo = handleCheckInfo(code)
|
|
59
|
-
return permissionInfo.disabled
|
|
60
|
-
}
|
|
61
|
-
}
|
|
1
|
+
import { globalConfigStore } from './configStore'
|
|
2
|
+
import XEUtils from 'xe-utils'
|
|
3
|
+
|
|
4
|
+
import type { VxeGlobalPermission, VxeComponentPermissionCodeType, VxeComponentPermissionInfo, VxeComponentPermissionMethod } from '../../types'
|
|
5
|
+
|
|
6
|
+
export function handleCheckInfo(permissionCode?: VxeComponentPermissionCodeType, permissionMethod?: VxeComponentPermissionMethod) {
|
|
7
|
+
let checkVisible = true
|
|
8
|
+
let checkDisabled = false
|
|
9
|
+
const checkMethod = permissionMethod || globalConfigStore.permissionMethod
|
|
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
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const info: VxeComponentPermissionInfo = {
|
|
42
|
+
code: permissionCode,
|
|
43
|
+
visible: checkVisible,
|
|
44
|
+
disabled: checkDisabled
|
|
45
|
+
}
|
|
46
|
+
return info
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const permission: VxeGlobalPermission = {
|
|
50
|
+
getCheckInfo(code) {
|
|
51
|
+
return handleCheckInfo(code)
|
|
52
|
+
},
|
|
53
|
+
checkVisible(code) {
|
|
54
|
+
const permissionInfo = handleCheckInfo(code)
|
|
55
|
+
return permissionInfo.visible
|
|
56
|
+
},
|
|
57
|
+
checkDisable(code) {
|
|
58
|
+
const permissionInfo = handleCheckInfo(code)
|
|
59
|
+
return permissionInfo.disabled
|
|
60
|
+
}
|
|
61
|
+
}
|