@vxe-ui/core 4.0.22 → 4.0.24

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.
Files changed (86) hide show
  1. package/LICENSE +21 -21
  2. package/README.en.md +31 -31
  3. package/README.md +31 -31
  4. package/README.zh-TW.md +31 -31
  5. package/es/src/core.js +1 -1
  6. package/es/src/event.js +10 -8
  7. package/es/src/log.js +1 -1
  8. package/lib/index.umd.js +942 -145
  9. package/lib/index.umd.min.js +1 -1
  10. package/lib/src/clipboard.min.js +1 -1
  11. package/lib/src/commands.min.js +1 -1
  12. package/lib/src/config.min.js +1 -1
  13. package/lib/src/configStore.min.js +1 -1
  14. package/lib/src/core.js +1 -1
  15. package/lib/src/core.min.js +1 -1
  16. package/lib/src/dataStore.min.js +1 -1
  17. package/lib/src/event.js +10 -8
  18. package/lib/src/event.min.js +1 -1
  19. package/lib/src/formats.min.js +1 -1
  20. package/lib/src/hooks.min.js +1 -1
  21. package/lib/src/i18n.min.js +1 -1
  22. package/lib/src/i18nStore.min.js +1 -1
  23. package/lib/src/icon.min.js +1 -1
  24. package/lib/src/iconStore.min.js +1 -1
  25. package/lib/src/interceptor.min.js +1 -1
  26. package/lib/src/log.js +1 -1
  27. package/lib/src/log.min.js +1 -1
  28. package/lib/src/menus.min.js +1 -1
  29. package/lib/src/permission.min.js +1 -1
  30. package/lib/src/renderer.min.js +1 -1
  31. package/lib/src/resize.min.js +1 -1
  32. package/lib/src/store.min.js +1 -1
  33. package/lib/src/theme.min.js +1 -1
  34. package/lib/src/themeStore.min.js +1 -1
  35. package/lib/src/useFns.min.js +1 -1
  36. package/lib/src/validators.min.js +1 -1
  37. package/package.json +79 -79
  38. package/packages/index.ts +117 -117
  39. package/packages/src/clipboard.ts +53 -53
  40. package/packages/src/commands.ts +62 -62
  41. package/packages/src/config.ts +30 -30
  42. package/packages/src/configStore.ts +8 -8
  43. package/packages/src/core.ts +9 -9
  44. package/packages/src/dataStore.ts +4 -4
  45. package/packages/src/event.ts +127 -125
  46. package/packages/src/formats.ts +62 -62
  47. package/packages/src/hooks.ts +5 -5
  48. package/packages/src/i18n.ts +43 -43
  49. package/packages/src/i18nStore.ts +11 -11
  50. package/packages/src/icon.ts +16 -16
  51. package/packages/src/iconStore.ts +3 -3
  52. package/packages/src/interceptor.ts +65 -65
  53. package/packages/src/log.ts +19 -19
  54. package/packages/src/menus.ts +62 -62
  55. package/packages/src/permission.ts +61 -61
  56. package/packages/src/renderer.ts +50 -50
  57. package/packages/src/resize.ts +89 -89
  58. package/packages/src/store.ts +49 -49
  59. package/packages/src/theme.ts +20 -20
  60. package/packages/src/themeStore.ts +7 -7
  61. package/packages/src/useFns.ts +34 -34
  62. package/packages/src/validators.ts +9 -9
  63. package/types/core/clipboard.d.ts +13 -13
  64. package/types/core/commands.d.ts +19 -19
  65. package/types/core/components.d.ts +4 -4
  66. package/types/core/formats.d.ts +19 -19
  67. package/types/core/global-config.d.ts +62 -62
  68. package/types/core/global-data.d.ts +7 -7
  69. package/types/core/global-event.d.ts +39 -39
  70. package/types/core/global-icon.d.ts +6 -6
  71. package/types/core/global-lang.d.ts +22 -22
  72. package/types/core/global-resize.d.ts +3 -3
  73. package/types/core/global-theme.d.ts +1 -1
  74. package/types/core/hooks.d.ts +14 -14
  75. package/types/core/index.d.ts +255 -255
  76. package/types/core/interceptor.d.ts +22 -22
  77. package/types/core/log.d.ts +8 -8
  78. package/types/core/menus.d.ts +19 -19
  79. package/types/core/permission.d.ts +10 -10
  80. package/types/core/renderer.d.ts +14 -14
  81. package/types/core/useFn.d.ts +27 -27
  82. package/types/core/validators.d.ts +19 -19
  83. package/types/index.d.ts +13 -13
  84. package/types/tool/common.d.ts +111 -111
  85. package/types/tool/index.d.ts +2 -2
  86. package/types/tool/util.d.ts +4 -4
