gis-common 3.1.2 → 3.1.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/dist/constant/ErrorTypeConstant.d.ts +23 -0
- package/dist/constant/EventTypeConstant.d.ts +24 -0
- package/dist/constant/GraphicConstant.d.ts +16 -0
- package/dist/constant/LayerType.d.ts +10 -0
- package/dist/constant/index.d.ts +4 -0
- package/dist/gis-common.es.js +1751 -0
- package/dist/gis-common.umd.js +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/utils/Cookie.d.ts +6 -0
- package/dist/utils/MathUtils.d.ts +36 -0
- package/package.json +26 -28
- package/dist/resource.min.js +0 -1
- package/src/assets/images/location.png +0 -0
- package/src/constant/ErrorTypeConstant.js +0 -22
- package/src/constant/EventTypeConstant.js +0 -23
- package/src/constant/GraphicConstant.js +0 -16
- package/src/constant/LayerType.js +0 -9
- package/src/constant/index.js +0 -4
- package/src/core/AudioPlayer.js +0 -30
- package/src/core/CanvasDrawer.js +0 -51
- package/src/core/DevicePixelRatio.js +0 -86
- package/src/core/ElQuery.js +0 -88
- package/src/core/EventDispatcher.js +0 -93
- package/src/core/HashMap.js +0 -26
- package/src/core/MqttClient.js +0 -108
- package/src/core/WebSocketClient.js +0 -104
- package/src/core/WebStorage.js +0 -73
- package/src/index.js +0 -10
- package/src/utils/AnimateUtils.js +0 -78
- package/src/utils/ArrayUtils.js +0 -82
- package/src/utils/AssertUtils.js +0 -112
- package/src/utils/BrowserUtils.js +0 -107
- package/src/utils/CommUtils.js +0 -236
- package/src/utils/Cookie.js +0 -23
- package/src/utils/CoordsUtils.js +0 -145
- package/src/utils/DateUtils.js +0 -144
- package/src/utils/DomUtils.js +0 -94
- package/src/utils/FileUtils.js +0 -104
- package/src/utils/GeoUtils.js +0 -253
- package/src/utils/MathUtils.js +0 -49
- package/src/utils/OptimizeUtils.js +0 -94
- package/src/utils/StringUtils.js +0 -148
- package/src/utils/index.js +0 -14
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
/**
|
|
3
|
-
* @desc 在事件被触发n秒后再执行回调函数,如果在这n秒内又被触发,则重新计时
|
|
4
|
-
* @desc 防止onresize,scroll,mousemove ,mousehover等,会被频繁触发影响性能
|
|
5
|
-
* @param func 需要执行的函数
|
|
6
|
-
* @param wait 延迟执行时间(毫秒)
|
|
7
|
-
* @param immediate---true 表立即执行,false 表非立即执行
|
|
8
|
-
* eg: window.addEventListener("resize",debounce(handle,1000));
|
|
9
|
-
* @returns {*}
|
|
10
|
-
*/
|
|
11
|
-
debounce(func, wait, immediate = true) {
|
|
12
|
-
let timeout, args, context, timestamp, result
|
|
13
|
-
|
|
14
|
-
const later = function () {
|
|
15
|
-
// 据上一次触发时间间隔
|
|
16
|
-
const last = +new Date() - timestamp
|
|
17
|
-
|
|
18
|
-
// 上次被包装函数被调用时间间隔last小于设定时间间隔wait
|
|
19
|
-
if (last < wait && last > 0) {
|
|
20
|
-
timeout = setTimeout(later, wait - last)
|
|
21
|
-
} else {
|
|
22
|
-
timeout = null
|
|
23
|
-
// 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
|
|
24
|
-
if (!immediate) {
|
|
25
|
-
result = func.apply(context, args)
|
|
26
|
-
if (!timeout) context = args = null
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return function (...args) {
|
|
32
|
-
context = this
|
|
33
|
-
timestamp = +new Date()
|
|
34
|
-
const callNow = immediate && !timeout
|
|
35
|
-
// 如果延时不存在,重新设定延时
|
|
36
|
-
if (!timeout) timeout = setTimeout(later, wait)
|
|
37
|
-
if (callNow) {
|
|
38
|
-
result = func.apply(context, args)
|
|
39
|
-
context = args = null
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return result
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
/**
|
|
46
|
-
* 规定一个单位时间,在这个单位时间内,只能有一次触发事件的回调函数执行,如果在同一个单位时间内某事件被触发多次,只有一次能生效
|
|
47
|
-
*
|
|
48
|
-
* @param {*} func
|
|
49
|
-
* @param {*} wait
|
|
50
|
-
* @param {*} type 1 表时间戳版,2 表定时器版
|
|
51
|
-
* @returns {*}
|
|
52
|
-
*/
|
|
53
|
-
throttle(func, wait, type) {
|
|
54
|
-
if (type === 1) {
|
|
55
|
-
var previous = 0
|
|
56
|
-
} else if (type === 2) {
|
|
57
|
-
var timeout
|
|
58
|
-
}
|
|
59
|
-
return function () {
|
|
60
|
-
let context = this
|
|
61
|
-
let args = arguments
|
|
62
|
-
if (type === 1) {
|
|
63
|
-
let now = Date.now()
|
|
64
|
-
if (now - previous > wait) {
|
|
65
|
-
func.apply(context, args)
|
|
66
|
-
previous = now
|
|
67
|
-
}
|
|
68
|
-
} else if (type === 2) {
|
|
69
|
-
if (!timeout) {
|
|
70
|
-
timeout = setTimeout(() => {
|
|
71
|
-
timeout = null
|
|
72
|
-
func.apply(context, args)
|
|
73
|
-
}, wait)
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
/**
|
|
79
|
-
* 延时递归
|
|
80
|
-
*
|
|
81
|
-
* @param {Number} frequency 间隔时间ms
|
|
82
|
-
* @param {Number} duration 持续时间ms
|
|
83
|
-
*/
|
|
84
|
-
recurve(fun, frequency = 500, duration = 5000) {
|
|
85
|
-
let timer = 0
|
|
86
|
-
setTimeout(function fn() {
|
|
87
|
-
timer++
|
|
88
|
-
if (timer < Math.floor(duration / frequency)) {
|
|
89
|
-
fun.call(this)
|
|
90
|
-
setTimeout(fn, frequency)
|
|
91
|
-
}
|
|
92
|
-
})
|
|
93
|
-
},
|
|
94
|
-
}
|
package/src/utils/StringUtils.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import CommUtils from './CommUtils'
|
|
2
|
-
export default {
|
|
3
|
-
/**
|
|
4
|
-
* 常用正则验证
|
|
5
|
-
*
|
|
6
|
-
* @param {*} str
|
|
7
|
-
* @param {*} type
|
|
8
|
-
* @returns {*}
|
|
9
|
-
*/
|
|
10
|
-
checkStr(str, type) {
|
|
11
|
-
switch (type) {
|
|
12
|
-
case 'phone': // 手机号码
|
|
13
|
-
return /^1[3|4|5|6|7|8|9][0-9]{9}$/.test(str)
|
|
14
|
-
case 'tel': // 座机
|
|
15
|
-
return /^(0\d{2,3}-\d{7,8})(-\d{1,4})?$/.test(str)
|
|
16
|
-
case 'card': // 身份证
|
|
17
|
-
return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(str)
|
|
18
|
-
case 'pwd': // 密码以字母开头,长度在6~18之间,只能包含字母、数字和下划线
|
|
19
|
-
return /^[a-zA-Z]\w{5,17}$/.test(str)
|
|
20
|
-
case 'postal': // 邮政编码
|
|
21
|
-
return /[1-9]\d{5}(?!\d)/.test(str)
|
|
22
|
-
case 'QQ': // QQ号
|
|
23
|
-
return /^[1-9][0-9]{4,9}$/.test(str)
|
|
24
|
-
case 'email': // 邮箱
|
|
25
|
-
return /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(str)
|
|
26
|
-
case 'money': // 金额(小数点2位)
|
|
27
|
-
return /^\d*(?:\.\d{0,2})?$/.test(str)
|
|
28
|
-
case 'URL': // 网址
|
|
29
|
-
return /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/.test(str)
|
|
30
|
-
case 'IP': // IP
|
|
31
|
-
return /((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))/.test(str)
|
|
32
|
-
case 'date': // 日期时间
|
|
33
|
-
return /^(\d{4})\-(\d{2})\-(\d{2}) (\d{2})(?:\:\d{2}|:(\d{2}):(\d{2}))$/.test(str) || /^(\d{4})\-(\d{2})\-(\d{2})$/.test(str)
|
|
34
|
-
case 'number': // 数字
|
|
35
|
-
return /^[0-9]$/.test(str)
|
|
36
|
-
case 'english': // 英文
|
|
37
|
-
return /^[a-zA-Z]+$/.test(str)
|
|
38
|
-
case 'chinese': // 中文
|
|
39
|
-
return /^[\u4E00-\u9FA5]+$/.test(str)
|
|
40
|
-
case 'lower': // 小写
|
|
41
|
-
return /^[a-z]+$/.test(str)
|
|
42
|
-
case 'upper': // 大写
|
|
43
|
-
return /^[A-Z]+$/.test(str)
|
|
44
|
-
case 'HTML': // HTML标记
|
|
45
|
-
return /<("[^"]*"|'[^']*'|[^'">])*>/.test(str)
|
|
46
|
-
default:
|
|
47
|
-
return true
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
/**
|
|
51
|
-
* 字符串大小写转换 type: 1:首字母大写 2:首页母小写 3:大小写转换 4:全部大写 5:全部小写
|
|
52
|
-
*
|
|
53
|
-
* @param {*} str
|
|
54
|
-
* @param {*} type
|
|
55
|
-
* @returns {*}
|
|
56
|
-
*/
|
|
57
|
-
changeCase(str, type) {
|
|
58
|
-
type = type || 4
|
|
59
|
-
switch (type) {
|
|
60
|
-
case 1:
|
|
61
|
-
return str.replace(/\b\w+\b/g, function (word) {
|
|
62
|
-
return word.substring(0, 1).toUpperCase() + word.substring(1).toLowerCase()
|
|
63
|
-
})
|
|
64
|
-
case 2:
|
|
65
|
-
return str.replace(/\b\w+\b/g, function (word) {
|
|
66
|
-
return word.substring(0, 1).toLowerCase() + word.substring(1).toUpperCase()
|
|
67
|
-
})
|
|
68
|
-
case 3:
|
|
69
|
-
return str
|
|
70
|
-
.split('')
|
|
71
|
-
.map(function (word) {
|
|
72
|
-
if (/[a-z]/.test(word)) {
|
|
73
|
-
return word.toUpperCase()
|
|
74
|
-
} else {
|
|
75
|
-
return word.toLowerCase()
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
.join('')
|
|
79
|
-
case 4:
|
|
80
|
-
return str.toUpperCase()
|
|
81
|
-
case 5:
|
|
82
|
-
return str.toLowerCase()
|
|
83
|
-
default:
|
|
84
|
-
return str
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
/**
|
|
88
|
-
* 处理字符串模板
|
|
89
|
-
* eg: tag`${abc}`
|
|
90
|
-
* @param {*} strArray
|
|
91
|
-
* @param {*} args
|
|
92
|
-
* @returns {*}
|
|
93
|
-
*/
|
|
94
|
-
tag(strArray, ...args) {
|
|
95
|
-
args = args.map((val) => {
|
|
96
|
-
switch (CommUtils.getDataType(val)) {
|
|
97
|
-
case 'Object':
|
|
98
|
-
return val || '{}'
|
|
99
|
-
case 'Array':
|
|
100
|
-
return val || '[]'
|
|
101
|
-
default:
|
|
102
|
-
return val || ''
|
|
103
|
-
}
|
|
104
|
-
})
|
|
105
|
-
return strArray.reduce((prev, next, index) => `${prev}${args[index - 1]}${next}`)
|
|
106
|
-
},
|
|
107
|
-
/**
|
|
108
|
-
* 获取字符串字节长度
|
|
109
|
-
* @param {*} str
|
|
110
|
-
* @returns {*}
|
|
111
|
-
*/
|
|
112
|
-
getByteLength(str) {
|
|
113
|
-
return str.replace(/[\u0391-\uFFE5]/g, 'aa').length
|
|
114
|
-
},
|
|
115
|
-
/**
|
|
116
|
-
* 根据字节长度截取字符串
|
|
117
|
-
* @param {*} str
|
|
118
|
-
* @param {*} n
|
|
119
|
-
* @returns {*}
|
|
120
|
-
*/
|
|
121
|
-
subStringByte(str, start, n) {
|
|
122
|
-
var r = /[^\x00-\xff]/g
|
|
123
|
-
if (str.replace(r, 'mm').length <= n) {
|
|
124
|
-
return str
|
|
125
|
-
}
|
|
126
|
-
var m = Math.floor(n / 2)
|
|
127
|
-
for (var i = m; i < str.length; i++) {
|
|
128
|
-
let sub = str.substring(start, i)
|
|
129
|
-
if (sub.replace(r, 'mm').length >= n) {
|
|
130
|
-
return sub
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return str
|
|
134
|
-
},
|
|
135
|
-
asString(value) {
|
|
136
|
-
if (CommUtils.isEmpty(value)) {
|
|
137
|
-
return ''
|
|
138
|
-
} else {
|
|
139
|
-
switch (CommUtils.getDataType()) {
|
|
140
|
-
case 'Object':
|
|
141
|
-
case 'Array':
|
|
142
|
-
return JSON.stringify(value)
|
|
143
|
-
default:
|
|
144
|
-
return value
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
}
|
package/src/utils/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export { default as AnimateUtils } from './AnimateUtils'
|
|
2
|
-
export { default as ArrayUtils } from './ArrayUtils'
|
|
3
|
-
export { default as BrowserUtils } from './BrowserUtils'
|
|
4
|
-
export { default as Cookie } from './Cookie'
|
|
5
|
-
export { default as CoordsUtils } from './CoordsUtils'
|
|
6
|
-
export { default as DateUtils } from './DateUtils'
|
|
7
|
-
export { default as DomUtils } from './DomUtils'
|
|
8
|
-
export { default as GeoUtils } from './GeoUtils'
|
|
9
|
-
export { default as FileUtils } from './FileUtils'
|
|
10
|
-
export { default as MathUtils } from './MathUtils'
|
|
11
|
-
export { default as OptimizeUtils } from './OptimizeUtils'
|
|
12
|
-
export { default as StringUtils } from './StringUtils'
|
|
13
|
-
export { default as AssertUtils } from './AssertUtils'
|
|
14
|
-
export { default as Utils } from './CommUtils'
|