@vxe-ui/core 3.0.16 → 3.0.17

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