@vxe-ui/core 4.0.19 → 4.0.20

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.
@@ -1,179 +1,9 @@
1
- import XEUtils from 'xe-utils'
2
- import DomZIndex from 'dom-zindex'
3
- import { createCommentVNode } from 'vue'
4
- import { globalConfigStore } from './configStore'
5
- import { globalStore } from './dataStore'
6
- import { iconConfigStore } from './iconStore'
7
- import { themeConfigStore } from './themeStore'
8
- import { i18nConfigStore } from './i18nStore'
9
- import { globalEvents, GLOBAL_EVENT_KEYS, createEvent } from './event'
10
- import { globalResize } from './resize'
11
- import { getI18n, hasLanguage, getLanguage } from './i18n'
12
- import { renderer } from './renderer'
13
- import { validators } from './validators'
14
- import { menus } from './menus'
15
- import { formats } from './formats'
16
- import { commands } from './commands'
17
- import { interceptor } from './interceptor'
18
- import { clipboard } from './clipboard'
19
- import { permission } from './permission'
20
- import { log } from './log'
21
- import { hooks } from './hooks'
22
- import { useFns } from './useFns'
23
-
24
- import { VxeUIExport, VxeGlobalConfig, VxeGlobalThemeName, VxeGlobalComponents, VxeGlobalIcon, VxeUIPluginObject, VxeGlobalI18nLocale } from '../../types'
25
-
26
- export function setTheme (name?: VxeGlobalThemeName) {
27
- const theme = !name || name === 'default' ? 'light' : name
28
- themeConfigStore.theme = theme
29
- if (typeof document !== 'undefined') {
30
- const documentElement = document.documentElement
31
- if (documentElement) {
32
- documentElement.setAttribute('data-vxe-ui-theme', theme)
33
- }
34
- }
35
- return VxeUI
36
- }
37
-
38
- export function getTheme () {
39
- return themeConfigStore.theme
40
- }
41
-
42
- export function setLanguage (locale: VxeGlobalI18nLocale) {
43
- i18nConfigStore.language = locale || 'zh-CN'
44
- return VxeUI
45
- }
46
-
47
- export function setI18n (locale: VxeGlobalI18nLocale, data: Record<string, any>) {
48
- i18nConfigStore.langMaps[locale] = Object.assign({}, data)
49
- return VxeUI
50
- }
51
-
52
- /**
53
- * 全局参数设置
54
- */
55
- export function setConfig (options?: VxeGlobalConfig) {
56
- if (options) {
57
- if (options.zIndex) {
58
- DomZIndex.setCurrent(options.zIndex)
59
- }
60
- if (options.theme) {
61
- setTheme(options.theme)
62
- }
63
- XEUtils.merge(globalConfigStore, options)
64
- }
65
- return VxeUI
66
- }
67
-
68
- /**
69
- * 获取全局参数
70
- */
71
- export function getConfig (key: keyof VxeGlobalConfig, defaultValue?: any) {
72
- return arguments.length ? XEUtils.get(globalConfigStore, key, defaultValue) : globalConfigStore
73
- }
74
-
75
- export function setIcon (options?: VxeGlobalIcon) {
76
- if (options) {
77
- Object.assign(iconConfigStore, options)
78
- }
79
- return VxeUI
80
- }
81
-
82
- export function getIcon (key: keyof VxeGlobalIcon) {
83
- return arguments.length ? XEUtils.get(iconConfigStore, key) : iconConfigStore
84
- }
1
+ import { VxeUIExport } from '../../types'
85
2
 
86
3
  export const coreVersion = process.env.VUE_APP_VXE_VERSION as string
87
4
 