@@ -1,19 +1,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
- }
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
+ }
@@ -1,62 +1,62 @@
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
- if (process.env.VUE_APP_VXE_ENV === 'development') {
29
- log.warn('vxe.error.delProp', ['menus -> callback', 'menuMethod'])
30
- }
31
- render = {
32
- menuMethod: render
33
- }
34
- }
35
-
36
- // 检测是否覆盖
37
- if (process.env.VUE_APP_VXE_ENV === 'development') {
38
- const confKeys = XEUtils.keys(conf)
39
- XEUtils.each(render, (item, key) => {
40
- if (confKeys.includes(key)) {
41
- log.warn('vxe.error.coverProp', [name, key])
42
- }
43
- })
44
- }
45
- this.store[name] = conf ? XEUtils.merge(conf, render) : render
46
- return this
47
- }
48
-
49
- delete (name: string): void {
50
- delete this.store[name]
51
- }
52
-
53
- forEach (callback: any): void {
54
- XEUtils.objectEach(this.store, callback)
55
- }
56
- }
57
-
58
- export const menus = new VXEMenusStore() as VxeGlobalMenus
59
-
60
- if (process.env.VUE_APP_VXE_ENV === 'development') {
61
- Object.assign(menus, { _name: 'Menus' })
62
- }
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
+ if (process.env.VUE_APP_VXE_ENV === 'development') {
29
+ log.warn('vxe.error.delProp', ['menus -> callback', 'menuMethod'])
30
+ }
31
+ render = {
32
+ menuMethod: render
33
+ }
34
+ }
35
+
36
+ // 检测是否覆盖
37
+ if (process.env.VUE_APP_VXE_ENV === 'development') {
38
+ const confKeys = XEUtils.keys(conf)
39
+ XEUtils.each(render, (item, key) => {
40
+ if (confKeys.includes(key)) {
41
+ log.warn('vxe.error.coverProp', [name, key])
42
+ }
43
+ })
44
+ }
45
+ this.store[name] = conf ? XEUtils.merge(conf, render) : render
46
+ return this
47
+ }
48
+
49
+ delete (name: string): void {
50
+ delete this.store[name]
51
+ }
52
+
53
+ forEach (callback: any): void {
54
+ XEUtils.objectEach(this.store, callback)
55
+ }
56
+ }
57
+
58
+ export const menus = new VXEMenusStore() as VxeGlobalMenus
59
+
60
+ if (process.env.VUE_APP_VXE_ENV === 'development') {
61
+ Object.assign(menus, { _name: 'Menus' })
62
+ }
@@ -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 (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
- }
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
+ }
@@ -1,50 +1,50 @@
1
- import XEUtils from 'xe-utils'
2
- import { log } from './log'
3
-
4
- import { VxeGlobalRenderer, VxeGlobalRendererOptions } from '../../types'
5
-
6
- /**
7
- * 内置的组件渲染
8
- */
9
- const renderMap: Record<string, VxeGlobalRendererOptions> = {}
10
-
11
- /**
12
- * 全局渲染器
13
- */
14
- export const renderer: VxeGlobalRenderer = {
15
- mixin (opts) {
16
- XEUtils.each(opts, (options, name) => renderer.add(name, options))
17
- return renderer
18
- },
19
- get (name: string) {
20
- return renderMap[name] || null
21
- },
22
- add (name, options) {
23
- if (name && options) {
24
- const renders: any = renderMap[name]
25
- if (renders) {
26
- // 检测是否覆盖
27
- if (process.env.VUE_APP_VXE_ENV === 'development') {
28
- XEUtils.each(options, (val, key) => {
29
- if (!XEUtils.eqNull(renders[key]) && renders[key] !== val) {
30
- log.warn('vxe.error.coverProp', [`Renderer.${name}`, key])
31
- }
32
- })
33
- }
34
-
35
- Object.assign(renders, options)
36
- } else {
37
- renderMap[name] = options
38
- }
39
- }
40
- return renderer
41
- },
42
- forEach (callback) {
43
- XEUtils.objectEach(renderMap, callback)
44
- return renderer
45
- },
46
- delete (name) {
47
- delete renderMap[name]
48
- return renderer
49
- }
50
- }
1
+ import XEUtils from 'xe-utils'
2
+ import { log } from './log'
3
+
4
+ import { VxeGlobalRenderer, VxeGlobalRendererOptions } from '../../types'
5
+
6
+ /**
7
+ * 内置的组件渲染
8
+ */
9
+ const renderMap: Record<string, VxeGlobalRendererOptions> = {}
10
+
11
+ /**
12
+ * 全局渲染器
13
+ */
14
+ export const renderer: VxeGlobalRenderer = {
15
+ mixin (opts) {
16
+ XEUtils.each(opts, (options, name) => renderer.add(name, options))
17
+ return renderer
18
+ },
19
+ get (name: string) {
20
+ return renderMap[name] || null
21
+ },
22
+ add (name, options) {
23
+ if (name && options) {
24
+ const renders: any = renderMap[name]
25
+ if (renders) {
26
+ // 检测是否覆盖
27
+ if (process.env.VUE_APP_VXE_ENV === 'development') {
28
+ XEUtils.each(options, (val, key) => {
29
+ if (!XEUtils.eqNull(renders[key]) && renders[key] !== val) {
30
+ log.warn('vxe.error.coverProp', [`Renderer.${name}`, key])
31
+ }
32
+ })
33
+ }
34
+
35
+ Object.assign(renders, options)
36
+ } else {
37
+ renderMap[name] = options
38
+ }
39
+ }
40
+ return renderer
41
+ },
42
+ forEach (callback) {
43
+ XEUtils.objectEach(renderMap, callback)
44
+ return renderer
45
+ },
46
+ delete (name) {
47
+ delete renderMap[name]
48
+ return renderer
49
+ }
50
+ }
@@ -1,89 +1,89 @@
1
- import XEUtils from 'xe-utils'
2
- import { globalConfigStore } from './configStore'
3
-
4
- import { VxeGlobalResize } from '../../types'
5
-
6
- /**
7
- * 监听 resize 事件
8
- * 如果项目中已使用了 resize-observer-polyfill,那么只需要将方法定义全局,该组件就会自动使用
9
- */
10
- let resizeTimeout: any
11
- /* eslint-disable no-use-before-define */
12
- const eventStore: XEResizeObserver[] = []
13
- const defaultInterval = 500
14
-
15
- function eventHandle () {
16
- if (eventStore.length) {
17
- eventStore.forEach((item) => {
18
- item.tarList.forEach((observer) => {
19
- const { target, width, heighe } = observer
20
- const clientWidth = target.clientWidth
21
- const clientHeight = target.clientHeight
22
- const rWidth = clientWidth && width !== clientWidth
23
- const rHeight = clientHeight && heighe !== clientHeight
24
- if (rWidth || rHeight) {
25
- observer.width = clientWidth
26
- observer.heighe = clientHeight
27
- setTimeout(item.callback)
28
- }
29
- })
30
- })
31
- /* eslint-disable @typescript-eslint/no-use-before-define */
32
- eventListener()
33
- }
34
- }
35
-
36
- function eventListener () {
37
- clearTimeout(resizeTimeout)
38
- resizeTimeout = setTimeout(eventHandle, globalConfigStore.resizeInterval || defaultInterval)
39
- }
40
-
41
- class XEResizeObserver {
42
- tarList: {
43
- target: Element;
44
- width: number;
45
- heighe: number;
46
- }[] = []
47
-
48
- callback: (...args: any[]) => void
49
-
50
- constructor (callback: (...args: any[]) => void) {
51
- this.callback = callback
52
- }
53
-
54
- observe (target: Element): void {
55
- if (target) {
56
- const { tarList } = this
57
- if (!tarList.some(observer => observer.target === target)) {
58
- tarList.push({
59
- target,
60
- width: target.clientWidth,
61
- heighe: target.clientHeight
62
- })
63
- }
64
- if (!eventStore.length) {
65
- eventListener()
66
- }
67
- if (!eventStore.some((item) => item === this)) {
68
- eventStore.push(this)
69
- }
70
- }
71
- }
72
-
73
- unobserve (target: Element): void {
74
- XEUtils.remove(eventStore, item => item.tarList.some(observer => observer.target === target))
75
- }
76
-
77
- disconnect (): void {
78
- XEUtils.remove(eventStore, item => item === this)
79
- }
80
- }
81
-
82
- export const globalResize: VxeGlobalResize = {
83
- create (callback: (...args: any[]) => void) {
84
- if (window.ResizeObserver) {
85
- return new window.ResizeObserver(callback)
86
- }
87
- return new XEResizeObserver(callback)
88
- }
89
- }
1
+ import XEUtils from 'xe-utils'
2
+ import { globalConfigStore } from './configStore'
3
+
4
+ import { VxeGlobalResize } from '../../types'
5
+
6
+ /**
7
+ * 监听 resize 事件
8
+ * 如果项目中已使用了 resize-observer-polyfill,那么只需要将方法定义全局,该组件就会自动使用
9
+ */
10
+ let resizeTimeout: any
11
+ /* eslint-disable no-use-before-define */
12
+ const eventStore: XEResizeObserver[] = []
13
+ const defaultInterval = 500
14
+
15
+ function eventHandle () {
16
+ if (eventStore.length) {
17
+ eventStore.forEach((item) => {
18
+ item.tarList.forEach((observer) => {
19
+ const { target, width, heighe } = observer
20
+ const clientWidth = target.clientWidth
21
+ const clientHeight = target.clientHeight
22
+ const rWidth = clientWidth && width !== clientWidth
23
+ const rHeight = clientHeight && heighe !== clientHeight
24
+ if (rWidth || rHeight) {
25
+ observer.width = clientWidth
26
+ observer.heighe = clientHeight
27
+ setTimeout(item.callback)
28
+ }
29
+ })
30
+ })
31
+ /* eslint-disable @typescript-eslint/no-use-before-define */
32
+ eventListener()
33
+ }
34
+ }
35
+
36
+ function eventListener () {
37
+ clearTimeout(resizeTimeout)
38
+ resizeTimeout = setTimeout(eventHandle, globalConfigStore.resizeInterval || defaultInterval)
39
+ }
40
+
41
+ class XEResizeObserver {
42
+ tarList: {
43
+ target: Element;
44
+ width: number;
45
+ heighe: number;
46
+ }[] = []
47
+
48
+ callback: (...args: any[]) => void
49
+
50
+ constructor (callback: (...args: any[]) => void) {
51
+ this.callback = callback
52
+ }
53
+
54
+ observe (target: Element): void {
55
+ if (target) {
56
+ const { tarList } = this
57
+ if (!tarList.some(observer => observer.target === target)) {
58
+ tarList.push({
59
+ target,
60
+ width: target.clientWidth,
61
+ heighe: target.clientHeight
62
+ })
63
+ }
64
+ if (!eventStore.length) {
65
+ eventListener()
66
+ }
67
+ if (!eventStore.some((item) => item === this)) {
68
+ eventStore.push(this)
69
+ }
70
+ }
71
+ }
72
+
73
+ unobserve (target: Element): void {
74
+ XEUtils.remove(eventStore, item => item.tarList.some(observer => observer.target === target))
75
+ }
76
+
77
+ disconnect (): void {
78
+ XEUtils.remove(eventStore, item => item === this)
79
+ }
80
+ }
81
+
82
+ export const globalResize: VxeGlobalResize = {
83
+ create (callback: (...args: any[]) => void) {
84
+ if (window.ResizeObserver) {
85
+ return new window.ResizeObserver(callback)
86
+ }
87
+ return new XEResizeObserver(callback)
88
+ }
89
+ }
@@ -1,49 +1,49 @@
1
- import { log } from './log'
2
- import XEUtils from 'xe-utils'
3
-
4
- /**
5
- * 创建数据仓库
6
- */
7
- export class Store {
8
- private store: any = {}
9
-
10
- mixin (options: any): Store {
11
- XEUtils.each(options, (item, key) => {
12
- this.add(key, item)
13
- })
14
- return this
15
- }
16
-
17
- has (name: string): boolean {
18
- return !!this.get(name)
19
- }
20
-
21
- get (name: string): any {
22
- return this.store[name]
23
- }
24
-
25
- add (name: string, options: any): Store {
26
- const conf = this.store[name]
27
- // 检测是否覆盖
28
- if (process.env.VUE_APP_VXE_ENV === 'development') {
29
- const confKeys = XEUtils.keys(conf)
30
- XEUtils.each(options, (item, key) => {
31
- if (confKeys.includes(key)) {
32
- log.warn('vxe.error.coverProp', [name, key])
33
- }
34
- })
35
- }
36
- this.store[name] = conf ? XEUtils.merge(conf, options) : options
37
- return this
38
- }
39
-
40
- delete (name: string): void {
41
- delete this.store[name]
42
- }
43
-
44
- forEach (callback: any): void {
45
- XEUtils.objectEach(this.store, callback)
46
- }
47
- }
48
-
49
- export default Store
1
+ import { log } from './log'
2
+ import XEUtils from 'xe-utils'
3
+
4
+ /**
5
+ * 创建数据仓库
6
+ */
7
+ export class Store {
8
+ private store: any = {}
9
+
10
+ mixin (options: any): Store {
11
+ XEUtils.each(options, (item, key) => {
12
+ this.add(key, item)
13
+ })
14
+ return this
15
+ }
16
+
17
+ has (name: string): boolean {
18
+ return !!this.get(name)
19
+ }
20
+
21
+ get (name: string): any {
22
+ return this.store[name]
23
+ }
24
+
25
+ add (name: string, options: any): Store {
26
+ const conf = this.store[name]
27
+ // 检测是否覆盖
28
+ if (process.env.VUE_APP_VXE_ENV === 'development') {
29
+ const confKeys = XEUtils.keys(conf)
30
+ XEUtils.each(options, (item, key) => {
31
+ if (confKeys.includes(key)) {
32
+ log.warn('vxe.error.coverProp', [name, key])
33
+ }
34
+ })
35
+ }
36
+ this.store[name] = conf ? XEUtils.merge(conf, options) : options
37
+ return this
38
+ }
39
+
40
+ delete (name: string): void {
41
+ delete this.store[name]
42
+ }
43
+
44
+ forEach (callback: any): void {
45
+ XEUtils.objectEach(this.store, callback)
46
+ }
47
+ }
48
+
49
+ export default Store