xt-element-ui 1.3.3 → 1.4.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/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 +4575 -4186
- package/lib/index.css +1 -1
- package/lib/index.umd.js +4475 -4085
- package/lib/index.umd.min.js +5 -5
- 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-chart/theme/dark.js +4 -1
- 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 +49 -40
- package/src/components/xt-badge/index.js +7 -0
- package/src/components/xt-badge/index.vue +71 -0
- package/src/components/xt-badge/style/index.scss +88 -0
- 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/index.vue +5 -5
- 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-progress/index.js +7 -0
- package/src/components/xt-progress/index.vue +103 -0
- package/src/components/xt-progress/style/index.scss +119 -0
- 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-tabs/TabPane.vue +36 -0
- package/src/components/xt-tabs/index.js +10 -0
- package/src/components/xt-tabs/index.vue +113 -0
- package/src/components/xt-tabs/style/index.scss +197 -0
- package/src/components/xt-text/index.js +7 -7
- package/src/components/xt-text/index.vue +16 -2
- package/src/components/xt-text/style/index.scss +110 -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 +169 -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,197 +1,197 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* XtMap 全局配置管理
|
|
3
|
-
* 支持通过 Vue.use 配置或运行时动态设置地图提供商、密钥、URL、主题等
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// 支持的地图提供商
|
|
7
|
-
export const MAP_PROVIDERS = ['amap', 'tianditu', 'baidu']
|
|
8
|
-
|
|
9
|
-
// 支持的地图类型(统一枚举,各适配器会转成对应引擎的类型)
|
|
10
|
-
export const MAP_TYPES = ['standard', 'satellite', 'hybrid', 'traffic']
|
|
11
|
-
|
|
12
|
-
// 支持的主题
|
|
13
|
-
export const MAP_THEMES = ['light', 'dark']
|
|
14
|
-
|
|
15
|
-
// 默认配置 - 以高德地图为基准
|
|
16
|
-
const defaultConfig = {
|
|
17
|
-
provider: 'amap',
|
|
18
|
-
apiKey: '',
|
|
19
|
-
apiUrl: null,
|
|
20
|
-
mapType: 'standard',
|
|
21
|
-
theme: 'light',
|
|
22
|
-
center: [116.397428, 39.90923],
|
|
23
|
-
zoom: 11,
|
|
24
|
-
plugins: [],
|
|
25
|
-
securityJsCode: null,
|
|
26
|
-
// 天地图专用:图层类型(vec:矢量, img:影像, ter:地形)
|
|
27
|
-
tiandituLayerType: 'vec',
|
|
28
|
-
// 百度地图专用:坐标系(bd09ll:百度经纬度, bd09mc:百度墨卡托)
|
|
29
|
-
baiduCoordType: 'bd09ll'
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// 当前配置
|
|
33
|
-
let currentConfig = { ...defaultConfig }
|
|
34
|
-
|
|
35
|
-
// 配置变更监听器
|
|
36
|
-
const configChangeListeners = []
|
|
37
|
-
|
|
38
|
-
const emitConfigChange = (key, value) => {
|
|
39
|
-
configChangeListeners.forEach(listener => {
|
|
40
|
-
try {
|
|
41
|
-
listener(key, value)
|
|
42
|
-
} catch (e) {
|
|
43
|
-
console.warn('[XtMap] 配置变更监听异常:', e)
|
|
44
|
-
}
|
|
45
|
-
})
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// 获取完整配置
|
|
49
|
-
export const getMapConfig = () => ({ ...currentConfig })
|
|
50
|
-
|
|
51
|
-
// 设置完整配置
|
|
52
|
-
export const setMapConfig = (config) => {
|
|
53
|
-
if (typeof config !== 'object' || config === null) {
|
|
54
|
-
console.warn('[XtMap] setMapConfig 必须传入对象参数')
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (config.provider !== undefined) setMapProvider(config.provider)
|
|
59
|
-
if (config.apiKey !== undefined) setMapApiKey(config.apiKey)
|
|
60
|
-
if (config.apiUrl !== undefined) setMapApiUrl(config.apiUrl)
|
|
61
|
-
if (config.mapType !== undefined) setMapType(config.mapType)
|
|
62
|
-
if (config.theme !== undefined) setMapTheme(config.theme)
|
|
63
|
-
if (config.center !== undefined) setMapCenter(config.center)
|
|
64
|
-
if (config.zoom !== undefined) setMapZoom(config.zoom)
|
|
65
|
-
if (config.plugins !== undefined) setMapPlugins(config.plugins)
|
|
66
|
-
if (config.securityJsCode !== undefined) setSecurityJsCode(config.securityJsCode)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export const setMapProvider = (provider) => {
|
|
70
|
-
if (!MAP_PROVIDERS.includes(provider)) {
|
|
71
|
-
console.warn(`[XtMap] 无效的地图提供商: ${provider},可选: ${MAP_PROVIDERS.join(', ')}`)
|
|
72
|
-
return
|
|
73
|
-
}
|
|
74
|
-
currentConfig.provider = provider
|
|
75
|
-
emitConfigChange('provider', provider)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export const setMapApiKey = (key) => {
|
|
79
|
-
currentConfig.apiKey = key
|
|
80
|
-
emitConfigChange('apiKey', key)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export const setMapApiUrl = (url) => {
|
|
84
|
-
currentConfig.apiUrl = url
|
|
85
|
-
emitConfigChange('apiUrl', url)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export const setMapType = (type) => {
|
|
89
|
-
if (!MAP_TYPES.includes(type)) {
|
|
90
|
-
console.warn(`[XtMap] 无效的地图类型: ${type},可选: ${MAP_TYPES.join(', ')}`)
|
|
91
|
-
return
|
|
92
|
-
}
|
|
93
|
-
currentConfig.mapType = type
|
|
94
|
-
emitConfigChange('mapType', type)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export const setMapTheme = (theme) => {
|
|
98
|
-
if (!MAP_THEMES.includes(theme)) {
|
|
99
|
-
console.warn(`[XtMap] 无效的主题: ${theme},可选: ${MAP_THEMES.join(', ')}`)
|
|
100
|
-
return
|
|
101
|
-
}
|
|
102
|
-
currentConfig.theme = theme
|
|
103
|
-
emitConfigChange('theme', theme)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export const setMapCenter = (center) => {
|
|
107
|
-
if (!Array.isArray(center) || center.length !== 2) {
|
|
108
|
-
console.warn('[XtMap] center 必须是 [lng, lat] 数组')
|
|
109
|
-
return
|
|
110
|
-
}
|
|
111
|
-
currentConfig.center = center
|
|
112
|
-
emitConfigChange('center', center)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export const setMapZoom = (zoom) => {
|
|
116
|
-
const z = Number(zoom)
|
|
117
|
-
if (isNaN(z)) {
|
|
118
|
-
console.warn('[XtMap] zoom 必须是数字')
|
|
119
|
-
return
|
|
120
|
-
}
|
|
121
|
-
currentConfig.zoom = z
|
|
122
|
-
emitConfigChange('zoom', z)
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export const setMapPlugins = (plugins) => {
|
|
126
|
-
if (!Array.isArray(plugins)) {
|
|
127
|
-
console.warn('[XtMap] plugins 必须是数组')
|
|
128
|
-
return
|
|
129
|
-
}
|
|
130
|
-
currentConfig.plugins = plugins
|
|
131
|
-
emitConfigChange('plugins', plugins)
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export const setSecurityJsCode = (code) => {
|
|
135
|
-
currentConfig.securityJsCode = code
|
|
136
|
-
// 高德地图安全密钥:设置 window._AMapSecurityConfig
|
|
137
|
-
if (typeof window !== 'undefined' && code) {
|
|
138
|
-
window._AMapSecurityConfig = {
|
|
139
|
-
securityJsCode: code,
|
|
140
|
-
...(window._AMapSecurityConfig || {})
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
emitConfigChange('securityJsCode', code)
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// 获取当前配置的快捷方法
|
|
147
|
-
export const getMapProvider = () => currentConfig.provider
|
|
148
|
-
export const getMapApiKey = () => currentConfig.apiKey
|
|
149
|
-
export const getMapApiUrl = () => currentConfig.apiUrl
|
|
150
|
-
export const getMapType = () => currentConfig.mapType
|
|
151
|
-
export const getMapTheme = () => currentConfig.theme
|
|
152
|
-
export const getMapCenter = () => currentConfig.center
|
|
153
|
-
export const getMapZoom = () => currentConfig.zoom
|
|
154
|
-
export const getMapPlugins = () => currentConfig.plugins
|
|
155
|
-
|
|
156
|
-
// 监听配置变更
|
|
157
|
-
export const onMapConfigChange = (listener) => {
|
|
158
|
-
if (typeof listener === 'function') {
|
|
159
|
-
configChangeListeners.push(listener)
|
|
160
|
-
return () => {
|
|
161
|
-
const index = configChangeListeners.indexOf(listener)
|
|
162
|
-
if (index > -1) configChangeListeners.splice(index, 1)
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// 重置为默认配置
|
|
168
|
-
export const resetMapConfig = () => {
|
|
169
|
-
setMapConfig(defaultConfig)
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export default {
|
|
173
|
-
MAP_PROVIDERS,
|
|
174
|
-
MAP_TYPES,
|
|
175
|
-
MAP_THEMES,
|
|
176
|
-
getMapConfig,
|
|
177
|
-
setMapConfig,
|
|
178
|
-
setMapProvider,
|
|
179
|
-
setMapApiKey,
|
|
180
|
-
setMapApiUrl,
|
|
181
|
-
setMapType,
|
|
182
|
-
setMapTheme,
|
|
183
|
-
setMapCenter,
|
|
184
|
-
setMapZoom,
|
|
185
|
-
setMapPlugins,
|
|
186
|
-
setSecurityJsCode,
|
|
187
|
-
getMapProvider,
|
|
188
|
-
getMapApiKey,
|
|
189
|
-
getMapApiUrl,
|
|
190
|
-
getMapType,
|
|
191
|
-
getMapTheme,
|
|
192
|
-
getMapCenter,
|
|
193
|
-
getMapZoom,
|
|
194
|
-
getMapPlugins,
|
|
195
|
-
onMapConfigChange,
|
|
196
|
-
resetMapConfig
|
|
197
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* XtMap 全局配置管理
|
|
3
|
+
* 支持通过 Vue.use 配置或运行时动态设置地图提供商、密钥、URL、主题等
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// 支持的地图提供商
|
|
7
|
+
export const MAP_PROVIDERS = ['amap', 'tianditu', 'baidu']
|
|
8
|
+
|
|
9
|
+
// 支持的地图类型(统一枚举,各适配器会转成对应引擎的类型)
|
|
10
|
+
export const MAP_TYPES = ['standard', 'satellite', 'hybrid', 'traffic']
|
|
11
|
+
|
|
12
|
+
// 支持的主题
|
|
13
|
+
export const MAP_THEMES = ['light', 'dark']
|
|
14
|
+
|
|
15
|
+
// 默认配置 - 以高德地图为基准
|
|
16
|
+
const defaultConfig = {
|
|
17
|
+
provider: 'amap',
|
|
18
|
+
apiKey: '',
|
|
19
|
+
apiUrl: null,
|
|
20
|
+
mapType: 'standard',
|
|
21
|
+
theme: 'light',
|
|
22
|
+
center: [116.397428, 39.90923],
|
|
23
|
+
zoom: 11,
|
|
24
|
+
plugins: [],
|
|
25
|
+
securityJsCode: null,
|
|
26
|
+
// 天地图专用:图层类型(vec:矢量, img:影像, ter:地形)
|
|
27
|
+
tiandituLayerType: 'vec',
|
|
28
|
+
// 百度地图专用:坐标系(bd09ll:百度经纬度, bd09mc:百度墨卡托)
|
|
29
|
+
baiduCoordType: 'bd09ll'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// 当前配置
|
|
33
|
+
let currentConfig = { ...defaultConfig }
|
|
34
|
+
|
|
35
|
+
// 配置变更监听器
|
|
36
|
+
const configChangeListeners = []
|
|
37
|
+
|
|
38
|
+
const emitConfigChange = (key, value) => {
|
|
39
|
+
configChangeListeners.forEach(listener => {
|
|
40
|
+
try {
|
|
41
|
+
listener(key, value)
|
|
42
|
+
} catch (e) {
|
|
43
|
+
console.warn('[XtMap] 配置变更监听异常:', e)
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 获取完整配置
|
|
49
|
+
export const getMapConfig = () => ({ ...currentConfig })
|
|
50
|
+
|
|
51
|
+
// 设置完整配置
|
|
52
|
+
export const setMapConfig = (config) => {
|
|
53
|
+
if (typeof config !== 'object' || config === null) {
|
|
54
|
+
console.warn('[XtMap] setMapConfig 必须传入对象参数')
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (config.provider !== undefined) setMapProvider(config.provider)
|
|
59
|
+
if (config.apiKey !== undefined) setMapApiKey(config.apiKey)
|
|
60
|
+
if (config.apiUrl !== undefined) setMapApiUrl(config.apiUrl)
|
|
61
|
+
if (config.mapType !== undefined) setMapType(config.mapType)
|
|
62
|
+
if (config.theme !== undefined) setMapTheme(config.theme)
|
|
63
|
+
if (config.center !== undefined) setMapCenter(config.center)
|
|
64
|
+
if (config.zoom !== undefined) setMapZoom(config.zoom)
|
|
65
|
+
if (config.plugins !== undefined) setMapPlugins(config.plugins)
|
|
66
|
+
if (config.securityJsCode !== undefined) setSecurityJsCode(config.securityJsCode)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const setMapProvider = (provider) => {
|
|
70
|
+
if (!MAP_PROVIDERS.includes(provider)) {
|
|
71
|
+
console.warn(`[XtMap] 无效的地图提供商: ${provider},可选: ${MAP_PROVIDERS.join(', ')}`)
|
|
72
|
+
return
|
|
73
|
+
}
|
|
74
|
+
currentConfig.provider = provider
|
|
75
|
+
emitConfigChange('provider', provider)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const setMapApiKey = (key) => {
|
|
79
|
+
currentConfig.apiKey = key
|
|
80
|
+
emitConfigChange('apiKey', key)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const setMapApiUrl = (url) => {
|
|
84
|
+
currentConfig.apiUrl = url
|
|
85
|
+
emitConfigChange('apiUrl', url)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export const setMapType = (type) => {
|
|
89
|
+
if (!MAP_TYPES.includes(type)) {
|
|
90
|
+
console.warn(`[XtMap] 无效的地图类型: ${type},可选: ${MAP_TYPES.join(', ')}`)
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
currentConfig.mapType = type
|
|
94
|
+
emitConfigChange('mapType', type)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export const setMapTheme = (theme) => {
|
|
98
|
+
if (!MAP_THEMES.includes(theme)) {
|
|
99
|
+
console.warn(`[XtMap] 无效的主题: ${theme},可选: ${MAP_THEMES.join(', ')}`)
|
|
100
|
+
return
|
|
101
|
+
}
|
|
102
|
+
currentConfig.theme = theme
|
|
103
|
+
emitConfigChange('theme', theme)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export const setMapCenter = (center) => {
|
|
107
|
+
if (!Array.isArray(center) || center.length !== 2) {
|
|
108
|
+
console.warn('[XtMap] center 必须是 [lng, lat] 数组')
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
currentConfig.center = center
|
|
112
|
+
emitConfigChange('center', center)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export const setMapZoom = (zoom) => {
|
|
116
|
+
const z = Number(zoom)
|
|
117
|
+
if (isNaN(z)) {
|
|
118
|
+
console.warn('[XtMap] zoom 必须是数字')
|
|
119
|
+
return
|
|
120
|
+
}
|
|
121
|
+
currentConfig.zoom = z
|
|
122
|
+
emitConfigChange('zoom', z)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export const setMapPlugins = (plugins) => {
|
|
126
|
+
if (!Array.isArray(plugins)) {
|
|
127
|
+
console.warn('[XtMap] plugins 必须是数组')
|
|
128
|
+
return
|
|
129
|
+
}
|
|
130
|
+
currentConfig.plugins = plugins
|
|
131
|
+
emitConfigChange('plugins', plugins)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export const setSecurityJsCode = (code) => {
|
|
135
|
+
currentConfig.securityJsCode = code
|
|
136
|
+
// 高德地图安全密钥:设置 window._AMapSecurityConfig
|
|
137
|
+
if (typeof window !== 'undefined' && code) {
|
|
138
|
+
window._AMapSecurityConfig = {
|
|
139
|
+
securityJsCode: code,
|
|
140
|
+
...(window._AMapSecurityConfig || {})
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
emitConfigChange('securityJsCode', code)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// 获取当前配置的快捷方法
|
|
147
|
+
export const getMapProvider = () => currentConfig.provider
|
|
148
|
+
export const getMapApiKey = () => currentConfig.apiKey
|
|
149
|
+
export const getMapApiUrl = () => currentConfig.apiUrl
|
|
150
|
+
export const getMapType = () => currentConfig.mapType
|
|
151
|
+
export const getMapTheme = () => currentConfig.theme
|
|
152
|
+
export const getMapCenter = () => currentConfig.center
|
|
153
|
+
export const getMapZoom = () => currentConfig.zoom
|
|
154
|
+
export const getMapPlugins = () => currentConfig.plugins
|
|
155
|
+
|
|
156
|
+
// 监听配置变更
|
|
157
|
+
export const onMapConfigChange = (listener) => {
|
|
158
|
+
if (typeof listener === 'function') {
|
|
159
|
+
configChangeListeners.push(listener)
|
|
160
|
+
return () => {
|
|
161
|
+
const index = configChangeListeners.indexOf(listener)
|
|
162
|
+
if (index > -1) configChangeListeners.splice(index, 1)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// 重置为默认配置
|
|
168
|
+
export const resetMapConfig = () => {
|
|
169
|
+
setMapConfig(defaultConfig)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export default {
|
|
173
|
+
MAP_PROVIDERS,
|
|
174
|
+
MAP_TYPES,
|
|
175
|
+
MAP_THEMES,
|
|
176
|
+
getMapConfig,
|
|
177
|
+
setMapConfig,
|
|
178
|
+
setMapProvider,
|
|
179
|
+
setMapApiKey,
|
|
180
|
+
setMapApiUrl,
|
|
181
|
+
setMapType,
|
|
182
|
+
setMapTheme,
|
|
183
|
+
setMapCenter,
|
|
184
|
+
setMapZoom,
|
|
185
|
+
setMapPlugins,
|
|
186
|
+
setSecurityJsCode,
|
|
187
|
+
getMapProvider,
|
|
188
|
+
getMapApiKey,
|
|
189
|
+
getMapApiUrl,
|
|
190
|
+
getMapType,
|
|
191
|
+
getMapTheme,
|
|
192
|
+
getMapCenter,
|
|
193
|
+
getMapZoom,
|
|
194
|
+
getMapPlugins,
|
|
195
|
+
onMapConfigChange,
|
|
196
|
+
resetMapConfig
|
|
197
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import XtMap from './index.vue'
|
|
2
|
-
|
|
3
|
-
XtMap.install = function (Vue) {
|
|
4
|
-
Vue.component(XtMap.name, XtMap)
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export default XtMap
|
|
8
|
-
export { XtMap }
|
|
1
|
+
import XtMap from './index.vue'
|
|
2
|
+
|
|
3
|
+
XtMap.install = function (Vue) {
|
|
4
|
+
Vue.component(XtMap.name, XtMap)
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export default XtMap
|
|
8
|
+
export { XtMap }
|