88
- const installedPlugins: VxeUIPluginObject[] = []
89
-
90
- export function use (Plugin: VxeUIPluginObject, options: any[]) {
91
- if (Plugin && Plugin.install) {
92
- if (installedPlugins.indexOf(Plugin) === -1) {
93
- Plugin.install(VxeUI, options)
94
- installedPlugins.push(Plugin)
95
- }
96
- }
97
- return VxeUI
98
- }
99
-
100
- const components: Record<string, any> = {}
101
-
102
- export function getComponent (name: keyof VxeGlobalComponents) {
103
- return components[name] || null
104
- }
105
-
106
- export function component (comp: any) {
107
- if (comp && comp.name) {
108
- components[comp.name] = comp
109
- }
110
- }
111
-
112
- export function renderEmptyElement () {
113
- return createCommentVNode()
114
- }
115
-
116
- export const VxeUI: VxeUIExport = {
5
+ export const VxeCore = {
117
6
  coreVersion,
118
-
119
- renderEmptyElement,
120
-
121
- setTheme,
122
- getTheme,
123
- setConfig,
124
- getConfig: getConfig as any,
125
- setIcon,
126
- getIcon: getIcon as any,
127
- setLanguage,
128
- hasLanguage,
129
- getLanguage,
130
- setI18n,
131
- getI18n,
132
-
133
- globalEvents,
134
- GLOBAL_EVENT_KEYS,
135
- createEvent,
136
-
137
- globalResize,
138
- renderer,
139
- validators,
140
- menus,
141
- formats,
142
- commands,
143
- interceptor,
144
- clipboard,
145
- log,
146
- permission,
147
-
148
- globalStore,
149
-
150
- hooks,
151
- component,
152
- getComponent,
153
- useFns,
154
-
155
- use
156
- }
157
-
158
- setTheme()
159
-
160
- export * from './event'
161
- export * from './resize'
162
-
163
- export * from './i18n'
164
- export * from './renderer'
165
- export * from './validators'
166
- export * from './menus'
167
- export * from './formats'
168
- export * from './commands'
169
- export * from './interceptor'
170
- export * from './clipboard'
171
- export * from './permission'
172
-
173
- export * from './dataStore'
174
-
175
- export * from './useFns'
176
- export * from './log'
177
- export * from './hooks'
178
-
179
- export default VxeUI
7
+ uiVersion: '',
8
+ tableVersion: ''
9
+ } as VxeUIExport
@@ -1,4 +1,5 @@
1
1
  import XEUtils from 'xe-utils'
2
+ import { VxeCore } from './core'
2
3
  import { i18nConfigStore } from './i18nStore'
3
4
  import { globalConfigStore } from './configStore'
4
5
 
@@ -14,13 +15,23 @@ export function getI18n (key: string, args?: any) {
14
15
  }
15
16
  if (!checkInstall) {
16
17
  if (!langMaps[language]) {
17
- console.error('[vxe] Language not installed. https://vxeui.com/#/start/i18n')
18
+ console.error(`[vxe core] 语言包未安装。Language not installed. https://${VxeCore.uiVersion ? 'vxeui.com' : 'vxetable.cn'}/#/start/i18n`)
18
19
  }
19
20
  checkInstall = true
20
21
  }
21
22
  return XEUtils.toFormatString(XEUtils.get(langMaps[language], key, key), args)
22
23
  }
23
24
 
25
+ export function setLanguage (locale: VxeGlobalI18nLocale) {
26
+ i18nConfigStore.language = locale || 'zh-CN'
27
+ return VxeCore
28
+ }
29
+
30
+ export function setI18n (locale: VxeGlobalI18nLocale, data: Record<string, any>) {
31
+ i18nConfigStore.langMaps[locale] = Object.assign({}, data)
32
+ return VxeCore
33
+ }
34
+
24
35
  export function hasLanguage (language: VxeGlobalI18nLocale) {
25
36
  const { langMaps } = i18nConfigStore
26
37
  return !!langMaps[language]
@@ -0,0 +1,16 @@
1
+ import XEUtils from 'xe-utils'
2
+ import { VxeCore } from './core'
3
+ import { iconConfigStore } from './iconStore'
4
+
5
+ import { VxeGlobalIcon } from '../../types'
6
+
7
+ export function setIcon (options?: VxeGlobalIcon) {
8
+ if (options) {
9
+ Object.assign(iconConfigStore, options)
10
+ }
11
+ return VxeCore
12
+ }
13
+
14
+ export function getIcon (key: keyof VxeGlobalIcon) {
15
+ return arguments.length ? XEUtils.get(iconConfigStore, key) : iconConfigStore
16
+ }
@@ -0,0 +1,20 @@
1
+ import { VxeCore } from './core'
2
+ import { themeConfigStore } from './themeStore'
3
+
4
+ import { VxeGlobalThemeName } from '../../types'
5
+
6
+ export function setTheme (name?: VxeGlobalThemeName) {
7
+ const theme = !name || name === 'default' ? 'light' : name
8
+ themeConfigStore.theme = theme
9
+ if (typeof document !== 'undefined') {
10
+ const documentElement = document.documentElement
11
+ if (documentElement) {
12
+ documentElement.setAttribute('data-vxe-ui-theme', theme)
13
+ }
14
+ }
15
+ return VxeCore
16
+ }
17
+
18
+ export function getTheme () {
19
+ return themeConfigStore.theme
20
+ }
@@ -87,9 +87,17 @@ export function use (plugin: VxeUIPluginObject, ...options: any[]): VxeUIExport
87
87
  */
88
88
  export interface VxeUIExport {
89
89
  /**
90
- * 版本号
90
+ * 核心版本号
91
91
  */
92
92
  coreVersion: string
93
+ /**
94
+ * UI 版本号
95
+ */
96
+ uiVersion: string
97
+ /**
98
+ * Table 版本号
99
+ */
100
+ tableVersion: string
93
101
  /**
94
102
  * 渲染一个空元素
95
103
  */