xt-element-ui 1.3.3 → 1.3.4
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/CHANGELOG.md +72 -72
- package/LICENSE +21 -21
- package/README.md +240 -240
- package/docs/README.md +100 -100
- package/docs/components/base/xt-button.md +114 -114
- package/docs/components/base/xt-card-item.md +104 -104
- package/docs/components/base/xt-card.md +108 -108
- package/docs/components/base/xt-config-provider.md +199 -199
- package/docs/components/base/xt-flex-box.md +115 -115
- package/docs/components/base/xt-grid-box.md +302 -302
- package/docs/components/base/xt-input.md +150 -150
- package/docs/components/base/xt-map-provider.md +23 -23
- package/docs/components/base/xt-map.md +331 -331
- package/docs/components/base/xt-step-price.md +165 -165
- package/docs/components/base/xt-text.md +212 -212
- package/docs/components/base/xt-time.md +165 -165
- package/docs/components/extend/ex-bar.md +67 -67
- package/docs/components/extend/ex-button.md +62 -62
- package/docs/components/extend/ex-card.md +86 -86
- package/docs/components/extend/ex-chart.md +463 -463
- package/docs/components/extend/ex-icon.md +189 -189
- package/docs/components/extend/ex-line.md +70 -70
- package/docs/components/extend/ex-multi.md +155 -155
- package/docs/components/extend/ex-pie.md +69 -69
- package/docs/components/extend/ex-select-tree.md +210 -210
- package/docs/components/extend/ex-table.md +590 -590
- package/docs/components/extend/ex-upload.md +134 -134
- package/docs/components/utils/size.md +147 -147
- package/docs/components/utils/theme.md +182 -182
- package/lib/index.common.js +4112 -4122
- package/lib/index.umd.js +4072 -4081
- package/lib/index.umd.min.js +3 -3
- package/package.json +80 -81
- package/src/components/ex-button/index.js +7 -7
- package/src/components/ex-button/index.vue +66 -66
- package/src/components/ex-button/style/index.scss +67 -67
- package/src/components/ex-card/index.js +7 -7
- package/src/components/ex-card/index.vue +68 -68
- package/src/components/ex-card/style/index.scss +73 -73
- package/src/components/ex-chart/index.js +7 -7
- package/src/components/ex-chart/index.vue +136 -136
- package/src/components/ex-date-picker/index.js +7 -7
- package/src/components/ex-icon/index.js +7 -7
- package/src/components/ex-icon/index.vue +168 -168
- package/src/components/ex-icon/style/index.scss +7 -7
- package/src/components/ex-page/index.js +7 -7
- package/src/components/ex-select-tree/index.js +7 -7
- package/src/components/ex-table/ExTableCell.vue +22 -22
- package/src/components/ex-table/index.js +7 -7
- package/src/components/ex-table/virtualScrollData.js +35 -35
- package/src/components/ex-upload/index.js +7 -7
- package/src/components/index.scss +39 -39
- package/src/components/xt-button/index.js +7 -7
- package/src/components/xt-button/index.vue +97 -97
- package/src/components/xt-card/index.js +7 -7
- package/src/components/xt-card/style/index.scss +48 -48
- package/src/components/xt-card-item/index.js +7 -7
- package/src/components/xt-card-item/style/index copy.scss +71 -71
- package/src/components/xt-card-item/style/index.scss +82 -82
- package/src/components/xt-config-provider/index.js +7 -7
- package/src/components/xt-config-provider/index.vue +362 -362
- package/src/components/xt-config-provider/style/index.scss +11 -11
- package/src/components/xt-flex-box/index.js +7 -7
- package/src/components/xt-flex-box/style/index.scss +81 -81
- package/src/components/xt-grid-box/index.js +7 -7
- package/src/components/xt-grid-box/style/index.scss +92 -92
- package/src/components/xt-grid-item/index.js +7 -7
- package/src/components/xt-grid-item/index.vue +106 -106
- package/src/components/xt-input/index.js +7 -7
- package/src/components/xt-input/index.vue +66 -66
- package/src/components/xt-input/style/index.scss +84 -84
- package/src/components/xt-map/adapters/amap.js +235 -235
- package/src/components/xt-map/adapters/baidu.js +254 -254
- package/src/components/xt-map/adapters/base.js +267 -267
- package/src/components/xt-map/adapters/index.js +29 -29
- package/src/components/xt-map/adapters/tianditu.js +242 -242
- package/src/components/xt-map/config/xt-map-config.js +197 -197
- package/src/components/xt-map/index.js +8 -8
- package/src/components/xt-map/index.vue +351 -351
- package/src/components/xt-map/loaders/script-loader.js +114 -114
- package/src/components/xt-map/provider.vue +200 -200
- package/src/components/xt-map/style/index.scss +77 -77
- package/src/components/xt-map-provider/index.js +8 -8
- package/src/components/xt-step-price/index.js +10 -10
- package/src/components/xt-step-price/index.vue +272 -272
- package/src/components/xt-step-price/style/index.scss +123 -123
- package/src/components/xt-step-price-item/index.js +7 -7
- package/src/components/xt-step-price-item/index.vue +187 -187
- package/src/components/xt-text/index.js +7 -7
- package/src/components/xt-text/index.vue +1 -1
- package/src/components/xt-text/style/index.scss +92 -92
- package/src/components/xt-time/index.js +7 -7
- package/src/components/xt-time/index.vue +313 -313
- package/src/components/xt-time/style/index.scss +23 -23
- package/src/config/element-registry.js +135 -135
- package/src/index.js +162 -178
- package/src/styles/css-variables.scss +257 -257
- package/src/styles/theme/background.scss +5 -5
- package/src/styles/theme/border-radius.scss +3 -3
- package/src/styles/theme/borders.scss +3 -3
- package/src/styles/theme/colors.scss +101 -101
- package/src/styles/theme/component-variables.scss +69 -69
- package/src/styles/theme/dark-variables.scss +28 -28
- package/src/styles/theme/font.scss +12 -12
- package/src/styles/theme/index.scss +11 -11
- package/src/styles/theme/shadows.scss +2 -2
- package/src/styles/theme/spacing.scss +4 -4
- package/src/styles/theme/transitions.scss +2 -2
- package/src/styles/theme/typography.scss +4 -4
- package/src/styles/variables-export.scss +85 -85
- package/src/utils/index.js +191 -202
|
@@ -1,114 +1,114 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 动态脚本加载器
|
|
3
|
-
* 负责动态注入地图 SDK <script> 标签,并返回 Promise
|
|
4
|
-
* 同一 URL 只会加载一次,缓存已加载的结果
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const loadedScripts = new Map() // URL -> Promise
|
|
8
|
-
const loadingScripts = new Map() // URL -> Promise (正在加载中)
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* 动态加载单个脚本
|
|
12
|
-
* @param {string} url - 脚本 URL
|
|
13
|
-
* @param {object} options - 配置
|
|
14
|
-
* @param {string} options.charset - 字符集,默认 'utf-8'
|
|
15
|
-
* @param {boolean} options.async - 是否异步,默认 true
|
|
16
|
-
* @param {number} options.timeout - 超时时间(ms),默认 30000
|
|
17
|
-
* @returns {Promise<HTMLScriptElement>}
|
|
18
|
-
*/
|
|
19
|
-
export const loadScript = (url, options = {}) => {
|
|
20
|
-
if (typeof window === 'undefined') {
|
|
21
|
-
return Promise.reject(new Error('[XtMap] 非浏览器环境'))
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const { charset = 'utf-8', async = true, timeout = 30000 } = options
|
|
25
|
-
|
|
26
|
-
if (loadedScripts.has(url)) {
|
|
27
|
-
return loadedScripts.get(url)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (loadingScripts.has(url)) {
|
|
31
|
-
return loadingScripts.get(url)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const promise = new Promise((resolve, reject) => {
|
|
35
|
-
const script = document.createElement('script')
|
|
36
|
-
script.type = 'text/javascript'
|
|
37
|
-
script.src = url
|
|
38
|
-
script.charset = charset
|
|
39
|
-
script.async = async
|
|
40
|
-
|
|
41
|
-
let timer = null
|
|
42
|
-
let done = false
|
|
43
|
-
|
|
44
|
-
const cleanup = () => {
|
|
45
|
-
done = true
|
|
46
|
-
if (timer) clearTimeout(timer)
|
|
47
|
-
script.onload = null
|
|
48
|
-
script.onerror = null
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
script.onload = () => {
|
|
52
|
-
if (done) return
|
|
53
|
-
cleanup()
|
|
54
|
-
loadingScripts.delete(url)
|
|
55
|
-
loadedScripts.set(url, Promise.resolve(script))
|
|
56
|
-
resolve(script)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
script.onerror = (err) => {
|
|
60
|
-
if (done) return
|
|
61
|
-
cleanup()
|
|
62
|
-
loadingScripts.delete(url)
|
|
63
|
-
reject(new Error(`[XtMap] 脚本加载失败: ${url}`))
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (timeout > 0) {
|
|
67
|
-
timer = setTimeout(() => {
|
|
68
|
-
if (done) return
|
|
69
|
-
cleanup()
|
|
70
|
-
loadingScripts.delete(url)
|
|
71
|
-
reject(new Error(`[XtMap] 脚本加载超时: ${url}`))
|
|
72
|
-
}, timeout)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
document.head.appendChild(script)
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
loadingScripts.set(url, promise)
|
|
79
|
-
return promise
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* 批量加载脚本(按顺序)
|
|
84
|
-
* @param {string[]} urls
|
|
85
|
-
* @param {object} options
|
|
86
|
-
*/
|
|
87
|
-
export const loadScripts = async (urls, options = {}) => {
|
|
88
|
-
for (const url of urls) {
|
|
89
|
-
await loadScript(url, options)
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* 清除加载缓存(切换密钥等场景使用)
|
|
95
|
-
*/
|
|
96
|
-
export const clearScriptCache = () => {
|
|
97
|
-
loadedScripts.clear()
|
|
98
|
-
loadingScripts.clear()
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* 检查全局对象是否存在
|
|
103
|
-
*/
|
|
104
|
-
export const hasGlobal = (name) => {
|
|
105
|
-
if (typeof window === 'undefined') return false
|
|
106
|
-
return window[name] !== undefined
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export default {
|
|
110
|
-
loadScript,
|
|
111
|
-
loadScripts,
|
|
112
|
-
clearScriptCache,
|
|
113
|
-
hasGlobal
|
|
114
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 动态脚本加载器
|
|
3
|
+
* 负责动态注入地图 SDK <script> 标签,并返回 Promise
|
|
4
|
+
* 同一 URL 只会加载一次,缓存已加载的结果
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const loadedScripts = new Map() // URL -> Promise
|
|
8
|
+
const loadingScripts = new Map() // URL -> Promise (正在加载中)
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 动态加载单个脚本
|
|
12
|
+
* @param {string} url - 脚本 URL
|
|
13
|
+
* @param {object} options - 配置
|
|
14
|
+
* @param {string} options.charset - 字符集,默认 'utf-8'
|
|
15
|
+
* @param {boolean} options.async - 是否异步,默认 true
|
|
16
|
+
* @param {number} options.timeout - 超时时间(ms),默认 30000
|
|
17
|
+
* @returns {Promise<HTMLScriptElement>}
|
|
18
|
+
*/
|
|
19
|
+
export const loadScript = (url, options = {}) => {
|
|
20
|
+
if (typeof window === 'undefined') {
|
|
21
|
+
return Promise.reject(new Error('[XtMap] 非浏览器环境'))
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const { charset = 'utf-8', async = true, timeout = 30000 } = options
|
|
25
|
+
|
|
26
|
+
if (loadedScripts.has(url)) {
|
|
27
|
+
return loadedScripts.get(url)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (loadingScripts.has(url)) {
|
|
31
|
+
return loadingScripts.get(url)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const promise = new Promise((resolve, reject) => {
|
|
35
|
+
const script = document.createElement('script')
|
|
36
|
+
script.type = 'text/javascript'
|
|
37
|
+
script.src = url
|
|
38
|
+
script.charset = charset
|
|
39
|
+
script.async = async
|
|
40
|
+
|
|
41
|
+
let timer = null
|
|
42
|
+
let done = false
|
|
43
|
+
|
|
44
|
+
const cleanup = () => {
|
|
45
|
+
done = true
|
|
46
|
+
if (timer) clearTimeout(timer)
|
|
47
|
+
script.onload = null
|
|
48
|
+
script.onerror = null
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
script.onload = () => {
|
|
52
|
+
if (done) return
|
|
53
|
+
cleanup()
|
|
54
|
+
loadingScripts.delete(url)
|
|
55
|
+
loadedScripts.set(url, Promise.resolve(script))
|
|
56
|
+
resolve(script)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
script.onerror = (err) => {
|
|
60
|
+
if (done) return
|
|
61
|
+
cleanup()
|
|
62
|
+
loadingScripts.delete(url)
|
|
63
|
+
reject(new Error(`[XtMap] 脚本加载失败: ${url}`))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (timeout > 0) {
|
|
67
|
+
timer = setTimeout(() => {
|
|
68
|
+
if (done) return
|
|
69
|
+
cleanup()
|
|
70
|
+
loadingScripts.delete(url)
|
|
71
|
+
reject(new Error(`[XtMap] 脚本加载超时: ${url}`))
|
|
72
|
+
}, timeout)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
document.head.appendChild(script)
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
loadingScripts.set(url, promise)
|
|
79
|
+
return promise
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 批量加载脚本(按顺序)
|
|
84
|
+
* @param {string[]} urls
|
|
85
|
+
* @param {object} options
|
|
86
|
+
*/
|
|
87
|
+
export const loadScripts = async (urls, options = {}) => {
|
|
88
|
+
for (const url of urls) {
|
|
89
|
+
await loadScript(url, options)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 清除加载缓存(切换密钥等场景使用)
|
|
95
|
+
*/
|
|
96
|
+
export const clearScriptCache = () => {
|
|
97
|
+
loadedScripts.clear()
|
|
98
|
+
loadingScripts.clear()
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 检查全局对象是否存在
|
|
103
|
+
*/
|
|
104
|
+
export const hasGlobal = (name) => {
|
|
105
|
+
if (typeof window === 'undefined') return false
|
|
106
|
+
return window[name] !== undefined
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export default {
|
|
110
|
+
loadScript,
|
|
111
|
+
loadScripts,
|
|
112
|
+
clearScriptCache,
|
|
113
|
+
hasGlobal
|
|
114
|
+
}
|
|
@@ -1,200 +1,200 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div :class="['xt-map-provider', { 'xt-map-provider--dark': mergedTheme === 'dark' }]" :style="wrapperStyle">
|
|
3
|
-
<slot></slot>
|
|
4
|
-
</div>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script>
|
|
8
|
-
import {
|
|
9
|
-
getMapConfig,
|
|
10
|
-
setMapConfig,
|
|
11
|
-
setMapProvider,
|
|
12
|
-
setMapApiKey,
|
|
13
|
-
setMapApiUrl,
|
|
14
|
-
setMapType,
|
|
15
|
-
setMapTheme,
|
|
16
|
-
setMapCenter,
|
|
17
|
-
setMapZoom,
|
|
18
|
-
setMapPlugins,
|
|
19
|
-
setSecurityJsCode,
|
|
20
|
-
getMapProvider,
|
|
21
|
-
getMapApiKey,
|
|
22
|
-
getMapApiUrl,
|
|
23
|
-
getMapType,
|
|
24
|
-
getMapTheme,
|
|
25
|
-
getMapCenter,
|
|
26
|
-
getMapZoom,
|
|
27
|
-
getMapPlugins,
|
|
28
|
-
MAP_PROVIDERS,
|
|
29
|
-
MAP_TYPES,
|
|
30
|
-
MAP_THEMES,
|
|
31
|
-
onMapConfigChange
|
|
32
|
-
} from './config/xt-map-config'
|
|
33
|
-
|
|
34
|
-
export default {
|
|
35
|
-
name: 'XtMapProvider',
|
|
36
|
-
|
|
37
|
-
props: {
|
|
38
|
-
provider: {
|
|
39
|
-
type: String,
|
|
40
|
-
default: '',
|
|
41
|
-
validator: (val) => val === '' || MAP_PROVIDERS.includes(val)
|
|
42
|
-
},
|
|
43
|
-
apiKey: {
|
|
44
|
-
type: String,
|
|
45
|
-
default: ''
|
|
46
|
-
},
|
|
47
|
-
apiUrl: {
|
|
48
|
-
type: String,
|
|
49
|
-
default: ''
|
|
50
|
-
},
|
|
51
|
-
mapType: {
|
|
52
|
-
type: String,
|
|
53
|
-
default: '',
|
|
54
|
-
validator: (val) => val === '' || MAP_TYPES.includes(val)
|
|
55
|
-
},
|
|
56
|
-
theme: {
|
|
57
|
-
type: String,
|
|
58
|
-
default: '',
|
|
59
|
-
validator: (val) => val === '' || MAP_THEMES.includes(val)
|
|
60
|
-
},
|
|
61
|
-
center: {
|
|
62
|
-
type: Array,
|
|
63
|
-
default: () => null
|
|
64
|
-
},
|
|
65
|
-
zoom: {
|
|
66
|
-
type: Number,
|
|
67
|
-
default: null
|
|
68
|
-
},
|
|
69
|
-
plugins: {
|
|
70
|
-
type: Array,
|
|
71
|
-
default: () => []
|
|
72
|
-
},
|
|
73
|
-
securityJsCode: {
|
|
74
|
-
type: String,
|
|
75
|
-
default: ''
|
|
76
|
-
},
|
|
77
|
-
tag: {
|
|
78
|
-
type: String,
|
|
79
|
-
default: 'div'
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
data() {
|
|
84
|
-
return {
|
|
85
|
-
mergedTheme: this.theme || getMapTheme() || 'light'
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
computed: {
|
|
90
|
-
wrapperStyle() {
|
|
91
|
-
return {}
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
watch: {
|
|
96
|
-
provider: {
|
|
97
|
-
immediate: true,
|
|
98
|
-
handler(newVal) {
|
|
99
|
-
if (newVal) setMapProvider(newVal)
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
apiKey: {
|
|
103
|
-
immediate: true,
|
|
104
|
-
handler(newVal) {
|
|
105
|
-
if (newVal) setMapApiKey(newVal)
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
apiUrl: {
|
|
109
|
-
immediate: true,
|
|
110
|
-
handler(newVal) {
|
|
111
|
-
if (newVal) setMapApiUrl(newVal)
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
mapType: {
|
|
115
|
-
immediate: true,
|
|
116
|
-
handler(newVal) {
|
|
117
|
-
if (newVal) setMapType(newVal)
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
theme: {
|
|
121
|
-
immediate: true,
|
|
122
|
-
handler(newVal) {
|
|
123
|
-
if (newVal) {
|
|
124
|
-
setMapTheme(newVal)
|
|
125
|
-
this.mergedTheme = newVal
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
center: {
|
|
130
|
-
immediate: true,
|
|
131
|
-
handler(newVal) {
|
|
132
|
-
if (newVal) setMapCenter(newVal)
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
zoom: {
|
|
136
|
-
immediate: true,
|
|
137
|
-
handler(newVal) {
|
|
138
|
-
if (newVal !== null && newVal !== undefined) setMapZoom(newVal)
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
plugins: {
|
|
142
|
-
immediate: true,
|
|
143
|
-
handler(newVal) {
|
|
144
|
-
if (newVal && newVal.length > 0) setMapPlugins(newVal)
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
securityJsCode: {
|
|
148
|
-
immediate: true,
|
|
149
|
-
handler(newVal) {
|
|
150
|
-
if (newVal) setSecurityJsCode(newVal)
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
|
|
155
|
-
provide() {
|
|
156
|
-
return {
|
|
157
|
-
xtMapConfig: {
|
|
158
|
-
getProvider: () => this.provider || getMapProvider(),
|
|
159
|
-
getApiKey: () => this.apiKey || getMapApiKey(),
|
|
160
|
-
getApiUrl: () => this.apiUrl || getMapApiUrl(),
|
|
161
|
-
getMapType: () => this.mapType || getMapType(),
|
|
162
|
-
getTheme: () => this.theme || getMapTheme(),
|
|
163
|
-
getCenter: () => this.center || getMapCenter(),
|
|
164
|
-
getZoom: () => this.zoom !== null ? this.zoom : getMapZoom(),
|
|
165
|
-
getPlugins: () => this.plugins.length > 0 ? this.plugins : getMapPlugins(),
|
|
166
|
-
getConfig: () => ({
|
|
167
|
-
provider: this.provider || getMapProvider(),
|
|
168
|
-
apiKey: this.apiKey || getMapApiKey(),
|
|
169
|
-
apiUrl: this.apiUrl || getMapApiUrl(),
|
|
170
|
-
mapType: this.mapType || getMapType(),
|
|
171
|
-
theme: this.theme || getMapTheme(),
|
|
172
|
-
center: this.center || getMapCenter(),
|
|
173
|
-
zoom: this.zoom !== null ? this.zoom : getMapZoom()
|
|
174
|
-
})
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
|
|
179
|
-
created() {
|
|
180
|
-
this._unsubscribe = onMapConfigChange((key, value) => {
|
|
181
|
-
if (key === 'theme') this.mergedTheme = this.theme || value
|
|
182
|
-
})
|
|
183
|
-
},
|
|
184
|
-
|
|
185
|
-
beforeDestroy() {
|
|
186
|
-
if (this._unsubscribe) this._unsubscribe()
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
</script>
|
|
190
|
-
|
|
191
|
-
<style scoped>
|
|
192
|
-
.xt-map-provider {
|
|
193
|
-
width: 100%;
|
|
194
|
-
height: 100%;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.xt-map-provider--dark {
|
|
198
|
-
background-color: transparent;
|
|
199
|
-
}
|
|
200
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="['xt-map-provider', { 'xt-map-provider--dark': mergedTheme === 'dark' }]" :style="wrapperStyle">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import {
|
|
9
|
+
getMapConfig,
|
|
10
|
+
setMapConfig,
|
|
11
|
+
setMapProvider,
|
|
12
|
+
setMapApiKey,
|
|
13
|
+
setMapApiUrl,
|
|
14
|
+
setMapType,
|
|
15
|
+
setMapTheme,
|
|
16
|
+
setMapCenter,
|
|
17
|
+
setMapZoom,
|
|
18
|
+
setMapPlugins,
|
|
19
|
+
setSecurityJsCode,
|
|
20
|
+
getMapProvider,
|
|
21
|
+
getMapApiKey,
|
|
22
|
+
getMapApiUrl,
|
|
23
|
+
getMapType,
|
|
24
|
+
getMapTheme,
|
|
25
|
+
getMapCenter,
|
|
26
|
+
getMapZoom,
|
|
27
|
+
getMapPlugins,
|
|
28
|
+
MAP_PROVIDERS,
|
|
29
|
+
MAP_TYPES,
|
|
30
|
+
MAP_THEMES,
|
|
31
|
+
onMapConfigChange
|
|
32
|
+
} from './config/xt-map-config'
|
|
33
|
+
|
|
34
|
+
export default {
|
|
35
|
+
name: 'XtMapProvider',
|
|
36
|
+
|
|
37
|
+
props: {
|
|
38
|
+
provider: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: '',
|
|
41
|
+
validator: (val) => val === '' || MAP_PROVIDERS.includes(val)
|
|
42
|
+
},
|
|
43
|
+
apiKey: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: ''
|
|
46
|
+
},
|
|
47
|
+
apiUrl: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: ''
|
|
50
|
+
},
|
|
51
|
+
mapType: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: '',
|
|
54
|
+
validator: (val) => val === '' || MAP_TYPES.includes(val)
|
|
55
|
+
},
|
|
56
|
+
theme: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: '',
|
|
59
|
+
validator: (val) => val === '' || MAP_THEMES.includes(val)
|
|
60
|
+
},
|
|
61
|
+
center: {
|
|
62
|
+
type: Array,
|
|
63
|
+
default: () => null
|
|
64
|
+
},
|
|
65
|
+
zoom: {
|
|
66
|
+
type: Number,
|
|
67
|
+
default: null
|
|
68
|
+
},
|
|
69
|
+
plugins: {
|
|
70
|
+
type: Array,
|
|
71
|
+
default: () => []
|
|
72
|
+
},
|
|
73
|
+
securityJsCode: {
|
|
74
|
+
type: String,
|
|
75
|
+
default: ''
|
|
76
|
+
},
|
|
77
|
+
tag: {
|
|
78
|
+
type: String,
|
|
79
|
+
default: 'div'
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
data() {
|
|
84
|
+
return {
|
|
85
|
+
mergedTheme: this.theme || getMapTheme() || 'light'
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
computed: {
|
|
90
|
+
wrapperStyle() {
|
|
91
|
+
return {}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
watch: {
|
|
96
|
+
provider: {
|
|
97
|
+
immediate: true,
|
|
98
|
+
handler(newVal) {
|
|
99
|
+
if (newVal) setMapProvider(newVal)
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
apiKey: {
|
|
103
|
+
immediate: true,
|
|
104
|
+
handler(newVal) {
|
|
105
|
+
if (newVal) setMapApiKey(newVal)
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
apiUrl: {
|
|
109
|
+
immediate: true,
|
|
110
|
+
handler(newVal) {
|
|
111
|
+
if (newVal) setMapApiUrl(newVal)
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
mapType: {
|
|
115
|
+
immediate: true,
|
|
116
|
+
handler(newVal) {
|
|
117
|
+
if (newVal) setMapType(newVal)
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
theme: {
|
|
121
|
+
immediate: true,
|
|
122
|
+
handler(newVal) {
|
|
123
|
+
if (newVal) {
|
|
124
|
+
setMapTheme(newVal)
|
|
125
|
+
this.mergedTheme = newVal
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
center: {
|
|
130
|
+
immediate: true,
|
|
131
|
+
handler(newVal) {
|
|
132
|
+
if (newVal) setMapCenter(newVal)
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
zoom: {
|
|
136
|
+
immediate: true,
|
|
137
|
+
handler(newVal) {
|
|
138
|
+
if (newVal !== null && newVal !== undefined) setMapZoom(newVal)
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
plugins: {
|
|
142
|
+
immediate: true,
|
|
143
|
+
handler(newVal) {
|
|
144
|
+
if (newVal && newVal.length > 0) setMapPlugins(newVal)
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
securityJsCode: {
|
|
148
|
+
immediate: true,
|
|
149
|
+
handler(newVal) {
|
|
150
|
+
if (newVal) setSecurityJsCode(newVal)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
provide() {
|
|
156
|
+
return {
|
|
157
|
+
xtMapConfig: {
|
|
158
|
+
getProvider: () => this.provider || getMapProvider(),
|
|
159
|
+
getApiKey: () => this.apiKey || getMapApiKey(),
|
|
160
|
+
getApiUrl: () => this.apiUrl || getMapApiUrl(),
|
|
161
|
+
getMapType: () => this.mapType || getMapType(),
|
|
162
|
+
getTheme: () => this.theme || getMapTheme(),
|
|
163
|
+
getCenter: () => this.center || getMapCenter(),
|
|
164
|
+
getZoom: () => this.zoom !== null ? this.zoom : getMapZoom(),
|
|
165
|
+
getPlugins: () => this.plugins.length > 0 ? this.plugins : getMapPlugins(),
|
|
166
|
+
getConfig: () => ({
|
|
167
|
+
provider: this.provider || getMapProvider(),
|
|
168
|
+
apiKey: this.apiKey || getMapApiKey(),
|
|
169
|
+
apiUrl: this.apiUrl || getMapApiUrl(),
|
|
170
|
+
mapType: this.mapType || getMapType(),
|
|
171
|
+
theme: this.theme || getMapTheme(),
|
|
172
|
+
center: this.center || getMapCenter(),
|
|
173
|
+
zoom: this.zoom !== null ? this.zoom : getMapZoom()
|
|
174
|
+
})
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
created() {
|
|
180
|
+
this._unsubscribe = onMapConfigChange((key, value) => {
|
|
181
|
+
if (key === 'theme') this.mergedTheme = this.theme || value
|
|
182
|
+
})
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
beforeDestroy() {
|
|
186
|
+
if (this._unsubscribe) this._unsubscribe()
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
</script>
|
|
190
|
+
|
|
191
|
+
<style scoped>
|
|
192
|
+
.xt-map-provider {
|
|
193
|
+
width: 100%;
|
|
194
|
+
height: 100%;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.xt-map-provider--dark {
|
|
198
|
+
background-color: transparent;
|
|
199
|
+
}
|
|
200
|
+
</style>
|