@vxe-ui/core 1.0.12 → 3.0.0-alpha.0
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/LICENSE +21 -21
- package/README.md +29 -31
- package/es/src/core.js +4 -4
- package/es/src/i18nStore.js +2 -3
- package/es/src/log.js +1 -1
- package/es/src/mixins.js +35 -0
- package/es/src/permission.js +36 -14
- package/lib/index.umd.js +187 -132
- package/lib/index.umd.min.js +1 -1
- package/lib/src/core.js +6 -6
- package/lib/src/core.min.js +1 -1
- package/lib/src/i18n.min.js +1 -1
- package/lib/src/i18nStore.js +2 -3
- package/lib/src/i18nStore.min.js +1 -1
- package/lib/src/log.js +1 -1
- package/lib/src/log.min.js +1 -1
- package/lib/src/mixins.js +44 -0
- package/lib/src/mixins.min.js +1 -0
- package/lib/src/permission.js +37 -15
- package/lib/src/permission.min.js +1 -1
- package/lib/src/resize.min.js +1 -1
- package/package.json +77 -78
- package/packages/index.ts +4 -4
- package/packages/src/clipboard.ts +53 -53
- package/packages/src/commands.ts +62 -62
- package/packages/src/core.ts +167 -167
- package/packages/src/event.ts +113 -113
- package/packages/src/formats.ts +62 -62
- package/packages/src/globalStore.ts +8 -8
- package/packages/src/hooks.ts +5 -5
- package/packages/src/i18n.ts +19 -19
- package/packages/src/i18nStore.ts +9 -11
- package/packages/src/iconStore.ts +3 -3
- package/packages/src/interceptor.ts +65 -65
- package/packages/src/log.ts +19 -19
- package/packages/src/menus.ts +62 -62
- package/packages/src/mixins.ts +38 -0
- package/packages/src/permission.ts +61 -39
- package/packages/src/renderer.ts +50 -50
- package/packages/src/resize.ts +89 -89
- package/packages/src/store.ts +49 -49
- package/packages/src/themeStore.ts +7 -7
- package/packages/src/validators.ts +9 -9
- package/types/core/clipboard.d.ts +13 -13
- package/types/core/commands.d.ts +19 -19
- package/types/core/components.d.ts +4 -4
- package/types/core/formats.d.ts +19 -19
- package/types/core/global-config.d.ts +55 -55
- package/types/core/global-event.d.ts +39 -39
- package/types/core/global-icon.d.ts +6 -6
- package/types/core/global-lang.d.ts +14 -1
- package/types/core/global-resize.d.ts +3 -3
- package/types/core/global-theme.d.ts +1 -1
- package/types/core/hooks.d.ts +14 -14
- package/types/core/index.d.ts +224 -224
- package/types/core/interceptor.d.ts +22 -22
- package/types/core/log.d.ts +8 -8
- package/types/core/menus.d.ts +19 -19
- package/types/core/mixins.d.ts +7 -0
- package/types/core/permission.d.ts +10 -10
- package/types/core/renderer.d.ts +14 -14
- package/types/core/validators.d.ts +19 -19
- package/types/index.d.ts +10 -10
- package/types/tool/common.d.ts +99 -99
- package/types/tool/index.d.ts +2 -2
- package/types/tool/util.d.ts +4 -4
- package/README.en.md +0 -31
- package/README.zh-TW.md +0 -31
- package/es/src/useFns.js +0 -23
- package/lib/src/useFns.js +0 -33
- package/lib/src/useFns.min.js +0 -1
- package/packages/src/useFns.ts +0 -34
- package/types/core/useFn.d.ts +0 -27
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import XEUtils from 'xe-utils'
|
|
2
|
-
|
|
3
|
-
import { VxeGlobalClipboard } from '../../types'
|
|
4
|
-
|
|
5
|
-
let copyElem: HTMLTextAreaElement
|
|
6
|
-
const clipStore = {
|
|
7
|
-
text: '',
|
|
8
|
-
html: ''
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function handleText (text: string) {
|
|
12
|
-
if (!copyElem) {
|
|
13
|
-
copyElem = document.createElement('textarea')
|
|
14
|
-
copyElem.id = '$VxeCopy'
|
|
15
|
-
const styles = copyElem.style
|
|
16
|
-
styles.width = '48px'
|
|
17
|
-
styles.height = '24px'
|
|
18
|
-
styles.position = 'fixed'
|
|
19
|
-
styles.zIndex = '0'
|
|
20
|
-
styles.left = '-500px'
|
|
21
|
-
styles.top = '-500px'
|
|
22
|
-
document.body.appendChild(copyElem)
|
|
23
|
-
}
|
|
24
|
-
copyElem.value = text
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const clipboard: VxeGlobalClipboard = {
|
|
28
|
-
getStore () {
|
|
29
|
-
return clipStore
|
|
30
|
-
},
|
|
31
|
-
setStore (data) {
|
|
32
|
-
Object.assign(clipStore, data || {})
|
|
33
|
-
},
|
|
34
|
-
/**
|
|
35
|
-
* 复制内容到剪贴板
|
|
36
|
-
*
|
|
37
|
-
* @param {String} content Text 内容
|
|
38
|
-
*/
|
|
39
|
-
copy (content) {
|
|
40
|
-
let result = false
|
|
41
|
-
try {
|
|
42
|
-
const text = XEUtils.toValueString(content)
|
|
43
|
-
handleText(text)
|
|
44
|
-
copyElem.select()
|
|
45
|
-
copyElem.setSelectionRange(0, copyElem.value.length)
|
|
46
|
-
result = document.execCommand('copy')
|
|
47
|
-
copyElem.blur()
|
|
48
|
-
clipStore.text = text
|
|
49
|
-
clipStore.html = ''
|
|
50
|
-
} catch (e) {}
|
|
51
|
-
return result
|
|
52
|
-
}
|
|
53
|
-
}
|
|
1
|
+
import XEUtils from 'xe-utils'
|
|
2
|
+
|
|
3
|
+
import { VxeGlobalClipboard } from '../../types'
|
|
4
|
+
|
|
5
|
+
let copyElem: HTMLTextAreaElement
|
|
6
|
+
const clipStore = {
|
|
7
|
+
text: '',
|
|
8
|
+
html: ''
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function handleText (text: string) {
|
|
12
|
+
if (!copyElem) {
|
|
13
|
+
copyElem = document.createElement('textarea')
|
|
14
|
+
copyElem.id = '$VxeCopy'
|
|
15
|
+
const styles = copyElem.style
|
|
16
|
+
styles.width = '48px'
|
|
17
|
+
styles.height = '24px'
|
|
18
|
+
styles.position = 'fixed'
|
|
19
|
+
styles.zIndex = '0'
|
|
20
|
+
styles.left = '-500px'
|
|
21
|
+
styles.top = '-500px'
|
|
22
|
+
document.body.appendChild(copyElem)
|
|
23
|
+
}
|
|
24
|
+
copyElem.value = text
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const clipboard: VxeGlobalClipboard = {
|
|
28
|
+
getStore () {
|
|
29
|
+
return clipStore
|
|
30
|
+
},
|
|
31
|
+
setStore (data) {
|
|
32
|
+
Object.assign(clipStore, data || {})
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* 复制内容到剪贴板
|
|
36
|
+
*
|
|
37
|
+
* @param {String} content Text 内容
|
|
38
|
+
*/
|
|
39
|
+
copy (content) {
|
|
40
|
+
let result = false
|
|
41
|
+
try {
|
|
42
|
+
const text = XEUtils.toValueString(content)
|
|
43
|
+
handleText(text)
|
|
44
|
+
copyElem.select()
|
|
45
|
+
copyElem.setSelectionRange(0, copyElem.value.length)
|
|
46
|
+
result = document.execCommand('copy')
|
|
47
|
+
copyElem.blur()
|
|
48
|
+
clipStore.text = text
|
|
49
|
+
clipStore.html = ''
|
|
50
|
+
} catch (e) {}
|
|
51
|
+
return result
|
|
52
|
+
}
|
|
53
|
+
}
|
package/packages/src/commands.ts
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import XEUtils from 'xe-utils'
|
|
2
|
-
import { log } from './log'
|
|
3
|
-
|
|
4
|
-
import { VxeGlobalCommands } from '../../types'
|
|
5
|
-
|
|
6
|
-
class VXECommandsStore {
|
|
7
|
-
private store: any = {}
|
|
8
|
-
|
|
9
|
-
mixin (options: any): VXECommandsStore {
|
|
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): VXECommandsStore {
|
|
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', ['commands -> callback', 'commandMethod'])
|
|
30
|
-
}
|
|
31
|
-
render = {
|
|
32
|
-
commandMethod: 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 commands = new VXECommandsStore() as VxeGlobalCommands
|
|
59
|
-
|
|
60
|
-
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
61
|
-
Object.assign(commands, { _name: 'Commands' })
|
|
62
|
-
}
|
|
1
|
+
import XEUtils from 'xe-utils'
|
|
2
|
+
import { log } from './log'
|
|
3
|
+
|
|
4
|
+
import { VxeGlobalCommands } from '../../types'
|
|
5
|
+
|
|
6
|
+
class VXECommandsStore {
|
|
7
|
+
private store: any = {}
|
|
8
|
+
|
|
9
|
+
mixin (options: any): VXECommandsStore {
|
|
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): VXECommandsStore {
|
|
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', ['commands -> callback', 'commandMethod'])
|
|
30
|
+
}
|
|
31
|
+
render = {
|
|
32
|
+
commandMethod: 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 commands = new VXECommandsStore() as VxeGlobalCommands
|
|
59
|
+
|
|
60
|
+
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
61
|
+
Object.assign(commands, { _name: 'Commands' })
|
|
62
|
+
}
|
package/packages/src/core.ts
CHANGED
|
@@ -1,167 +1,167 @@
|
|
|
1
|
-
import XEUtils from 'xe-utils'
|
|
2
|
-
import DomZIndex from 'dom-zindex'
|
|
3
|
-
import { globalConfigStore } from './globalStore'
|
|
4
|
-
import { iconConfigStore } from './iconStore'
|
|
5
|
-
import { themeConfigStore } from './themeStore'
|
|
6
|
-
import { i18nConfigStore } from './i18nStore'
|
|
7
|
-
import { globalEvents, GLOBAL_EVENT_KEYS, createEvent } from './event'
|
|
8
|
-
import { globalResize } from './resize'
|
|
9
|
-
import { getI18n, hasLanguage, getLanguage } from './i18n'
|
|
10
|
-
import { renderer } from './renderer'
|
|
11
|
-
import { validators } from './validators'
|
|
12
|
-
import { menus } from './menus'
|
|
13
|
-
import { formats } from './formats'
|
|
14
|
-
import { commands } from './commands'
|
|
15
|
-
import { interceptor } from './interceptor'
|
|
16
|
-
import { clipboard } from './clipboard'
|
|
17
|
-
import { permission } from './permission'
|
|
18
|
-
import { log } from './log'
|
|
19
|
-
import { hooks } from './hooks'
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
import { VxeUIExport, VxeGlobalConfig, VxeGlobalThemeName, VxeGlobalComponents, VxeGlobalIcon, VxeUIPluginObject, VxeGlobalI18nLocale } from '../../types'
|
|
23
|
-
|
|
24
|
-
export function setTheme (name?: VxeGlobalThemeName) {
|
|
25
|
-
const theme = !name || name === 'default' ? 'light' : name
|
|
26
|
-
themeConfigStore.theme = theme
|
|
27
|
-
if (typeof document !== 'undefined') {
|
|
28
|
-
const documentElement = document.documentElement
|
|
29
|
-
if (documentElement) {
|
|
30
|
-
documentElement.setAttribute('data-vxe-ui-theme', theme)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return VxeUI
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function getTheme () {
|
|
37
|
-
return themeConfigStore.theme
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function setLanguage (locale: VxeGlobalI18nLocale) {
|
|
41
|
-
i18nConfigStore.language = locale || 'zh-CN'
|
|
42
|
-
return VxeUI
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function setI18n (locale: VxeGlobalI18nLocale, data: Record<string, any>) {
|
|
46
|
-
i18nConfigStore.langMaps[locale] = Object.assign({}, data)
|
|
47
|
-
return VxeUI
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* 全局参数设置
|
|
52
|
-
*/
|
|
53
|
-
export function setConfig (options?: VxeGlobalConfig) {
|
|
54
|
-
if (options) {
|
|
55
|
-
if (options.zIndex) {
|
|
56
|
-
DomZIndex.setCurrent(options.zIndex)
|
|
57
|
-
}
|
|
58
|
-
if (options.theme) {
|
|
59
|
-
setTheme(options.theme)
|
|
60
|
-
}
|
|
61
|
-
XEUtils.merge(globalConfigStore, options)
|
|
62
|
-
}
|
|
63
|
-
return VxeUI
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* 获取全局参数
|
|
68
|
-
*/
|
|
69
|
-
export function getConfig (key: keyof VxeGlobalConfig, defaultValue?: any) {
|
|
70
|
-
return arguments.length ? XEUtils.get(globalConfigStore, key, defaultValue) : globalConfigStore
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function setIcon (options?: VxeGlobalIcon) {
|
|
74
|
-
if (options) {
|
|
75
|
-
Object.assign(iconConfigStore, options)
|
|
76
|
-
}
|
|
77
|
-
return VxeUI
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export function getIcon (key: keyof VxeGlobalIcon) {
|
|
81
|
-
return arguments.length ? XEUtils.get(iconConfigStore, key) : iconConfigStore
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export const coreVersion = process.env.VUE_APP_VXE_VERSION as string
|
|
85
|
-
|
|
86
|
-
const installedPlugins: VxeUIPluginObject[] = []
|
|
87
|
-
|
|
88
|
-
export function use (Plugin: VxeUIPluginObject, options: any[]) {
|
|
89
|
-
if (Plugin && Plugin.install) {
|
|
90
|
-
if (installedPlugins.indexOf(Plugin) === -1) {
|
|
91
|
-
Plugin.install(VxeUI, options)
|
|
92
|
-
installedPlugins.push(Plugin)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return VxeUI
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const components: Record<string, any> = {}
|
|
99
|
-
|
|
100
|
-
export function getComponent (name: keyof VxeGlobalComponents) {
|
|
101
|
-
return components[name] || null
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export function component (comp: any) {
|
|
105
|
-
if (comp && comp.name) {
|
|
106
|
-
components[comp.name] = comp
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export const VxeUI: VxeUIExport = {
|
|
111
|
-
coreVersion,
|
|
112
|
-
|
|
113
|
-
setTheme,
|
|
114
|
-
getTheme,
|
|
115
|
-
setConfig,
|
|
116
|
-
getConfig: getConfig as any,
|
|
117
|
-
setIcon,
|
|
118
|
-
getIcon: getIcon as any,
|
|
119
|
-
setLanguage,
|
|
120
|
-
hasLanguage,
|
|
121
|
-
getLanguage,
|
|
122
|
-
setI18n,
|
|
123
|
-
getI18n,
|
|
124
|
-
|
|
125
|
-
globalEvents,
|
|
126
|
-
GLOBAL_EVENT_KEYS,
|
|
127
|
-
createEvent,
|
|
128
|
-
|
|
129
|
-
globalResize,
|
|
130
|
-
renderer,
|
|
131
|
-
validators,
|
|
132
|
-
menus,
|
|
133
|
-
formats,
|
|
134
|
-
commands,
|
|
135
|
-
interceptor,
|
|
136
|
-
clipboard,
|
|
137
|
-
log,
|
|
138
|
-
permission,
|
|
139
|
-
|
|
140
|
-
hooks,
|
|
141
|
-
component,
|
|
142
|
-
getComponent,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
use
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
setTheme()
|
|
149
|
-
|
|
150
|
-
export * from './event'
|
|
151
|
-
export * from './resize'
|
|
152
|
-
|
|
153
|
-
export * from './i18n'
|
|
154
|
-
export * from './renderer'
|
|
155
|
-
export * from './validators'
|
|
156
|
-
export * from './menus'
|
|
157
|
-
export * from './formats'
|
|
158
|
-
export * from './commands'
|
|
159
|
-
export * from './interceptor'
|
|
160
|
-
export * from './clipboard'
|
|
161
|
-
export * from './permission'
|
|
162
|
-
|
|
163
|
-
export * from './
|
|
164
|
-
export * from './log'
|
|
165
|
-
export * from './hooks'
|
|
166
|
-
|
|
167
|
-
export default VxeUI
|
|
1
|
+
import XEUtils from 'xe-utils'
|
|
2
|
+
import DomZIndex from 'dom-zindex'
|
|
3
|
+
import { globalConfigStore } from './globalStore'
|
|
4
|
+
import { iconConfigStore } from './iconStore'
|
|
5
|
+
import { themeConfigStore } from './themeStore'
|
|
6
|
+
import { i18nConfigStore } from './i18nStore'
|
|
7
|
+
import { globalEvents, GLOBAL_EVENT_KEYS, createEvent } from './event'
|
|
8
|
+
import { globalResize } from './resize'
|
|
9
|
+
import { getI18n, hasLanguage, getLanguage } from './i18n'
|
|
10
|
+
import { renderer } from './renderer'
|
|
11
|
+
import { validators } from './validators'
|
|
12
|
+
import { menus } from './menus'
|
|
13
|
+
import { formats } from './formats'
|
|
14
|
+
import { commands } from './commands'
|
|
15
|
+
import { interceptor } from './interceptor'
|
|
16
|
+
import { clipboard } from './clipboard'
|
|
17
|
+
import { permission } from './permission'
|
|
18
|
+
import { log } from './log'
|
|
19
|
+
import { hooks } from './hooks'
|
|
20
|
+
import { mixins } from './mixins'
|
|
21
|
+
|
|
22
|
+
import { VxeUIExport, VxeGlobalConfig, VxeGlobalThemeName, VxeGlobalComponents, VxeGlobalIcon, VxeUIPluginObject, VxeGlobalI18nLocale } from '../../types'
|
|
23
|
+
|
|
24
|
+
export function setTheme (name?: VxeGlobalThemeName) {
|
|
25
|
+
const theme = !name || name === 'default' ? 'light' : name
|
|
26
|
+
themeConfigStore.theme = theme
|
|
27
|
+
if (typeof document !== 'undefined') {
|
|
28
|
+
const documentElement = document.documentElement
|
|
29
|
+
if (documentElement) {
|
|
30
|
+
documentElement.setAttribute('data-vxe-ui-theme', theme)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return VxeUI
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function getTheme () {
|
|
37
|
+
return themeConfigStore.theme
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function setLanguage (locale: VxeGlobalI18nLocale) {
|
|
41
|
+
i18nConfigStore.language = locale || 'zh-CN'
|
|
42
|
+
return VxeUI
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function setI18n (locale: VxeGlobalI18nLocale, data: Record<string, any>) {
|
|
46
|
+
i18nConfigStore.langMaps[locale] = Object.assign({}, data)
|
|
47
|
+
return VxeUI
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 全局参数设置
|
|
52
|
+
*/
|
|
53
|
+
export function setConfig (options?: VxeGlobalConfig) {
|
|
54
|
+
if (options) {
|
|
55
|
+
if (options.zIndex) {
|
|
56
|
+
DomZIndex.setCurrent(options.zIndex)
|
|
57
|
+
}
|
|
58
|
+
if (options.theme) {
|
|
59
|
+
setTheme(options.theme)
|
|
60
|
+
}
|
|
61
|
+
XEUtils.merge(globalConfigStore, options)
|
|
62
|
+
}
|
|
63
|
+
return VxeUI
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 获取全局参数
|
|
68
|
+
*/
|
|
69
|
+
export function getConfig (key: keyof VxeGlobalConfig, defaultValue?: any) {
|
|
70
|
+
return arguments.length ? XEUtils.get(globalConfigStore, key, defaultValue) : globalConfigStore
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function setIcon (options?: VxeGlobalIcon) {
|
|
74
|
+
if (options) {
|
|
75
|
+
Object.assign(iconConfigStore, options)
|
|
76
|
+
}
|
|
77
|
+
return VxeUI
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function getIcon (key: keyof VxeGlobalIcon) {
|
|
81
|
+
return arguments.length ? XEUtils.get(iconConfigStore, key) : iconConfigStore
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const coreVersion = process.env.VUE_APP_VXE_VERSION as string
|
|
85
|
+
|
|
86
|
+
const installedPlugins: VxeUIPluginObject[] = []
|
|
87
|
+
|
|
88
|
+
export function use (Plugin: VxeUIPluginObject, options: any[]) {
|
|
89
|
+
if (Plugin && Plugin.install) {
|
|
90
|
+
if (installedPlugins.indexOf(Plugin) === -1) {
|
|
91
|
+
Plugin.install(VxeUI, options)
|
|
92
|
+
installedPlugins.push(Plugin)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return VxeUI
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const components: Record<string, any> = {}
|
|
99
|
+
|
|
100
|
+
export function getComponent (name: keyof VxeGlobalComponents) {
|
|
101
|
+
return components[name] || null
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function component (comp: any) {
|
|
105
|
+
if (comp && comp.name) {
|
|
106
|
+
components[comp.name] = comp
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export const VxeUI: VxeUIExport = {
|
|
111
|
+
coreVersion,
|
|
112
|
+
|
|
113
|
+
setTheme,
|
|
114
|
+
getTheme,
|
|
115
|
+
setConfig,
|
|
116
|
+
getConfig: getConfig as any,
|
|
117
|
+
setIcon,
|
|
118
|
+
getIcon: getIcon as any,
|
|
119
|
+
setLanguage,
|
|
120
|
+
hasLanguage,
|
|
121
|
+
getLanguage,
|
|
122
|
+
setI18n,
|
|
123
|
+
getI18n,
|
|
124
|
+
|
|
125
|
+
globalEvents,
|
|
126
|
+
GLOBAL_EVENT_KEYS,
|
|
127
|
+
createEvent,
|
|
128
|
+
|
|
129
|
+
globalResize,
|
|
130
|
+
renderer,
|
|
131
|
+
validators,
|
|
132
|
+
menus,
|
|
133
|
+
formats,
|
|
134
|
+
commands,
|
|
135
|
+
interceptor,
|
|
136
|
+
clipboard,
|
|
137
|
+
log,
|
|
138
|
+
permission,
|
|
139
|
+
|
|
140
|
+
hooks,
|
|
141
|
+
component,
|
|
142
|
+
getComponent,
|
|
143
|
+
mixins,
|
|
144
|
+
|
|
145
|
+
use
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
setTheme()
|
|
149
|
+
|
|
150
|
+
export * from './event'
|
|
151
|
+
export * from './resize'
|
|
152
|
+
|
|
153
|
+
export * from './i18n'
|
|
154
|
+
export * from './renderer'
|
|
155
|
+
export * from './validators'
|
|
156
|
+
export * from './menus'
|
|
157
|
+
export * from './formats'
|
|
158
|
+
export * from './commands'
|
|
159
|
+
export * from './interceptor'
|
|
160
|
+
export * from './clipboard'
|
|
161
|
+
export * from './permission'
|
|
162
|
+
|
|
163
|
+
export * from './mixins'
|
|
164
|
+
export * from './log'
|
|
165
|
+
export * from './hooks'
|
|
166
|
+
|
|
167
|
+
export default VxeUI
|