@vxe-ui/core 3.0.20 → 3.0.22
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 -29
- package/es/src/core.js +1 -1
- package/es/src/log.js +1 -1
- package/es/src/mixins.js +2 -2
- package/lib/index.umd.js +856 -88
- package/lib/index.umd.min.js +1 -1
- package/lib/src/core.js +1 -1
- package/lib/src/core.min.js +1 -1
- package/lib/src/log.js +1 -1
- package/lib/src/log.min.js +1 -1
- package/lib/src/mixins.js +2 -2
- package/lib/src/mixins.min.js +1 -1
- package/package.json +80 -80
- package/packages/index.ts +115 -115
- package/packages/src/clipboard.ts +53 -53
- package/packages/src/commands.ts +62 -62
- package/packages/src/config.ts +30 -30
- package/packages/src/configStore.ts +8 -8
- package/packages/src/core.ts +9 -9
- package/packages/src/dataStore.ts +4 -4
- package/packages/src/event.ts +127 -127
- package/packages/src/formats.ts +62 -62
- package/packages/src/i18n.ts +46 -46
- package/packages/src/i18nStore.ts +16 -16
- package/packages/src/icon.ts +16 -16
- 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 +39 -39
- package/packages/src/permission.ts +61 -61
- package/packages/src/renderer.ts +50 -50
- package/packages/src/resize.ts +89 -89
- package/packages/src/store.ts +49 -49
- package/packages/src/theme.ts +20 -20
- 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 +62 -62
- package/types/core/global-data.d.ts +7 -7
- 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 +22 -22
- package/types/core/global-resize.d.ts +3 -3
- package/types/core/global-theme.d.ts +1 -1
- package/types/core/index.d.ts +246 -246
- 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 +16 -16
- 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 +13 -13
- package/types/tool/common.d.ts +105 -105
- package/types/tool/index.d.ts +2 -2
- package/types/tool/util.d.ts +4 -4
package/packages/src/formats.ts
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import XEUtils from 'xe-utils'
|
|
2
|
-
import { log } from './log'
|
|
3
|
-
|
|
4
|
-
import { VxeGlobalFormats } from '../../types'
|
|
5
|
-
|
|
6
|
-
class VXEFormatsStore {
|
|
7
|
-
private store: any = {}
|
|
8
|
-
|
|
9
|
-
mixin (options: any): VXEFormatsStore {
|
|
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): VXEFormatsStore {
|
|
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', ['formats -> callback', 'cellFormatMethod'])
|
|
30
|
-
}
|
|
31
|
-
render = {
|
|
32
|
-
cellFormatMethod: 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 formats = new VXEFormatsStore() as VxeGlobalFormats
|
|
59
|
-
|
|
60
|
-
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
61
|
-
Object.assign(formats, { _name: 'Formats' })
|
|
62
|
-
}
|
|
1
|
+
import XEUtils from 'xe-utils'
|
|
2
|
+
import { log } from './log'
|
|
3
|
+
|
|
4
|
+
import { VxeGlobalFormats } from '../../types'
|
|
5
|
+
|
|
6
|
+
class VXEFormatsStore {
|
|
7
|
+
private store: any = {}
|
|
8
|
+
|
|
9
|
+
mixin (options: any): VXEFormatsStore {
|
|
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): VXEFormatsStore {
|
|
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', ['formats -> callback', 'cellFormatMethod'])
|
|
30
|
+
}
|
|
31
|
+
render = {
|
|
32
|
+
cellFormatMethod: 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 formats = new VXEFormatsStore() as VxeGlobalFormats
|
|
59
|
+
|
|
60
|
+
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
61
|
+
Object.assign(formats, { _name: 'Formats' })
|
|
62
|
+
}
|
package/packages/src/i18n.ts
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import XEUtils from 'xe-utils'
|
|
2
|
-
import { VxeCore } from './core'
|
|
3
|
-
import { i18nConfigStore } from './i18nStore'
|
|
4
|
-
import { globalConfigStore } from './configStore'
|
|
5
|
-
|
|
6
|
-
import { VxeGlobalI18nLocale } from '../../types'
|
|
7
|
-
|
|
8
|
-
let checkInstall = false
|
|
9
|
-
|
|
10
|
-
export function getI18n (key: string, args?: any) {
|
|
11
|
-
const { langMaps, language } = i18nConfigStore
|
|
12
|
-
const { i18n } = globalConfigStore
|
|
13
|
-
if (i18n) {
|
|
14
|
-
return `${i18n(key, args) || ''}`
|
|
15
|
-
}
|
|
16
|
-
if (!checkInstall) {
|
|
17
|
-
if (!langMaps[language]) {
|
|
18
|
-
console.error(`[vxe core] 语言包未安装。Language not installed. https://${VxeCore.uiVersion ? 'vxeui.com' : 'vxetable.cn'}/#/start/i18n`)
|
|
19
|
-
}
|
|
20
|
-
checkInstall = true
|
|
21
|
-
}
|
|
22
|
-
return XEUtils.toFormatString(XEUtils.get(langMaps[language], key, key), args)
|
|
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
|
-
|
|
38
|
-
export function hasLanguage (language: VxeGlobalI18nLocale) {
|
|
39
|
-
const { langMaps } = i18nConfigStore
|
|
40
|
-
return !!langMaps[language]
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function getLanguage () {
|
|
44
|
-
const { language } = i18nConfigStore
|
|
45
|
-
return language
|
|
46
|
-
}
|
|
1
|
+
import XEUtils from 'xe-utils'
|
|
2
|
+
import { VxeCore } from './core'
|
|
3
|
+
import { i18nConfigStore } from './i18nStore'
|
|
4
|
+
import { globalConfigStore } from './configStore'
|
|
5
|
+
|
|
6
|
+
import { VxeGlobalI18nLocale } from '../../types'
|
|
7
|
+
|
|
8
|
+
let checkInstall = false
|
|
9
|
+
|
|
10
|
+
export function getI18n (key: string, args?: any) {
|
|
11
|
+
const { langMaps, language } = i18nConfigStore
|
|
12
|
+
const { i18n } = globalConfigStore
|
|
13
|
+
if (i18n) {
|
|
14
|
+
return `${i18n(key, args) || ''}`
|
|
15
|
+
}
|
|
16
|
+
if (!checkInstall) {
|
|
17
|
+
if (!langMaps[language]) {
|
|
18
|
+
console.error(`[vxe core] 语言包未安装。Language not installed. https://${VxeCore.uiVersion ? 'vxeui.com' : 'vxetable.cn'}/#/start/i18n`)
|
|
19
|
+
}
|
|
20
|
+
checkInstall = true
|
|
21
|
+
}
|
|
22
|
+
return XEUtils.toFormatString(XEUtils.get(langMaps[language], key, key), args)
|
|
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
|
+
|
|
38
|
+
export function hasLanguage (language: VxeGlobalI18nLocale) {
|
|
39
|
+
const { langMaps } = i18nConfigStore
|
|
40
|
+
return !!langMaps[language]
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function getLanguage () {
|
|
44
|
+
const { language } = i18nConfigStore
|
|
45
|
+
return language
|
|
46
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import Vue from 'vue'
|
|
2
|
-
import { VxeGlobalI18nLocale } from '../../types'
|
|
3
|
-
|
|
4
|
-
const I18nStore = Vue.extend({
|
|
5
|
-
data () {
|
|
6
|
-
return {
|
|
7
|
-
language: '' as VxeGlobalI18nLocale,
|
|
8
|
-
langMaps: {} as Partial<Record<VxeGlobalI18nLocale, any>>
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
export const i18nConfigStore = new I18nStore() as {
|
|
14
|
-
language: VxeGlobalI18nLocale,
|
|
15
|
-
langMaps: Partial<Record<VxeGlobalI18nLocale, any>>
|
|
16
|
-
}
|
|
1
|
+
import Vue from 'vue'
|
|
2
|
+
import { VxeGlobalI18nLocale } from '../../types'
|
|
3
|
+
|
|
4
|
+
const I18nStore = Vue.extend({
|
|
5
|
+
data () {
|
|
6
|
+
return {
|
|
7
|
+
language: '' as VxeGlobalI18nLocale,
|
|
8
|
+
langMaps: {} as Partial<Record<VxeGlobalI18nLocale, any>>
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
export const i18nConfigStore = new I18nStore() as {
|
|
14
|
+
language: VxeGlobalI18nLocale,
|
|
15
|
+
langMaps: Partial<Record<VxeGlobalI18nLocale, any>>
|
|
16
|
+
}
|
package/packages/src/icon.ts
CHANGED
|
@@ -1,16 +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
|
-
}
|
|
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
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { VxeGlobalIcon } from '../../types'
|
|
2
|
-
|
|
3
|
-
export const iconConfigStore: VxeGlobalIcon = {}
|
|
1
|
+
import { VxeGlobalIcon } from '../../types'
|
|
2
|
+
|
|
3
|
+
export const iconConfigStore: VxeGlobalIcon = {}
|
|
@@ -1,65 +1,65 @@
|
|
|
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
|
-
return storeMap[type] || []
|
|
17
|
-
},
|
|
18
|
-
add (type, render) {
|
|
19
|
-
// 兼容
|
|
20
|
-
if (XEUtils.isFunction(render)) {
|
|
21
|
-
// if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
22
|
-
// log.warn('vxe.error.delProp', ['interceptor -> callback', 'tableInterceptorMethod'])
|
|
23
|
-
// }
|
|
24
|
-
render = {
|
|
25
|
-
tableInterceptorMethod: render
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const callback = render.tableInterceptorMethod
|
|
29
|
-
|
|
30
|
-
if (callback) {
|
|
31
|
-
let eList = storeMap[type]
|
|
32
|
-
if (!eList) {
|
|
33
|
-
eList = storeMap[type] = []
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// 检测重复
|
|
37
|
-
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
38
|
-
if (eList.indexOf(callback) > -1) {
|
|
39
|
-
log.warn('vxe.error.coverProp', ['Interceptor', type])
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
eList.push(callback)
|
|
44
|
-
}
|
|
45
|
-
return interceptor
|
|
46
|
-
},
|
|
47
|
-
delete (type, render) {
|
|
48
|
-
const eList = storeMap[type]
|
|
49
|
-
if (eList) {
|
|
50
|
-
// 兼容
|
|
51
|
-
if (XEUtils.isFunction(render)) {
|
|
52
|
-
render = {
|
|
53
|
-
tableInterceptorMethod: render
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
const callback = render ? render.tableInterceptorMethod : null
|
|
57
|
-
|
|
58
|
-
if (callback) {
|
|
59
|
-
XEUtils.remove(eList, fn => fn === callback)
|
|
60
|
-
} else {
|
|
61
|
-
delete storeMap[type]
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
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
|
+
return storeMap[type] || []
|
|
17
|
+
},
|
|
18
|
+
add (type, render) {
|
|
19
|
+
// 兼容
|
|
20
|
+
if (XEUtils.isFunction(render)) {
|
|
21
|
+
// if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
22
|
+
// log.warn('vxe.error.delProp', ['interceptor -> callback', 'tableInterceptorMethod'])
|
|
23
|
+
// }
|
|
24
|
+
render = {
|
|
25
|
+
tableInterceptorMethod: render
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const callback = render.tableInterceptorMethod
|
|
29
|
+
|
|
30
|
+
if (callback) {
|
|
31
|
+
let eList = storeMap[type]
|
|
32
|
+
if (!eList) {
|
|
33
|
+
eList = storeMap[type] = []
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// 检测重复
|
|
37
|
+
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
38
|
+
if (eList.indexOf(callback) > -1) {
|
|
39
|
+
log.warn('vxe.error.coverProp', ['Interceptor', type])
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
eList.push(callback)
|
|
44
|
+
}
|
|
45
|
+
return interceptor
|
|
46
|
+
},
|
|
47
|
+
delete (type, render) {
|
|
48
|
+
const eList = storeMap[type]
|
|
49
|
+
if (eList) {
|
|
50
|
+
// 兼容
|
|
51
|
+
if (XEUtils.isFunction(render)) {
|
|
52
|
+
render = {
|
|
53
|
+
tableInterceptorMethod: render
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const callback = render ? render.tableInterceptorMethod : null
|
|
57
|
+
|
|
58
|
+
if (callback) {
|
|
59
|
+
XEUtils.remove(eList, fn => fn === callback)
|
|
60
|
+
} else {
|
|
61
|
+
delete storeMap[type]
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
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 (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
|
+
}
|
package/packages/src/menus.ts
CHANGED
|
@@ -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
|
+
}
|
package/packages/src/mixins.ts
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import Vue from 'vue'
|
|
2
|
-
import { handleCheckInfo } from './permission'
|
|
3
|
-
|
|
4
|
-
import { VxeComponentSizeType } from '../../types'
|
|
5
|
-
|
|
6
|
-
export const sizeMixin = Vue.extend({
|
|
7
|
-
inject: {
|
|
8
|
-
$xeSizeInfo: {
|
|
9
|
-
default: null
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
provide (this: any) {
|
|
13
|
-
return {
|
|
14
|
-
$xeSizeInfo: {
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
computed: {
|
|
20
|
-
computeSize (this: any): VxeComponentSizeType {
|
|
21
|
-
const { size } = this
|
|
22
|
-
const $xeSizeInfo = this.$xeSizeInfo
|
|
23
|
-
return size || ($xeSizeInfo ? $xeSizeInfo.
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
export const permissionMixin = Vue.extend({
|
|
29
|
-
computed: {
|
|
30
|
-
computePermissionInfo (this: any) {
|
|
31
|
-
return handleCheckInfo(this.permissionCode, this.permissionMethod)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
export const globalMixins = {
|
|
37
|
-
sizeMixin,
|
|
38
|
-
permissionMixin
|
|
39
|
-
}
|
|
1
|
+
import Vue from 'vue'
|
|
2
|
+
import { handleCheckInfo } from './permission'
|
|
3
|
+
|
|
4
|
+
import { VxeComponentSizeType } from '../../types'
|
|
5
|
+
|
|
6
|
+
export const sizeMixin = Vue.extend({
|
|
7
|
+
inject: {
|
|
8
|
+
$xeSizeInfo: {
|
|
9
|
+
default: null
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
provide (this: any) {
|
|
13
|
+
return {
|
|
14
|
+
$xeSizeInfo: {
|
|
15
|
+
getSize: () => this.computeSize
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
computed: {
|
|
20
|
+
computeSize (this: any): VxeComponentSizeType {
|
|
21
|
+
const { size } = this
|
|
22
|
+
const $xeSizeInfo = this.$xeSizeInfo
|
|
23
|
+
return size || ($xeSizeInfo ? $xeSizeInfo.getSize() : null)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
export const permissionMixin = Vue.extend({
|
|
29
|
+
computed: {
|
|
30
|
+
computePermissionInfo (this: any) {
|
|
31
|
+
return handleCheckInfo(this.permissionCode, this.permissionMethod)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
export const globalMixins = {
|
|
37
|
+
sizeMixin,
|
|
38
|
+
permissionMixin
|
|
39
|
+
}
|