gis-common 3.1.10 → 3.1.11
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/core/EventDispatcher.d.ts +16 -0
- package/dist/core/HashMap.d.ts +7 -0
- package/dist/core/WebSocketClient.d.ts +14 -0
- package/dist/gis-common.es.js +1003 -825
- package/dist/gis-common.umd.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/utils/CommUtils.d.ts +109 -0
- package/dist/utils/DateUtils.d.ts +23 -0
- package/dist/utils/DomUtils.d.ts +90 -0
- package/dist/utils/FileUtils.d.ts +38 -0
- package/dist/utils/GeoUtils.d.ts +115 -0
- package/dist/utils/OptimizeUtils.d.ts +21 -0
- package/dist/utils/StringUtils.d.ts +86 -0
- package/package.json +13 -8
package/dist/gis-common.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
const
|
|
1
|
+
var z = Object.defineProperty;
|
|
2
|
+
var H = (e, t, n) => t in e ? z(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var f = (e, t, n) => H(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
const x = {
|
|
5
5
|
MAP_RENDER: "mapRender",
|
|
6
6
|
MAP_READY: "mapReady",
|
|
7
7
|
MOUSE_CLICK: "click",
|
|
@@ -23,7 +23,7 @@ const b = {
|
|
|
23
23
|
WEB_SOCKET_ERROR: "webSocketError",
|
|
24
24
|
WEB_SOCKET_MESSAGE: "webSocketMessage",
|
|
25
25
|
WEB_SOCKET_CLOSE: "webSocketClose"
|
|
26
|
-
},
|
|
26
|
+
}, p = {
|
|
27
27
|
LOGIN_EXPIRED: "登录信息过期,请重新登录",
|
|
28
28
|
CROSS_ERROR: "跨域访问",
|
|
29
29
|
UNEXIST_RESOURCE: "资源不存在",
|
|
@@ -44,7 +44,7 @@ const b = {
|
|
|
44
44
|
PARAMETER_ERROR_OBJECT: "格式类型验证失败:必须是对象",
|
|
45
45
|
PARAMETER_ERROR_LACK: "参数缺失",
|
|
46
46
|
STRING_CHECK_LOSS: "字符缺少关键字"
|
|
47
|
-
},
|
|
47
|
+
}, Q = {
|
|
48
48
|
SUPER_MAP_IMAGES: "SuperMapImages",
|
|
49
49
|
// 超图影像服务 栅格数据
|
|
50
50
|
SUPER_MAP_DATA: "SuperMapData",
|
|
@@ -58,7 +58,7 @@ const b = {
|
|
|
58
58
|
// addS3MGroupLayer(url, options, index) 添加S3M分组图层。
|
|
59
59
|
TERRAIN_LAYER: "TerrainFileLayer"
|
|
60
60
|
// 地形图层, 需要单独处理
|
|
61
|
-
},
|
|
61
|
+
}, X = {
|
|
62
62
|
POINT: "point",
|
|
63
63
|
POLYLINE: "polyline",
|
|
64
64
|
POLYGON: "polygon",
|
|
@@ -68,7 +68,15 @@ const b = {
|
|
|
68
68
|
LABEL: "label",
|
|
69
69
|
MODEL: "model",
|
|
70
70
|
WALL: "wall"
|
|
71
|
-
},
|
|
71
|
+
}, V = {
|
|
72
|
+
DISTANCE: "distance",
|
|
73
|
+
AREA: "area",
|
|
74
|
+
HEIGHT: "height"
|
|
75
|
+
}, Z = {
|
|
76
|
+
ADD: "add",
|
|
77
|
+
REMOVE: "remove",
|
|
78
|
+
INIT: "init"
|
|
79
|
+
}, tt = {
|
|
72
80
|
/**
|
|
73
81
|
* 多属性的动画函数
|
|
74
82
|
* @param {*} ele 需要运动的节点
|
|
@@ -76,215 +84,258 @@ const b = {
|
|
|
76
84
|
* @param {*} timefn 运动的形式,默认是缓冲运动
|
|
77
85
|
* @param {*} speed 运动的速度
|
|
78
86
|
*/
|
|
79
|
-
animate(
|
|
80
|
-
for (var
|
|
81
|
-
|
|
82
|
-
target:
|
|
87
|
+
animate(e, t, n, s = "swing", a = 5) {
|
|
88
|
+
for (var r in t)
|
|
89
|
+
t[r] = {
|
|
90
|
+
target: r === "opacity" ? parseInt(t[r] * 100) : t[r],
|
|
83
91
|
// 需要计算得到
|
|
84
|
-
iNow: parseInt(
|
|
92
|
+
iNow: parseInt(r === "opacity" ? getComputedStyle(e)[r] * 100 : getComputedStyle(e)[r])
|
|
85
93
|
};
|
|
86
|
-
|
|
87
|
-
for (var i in
|
|
88
|
-
var o =
|
|
89
|
-
if (
|
|
90
|
-
i === "opacity" ?
|
|
91
|
-
for (var l in
|
|
94
|
+
s === "liner" && (a = t[r].iNow < t[r].target ? Math.abs(a) : -Math.abs(a)), clearInterval(e.timer), e.timer = setInterval(function() {
|
|
95
|
+
for (var i in t) {
|
|
96
|
+
var o = t[i].target, c = t[i].iNow;
|
|
97
|
+
if (s === "swing" && (a = (o - c) / 20, a = a > 0 ? Math.ceil(a) : Math.floor(a)), Math.abs(o - c) <= Math.abs(a)) {
|
|
98
|
+
i === "opacity" ? e.style[i] = o / 100 : e.style[i] = o + "px", delete t[i];
|
|
99
|
+
for (var l in t)
|
|
92
100
|
return !1;
|
|
93
|
-
clearInterval(
|
|
101
|
+
clearInterval(e.timer), typeof n == "function" && n();
|
|
94
102
|
} else
|
|
95
|
-
|
|
103
|
+
t[i].iNow += a, i === "opacity" ? e.style[i] = t[i].iNow / 100 : e.style[i] = t[i].iNow + "px";
|
|
96
104
|
}
|
|
97
105
|
}, 30);
|
|
98
106
|
}
|
|
99
107
|
}, E = {
|
|
100
108
|
/**
|
|
101
|
-
*
|
|
109
|
+
* 获取数据类型
|
|
102
110
|
*
|
|
103
|
-
* @param
|
|
104
|
-
* @returns
|
|
111
|
+
* @param data 待判断的数据
|
|
112
|
+
* @returns 返回数据类型字符串
|
|
105
113
|
*/
|
|
106
|
-
getDataType(
|
|
107
|
-
return Object.prototype.toString.call(
|
|
114
|
+
getDataType(e) {
|
|
115
|
+
return Object.prototype.toString.call(e).slice(8, -1);
|
|
108
116
|
},
|
|
109
|
-
isEmpty(
|
|
110
|
-
if (
|
|
117
|
+
isEmpty(e) {
|
|
118
|
+
if (e == null)
|
|
111
119
|
return !0;
|
|
112
|
-
switch (this.getDataType(
|
|
120
|
+
switch (this.getDataType(e)) {
|
|
113
121
|
case "String":
|
|
114
|
-
return
|
|
122
|
+
return e.trim() === "";
|
|
115
123
|
case "Array":
|
|
116
|
-
return !
|
|
124
|
+
return !e.length;
|
|
117
125
|
case "Object":
|
|
118
|
-
return !Object.keys(
|
|
126
|
+
return !Object.keys(e).length;
|
|
119
127
|
case "Boolean":
|
|
120
|
-
return !
|
|
128
|
+
return !e;
|
|
121
129
|
default:
|
|
122
130
|
return !1;
|
|
123
131
|
}
|
|
124
132
|
},
|
|
125
|
-
isNotEmpty(
|
|
126
|
-
return !this.isEmpty(
|
|
133
|
+
isNotEmpty(e) {
|
|
134
|
+
return !this.isEmpty(e);
|
|
127
135
|
},
|
|
128
|
-
json2form(
|
|
129
|
-
const
|
|
130
|
-
return Object.keys(
|
|
131
|
-
|
|
132
|
-
}),
|
|
136
|
+
json2form(e) {
|
|
137
|
+
const t = new FormData();
|
|
138
|
+
return Object.keys(e).forEach((n) => {
|
|
139
|
+
t.append(n, e[n] instanceof Object ? JSON.stringify(e[n]) : e[n]);
|
|
140
|
+
}), t;
|
|
133
141
|
},
|
|
134
142
|
/**
|
|
135
|
-
* json
|
|
143
|
+
* 将json对象转换为查询字符串
|
|
136
144
|
*
|
|
137
|
-
* @param
|
|
138
|
-
* @returns
|
|
145
|
+
* @param json 待转换的json对象
|
|
146
|
+
* @returns 转换后的查询字符串
|
|
139
147
|
*/
|
|
140
|
-
json2Query(
|
|
141
|
-
var
|
|
142
|
-
for (var n in
|
|
143
|
-
var
|
|
144
|
-
|
|
148
|
+
json2Query(e) {
|
|
149
|
+
var t = [];
|
|
150
|
+
for (var n in e) {
|
|
151
|
+
var s = n, a = e[n];
|
|
152
|
+
t.push(s + "=" + a);
|
|
145
153
|
}
|
|
146
|
-
var
|
|
147
|
-
return
|
|
154
|
+
var r = t.join("&");
|
|
155
|
+
return r;
|
|
148
156
|
},
|
|
157
|
+
/**
|
|
158
|
+
* 生成GUID
|
|
159
|
+
*
|
|
160
|
+
* @returns 返回一个由8个16进制数组成的GUID字符串
|
|
161
|
+
*/
|
|
149
162
|
generateGuid() {
|
|
150
|
-
const
|
|
163
|
+
const e = function() {
|
|
151
164
|
return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
|
|
152
165
|
};
|
|
153
|
-
return
|
|
166
|
+
return e() + e() + e() + e() + e() + e() + e() + e();
|
|
154
167
|
},
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
168
|
+
/**
|
|
169
|
+
* 将参数进行解码并返回解码后的字符串
|
|
170
|
+
*
|
|
171
|
+
* @param args 参数
|
|
172
|
+
* @returns 解码后的字符串
|
|
173
|
+
*/
|
|
174
|
+
decodeDict(...e) {
|
|
175
|
+
let t = "";
|
|
176
|
+
if (e.length > 1) {
|
|
177
|
+
const n = e.slice(1, e.length % 2 === 0 ? e.length - 1 : e.length);
|
|
178
|
+
for (let s = 0; s < n.length; s = s + 2) {
|
|
179
|
+
const a = n[s];
|
|
180
|
+
e[0] === a && (t = n[s + 1]);
|
|
162
181
|
}
|
|
163
|
-
!
|
|
182
|
+
!t && e.length % 2 === 0 && (t = e[e.length - 1]);
|
|
164
183
|
} else
|
|
165
|
-
|
|
166
|
-
return
|
|
184
|
+
t = e[0];
|
|
185
|
+
return t;
|
|
167
186
|
},
|
|
168
187
|
/**
|
|
188
|
+
* 将一个或多个对象的所有可枚举属性复制到目标对象。
|
|
169
189
|
*
|
|
170
|
-
* @param
|
|
171
|
-
* @param
|
|
172
|
-
* @returns
|
|
190
|
+
* @param dest 目标对象,用于接收复制的属性。
|
|
191
|
+
* @param args 一个或多个源对象,用于提供要复制的属性。
|
|
192
|
+
* @returns 返回目标对象,包含所有复制的属性。
|
|
173
193
|
*/
|
|
174
|
-
extend(
|
|
175
|
-
let n,
|
|
176
|
-
for (
|
|
177
|
-
|
|
178
|
-
for (n in
|
|
179
|
-
|
|
194
|
+
extend(e, ...t) {
|
|
195
|
+
let n, s, a, r;
|
|
196
|
+
for (s = 0, a = t.length; s < a; s++) {
|
|
197
|
+
r = t[s];
|
|
198
|
+
for (n in r)
|
|
199
|
+
e[n] = r[n];
|
|
180
200
|
}
|
|
181
|
-
return t;
|
|
182
|
-
},
|
|
183
|
-
rgb2hex(t) {
|
|
184
|
-
var e = "#" + (16777216 + (t[0] << 16) + (t[1] << 8) + t[2]).toString(16).slice(1);
|
|
185
201
|
return e;
|
|
186
202
|
},
|
|
187
203
|
/**
|
|
188
|
-
*
|
|
204
|
+
* 将RGB颜色值转换为十六进制颜色值
|
|
189
205
|
*
|
|
190
|
-
* @param
|
|
191
|
-
* @
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
206
|
+
* @param rgb RGB颜色值数组,包含三个0-255之间的整数
|
|
207
|
+
* @returns 转换后的十六进制颜色值,以#开头
|
|
208
|
+
*/
|
|
209
|
+
rgb2hex(e) {
|
|
210
|
+
var t = "#" + (16777216 + (e[0] << 16) + (e[1] << 8) + e[2]).toString(16).slice(1);
|
|
211
|
+
return t;
|
|
212
|
+
},
|
|
213
|
+
/**
|
|
214
|
+
* 将扁平化数组转换为树形结构数组
|
|
215
|
+
*
|
|
216
|
+
* @param data 扁平化数组
|
|
217
|
+
* @param idPropertyName 数据中标识id的字段名,默认为'id'
|
|
218
|
+
* @param parentIdPropertyName 数据中标识父节点id的字段名,默认为'parentId'
|
|
219
|
+
* @param childrenPropertyName 树形结构中标识子节点的字段名,默认为'children'
|
|
220
|
+
* @returns 转换后的树形结构数组
|
|
195
221
|
*/
|
|
196
|
-
convertToTree2(
|
|
222
|
+
convertToTree2(e, t = "id", n = "parentId", s = "children") {
|
|
197
223
|
const a = [];
|
|
198
|
-
function
|
|
199
|
-
const o =
|
|
200
|
-
|
|
224
|
+
function r(i) {
|
|
225
|
+
const o = e.filter((c) => c[n] === i[t]).map((c) => (a.some((l) => l[t] === c[t]) || r(c), c));
|
|
226
|
+
o.length > 0 && (i[s] = o);
|
|
201
227
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
228
|
+
return e.forEach((i) => {
|
|
229
|
+
e.some((o) => o[n] === i[t]) || (r(i), a.push(i));
|
|
230
|
+
}), a;
|
|
205
231
|
},
|
|
206
232
|
/**
|
|
207
233
|
* 异步加载script
|
|
208
234
|
*
|
|
209
235
|
* @param {*} url
|
|
210
236
|
*/
|
|
211
|
-
asyncLoadScript(
|
|
212
|
-
return new Promise((
|
|
237
|
+
asyncLoadScript(e) {
|
|
238
|
+
return new Promise((t, n) => {
|
|
213
239
|
try {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
(
|
|
217
|
-
} :
|
|
218
|
-
|
|
219
|
-
},
|
|
220
|
-
|
|
221
|
-
|
|
240
|
+
const s = document.createElement("script");
|
|
241
|
+
s.type = "text/javascript", s.src = e, "readyState" in s ? s.onreadystatechange = function() {
|
|
242
|
+
(s.readyState === "complete" || s.readyState === "loaded") && t(s);
|
|
243
|
+
} : (s.onload = function() {
|
|
244
|
+
t(s);
|
|
245
|
+
}, s.onerror = function() {
|
|
246
|
+
n(new Error("Script failed to load for URL: " + e));
|
|
247
|
+
}), document.body.appendChild(s);
|
|
248
|
+
} catch (s) {
|
|
249
|
+
n(s);
|
|
222
250
|
}
|
|
223
251
|
});
|
|
224
252
|
},
|
|
225
|
-
|
|
226
|
-
|
|
253
|
+
/**
|
|
254
|
+
* 加载样式文件
|
|
255
|
+
*
|
|
256
|
+
* @param urls 样式文件URL数组
|
|
257
|
+
* @returns 无返回值
|
|
258
|
+
*/
|
|
259
|
+
loadStyle(e) {
|
|
260
|
+
e.forEach((t) => {
|
|
227
261
|
const n = document.createElement("link");
|
|
228
|
-
n.href =
|
|
262
|
+
n.href = t, n.rel = "stylesheet", n.type = "text/css", n.onerror = function() {
|
|
263
|
+
console.error(`Style loading failed for URL: ${t}`);
|
|
264
|
+
}, document.head.appendChild(n);
|
|
229
265
|
});
|
|
230
266
|
},
|
|
231
267
|
/**
|
|
232
|
-
*
|
|
233
|
-
* eg: template('aaa{key}', json)
|
|
268
|
+
* 将模板字符串中的占位符替换为给定对象中的值
|
|
234
269
|
*
|
|
235
|
-
* @param
|
|
236
|
-
* @param
|
|
237
|
-
* @returns
|
|
270
|
+
* @param str 模板字符串
|
|
271
|
+
* @param data 包含替换值的对象
|
|
272
|
+
* @returns 替换后的字符串
|
|
273
|
+
* @throws 当对象中没有找到与占位符对应的值时,抛出错误
|
|
238
274
|
*/
|
|
239
|
-
template(
|
|
275
|
+
template(e, t) {
|
|
240
276
|
const n = /\{ *([\w_-]+) *\}/g;
|
|
241
|
-
return
|
|
242
|
-
|
|
243
|
-
if (
|
|
244
|
-
throw new Error(
|
|
245
|
-
return typeof
|
|
277
|
+
return e.replace(n, (s, a) => {
|
|
278
|
+
const r = t[a];
|
|
279
|
+
if (r === void 0)
|
|
280
|
+
throw new Error(`${p.JSON_VALUE_ERROR}: ${s}`);
|
|
281
|
+
return typeof r == "function" ? r(t) : r;
|
|
246
282
|
});
|
|
247
283
|
},
|
|
248
|
-
|
|
284
|
+
/**
|
|
285
|
+
* 删除对象中所有值为空的属性
|
|
286
|
+
*
|
|
287
|
+
* @param data 待处理的对象
|
|
288
|
+
* @returns 返回处理后的对象
|
|
289
|
+
*/
|
|
290
|
+
deleteEmptyProperty(e) {
|
|
249
291
|
return Object.fromEntries(
|
|
250
|
-
Object.keys(
|
|
292
|
+
Object.keys(e).filter((t) => !this.isEmpty(e[t])).map((t) => [t, e[t]])
|
|
251
293
|
);
|
|
252
294
|
},
|
|
253
|
-
deepAssign() {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
for (let a in r)
|
|
260
|
-
a === "__proto__" || e === r[a] || (this.getDataType(r[a]) === "Object" ? e[a] = this.deepAssign(e[a], r[a]) : e[a] = r[a]);
|
|
261
|
-
}
|
|
295
|
+
deepAssign(e, ...t) {
|
|
296
|
+
(typeof e != "object" || e === null) && (e = {});
|
|
297
|
+
for (const n of t)
|
|
298
|
+
if (typeof n == "object" && n !== null)
|
|
299
|
+
for (const s in n)
|
|
300
|
+
Object.prototype.hasOwnProperty.call(n, s) && (typeof n[s] == "object" && n[s] !== null ? (e[s] || (e[s] = Array.isArray(n[s]) ? [] : {}), this.deepAssign(e[s], n[s])) : e[s] = n[s]);
|
|
262
301
|
return e;
|
|
263
302
|
},
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
303
|
+
/**
|
|
304
|
+
* 复制文本到剪贴板
|
|
305
|
+
*
|
|
306
|
+
* @param text 要复制的文本
|
|
307
|
+
* @returns 返回一个Promise,表示复制操作的结果
|
|
308
|
+
*/
|
|
309
|
+
handleCopyValue(e) {
|
|
310
|
+
if (navigator.clipboard && window.isSecureContext)
|
|
311
|
+
return navigator.clipboard.writeText(e);
|
|
267
312
|
{
|
|
268
|
-
const
|
|
269
|
-
return
|
|
270
|
-
|
|
313
|
+
const t = document.createElement("textarea");
|
|
314
|
+
return t.style.position = "fixed", t.style.top = t.style.left = "-100vh", t.style.opacity = "0", t.value = e, document.body.appendChild(t), t.focus(), t.select(), new Promise((n, s) => {
|
|
315
|
+
try {
|
|
316
|
+
document.execCommand("copy"), n();
|
|
317
|
+
} catch {
|
|
318
|
+
s(new Error("copy failed"));
|
|
319
|
+
} finally {
|
|
320
|
+
t.remove();
|
|
321
|
+
}
|
|
271
322
|
});
|
|
272
323
|
}
|
|
273
324
|
}
|
|
274
325
|
};
|
|
275
|
-
Array.prototype.groupBy = function(
|
|
276
|
-
var
|
|
326
|
+
Array.prototype.groupBy = function(e) {
|
|
327
|
+
var t = {};
|
|
277
328
|
return this.forEach(function(n) {
|
|
278
|
-
var
|
|
279
|
-
|
|
280
|
-
}), Object.keys(
|
|
329
|
+
var s = JSON.stringify(e(n));
|
|
330
|
+
t[s] = t[s] || [], t[s].push(n);
|
|
331
|
+
}), Object.keys(t).map((n) => t[n]);
|
|
281
332
|
};
|
|
282
|
-
Array.prototype.distinct = function(
|
|
283
|
-
const
|
|
284
|
-
return this.forEach((
|
|
285
|
-
const a =
|
|
286
|
-
!n[a] && (n[a] =
|
|
287
|
-
}),
|
|
333
|
+
Array.prototype.distinct = function(e = (t) => t) {
|
|
334
|
+
const t = [], n = {};
|
|
335
|
+
return this.forEach((s) => {
|
|
336
|
+
const a = e(s);
|
|
337
|
+
!n[a] && (n[a] = t.push(s));
|
|
338
|
+
}), t;
|
|
288
339
|
};
|
|
289
340
|
Array.prototype.max = function() {
|
|
290
341
|
return Math.max.apply({}, this);
|
|
@@ -293,85 +344,85 @@ Array.prototype.min = function() {
|
|
|
293
344
|
return Math.min.apply({}, this);
|
|
294
345
|
};
|
|
295
346
|
Array.prototype.sum = function() {
|
|
296
|
-
return this.length > 0 ? this.reduce((
|
|
347
|
+
return this.length > 0 ? this.reduce((e = 0, t = 0) => e + t) : 0;
|
|
297
348
|
};
|
|
298
349
|
Array.prototype.avg = function() {
|
|
299
350
|
return this.length ? this.sum() / this.length : 0;
|
|
300
351
|
};
|
|
301
|
-
Array.prototype.desc = function(
|
|
302
|
-
return this.sort((
|
|
352
|
+
Array.prototype.desc = function(e = (t) => t) {
|
|
353
|
+
return this.sort((t, n) => e(n) - e(t));
|
|
303
354
|
};
|
|
304
|
-
Array.prototype.asc = function(
|
|
305
|
-
return this.sort((
|
|
355
|
+
Array.prototype.asc = function(e = (t) => t) {
|
|
356
|
+
return this.sort((t, n) => e(t) - e(n));
|
|
306
357
|
};
|
|
307
358
|
Array.prototype.clear = function() {
|
|
308
359
|
return this.length = 0, this;
|
|
309
360
|
};
|
|
310
|
-
const
|
|
311
|
-
asArray(
|
|
312
|
-
return E.isEmpty(
|
|
313
|
-
},
|
|
314
|
-
generateArray(
|
|
315
|
-
return [...new Array(
|
|
316
|
-
},
|
|
317
|
-
union(...
|
|
318
|
-
let
|
|
319
|
-
return
|
|
320
|
-
Array.isArray(n) && (
|
|
321
|
-
}),
|
|
322
|
-
},
|
|
323
|
-
intersection(...
|
|
324
|
-
let
|
|
325
|
-
return
|
|
326
|
-
Array.isArray(n) && (
|
|
327
|
-
}),
|
|
328
|
-
},
|
|
329
|
-
unionAll(...
|
|
330
|
-
return [...
|
|
331
|
-
},
|
|
332
|
-
difference(...
|
|
333
|
-
return this.union(...
|
|
361
|
+
const et = {
|
|
362
|
+
asArray(e) {
|
|
363
|
+
return E.isEmpty(e) ? [] : Array.isArray(e) ? e : [e];
|
|
364
|
+
},
|
|
365
|
+
generateArray(e) {
|
|
366
|
+
return [...new Array(e).keys()];
|
|
367
|
+
},
|
|
368
|
+
union(...e) {
|
|
369
|
+
let t = [];
|
|
370
|
+
return e.forEach((n) => {
|
|
371
|
+
Array.isArray(n) && (t = t.concat(n.filter((s) => !t.includes(s))));
|
|
372
|
+
}), t;
|
|
373
|
+
},
|
|
374
|
+
intersection(...e) {
|
|
375
|
+
let t = e[0] || [];
|
|
376
|
+
return e.forEach((n) => {
|
|
377
|
+
Array.isArray(n) && (t = t.filter((s) => n.includes(s)));
|
|
378
|
+
}), t;
|
|
379
|
+
},
|
|
380
|
+
unionAll(...e) {
|
|
381
|
+
return [...e].flat().filter((t) => !!t);
|
|
382
|
+
},
|
|
383
|
+
difference(...e) {
|
|
384
|
+
return this.union(...e).filter((t) => !this.intersection(...e).includes(t));
|
|
334
385
|
}
|
|
335
|
-
},
|
|
336
|
-
getUrlParams(
|
|
337
|
-
const n = /([^&=]+)=([\w\W]*?)(&|$|#)/g, { search:
|
|
386
|
+
}, nt = {
|
|
387
|
+
getUrlParams(e = window.location.href, t = !0) {
|
|
388
|
+
const n = /([^&=]+)=([\w\W]*?)(&|$|#)/g, { search: s, hash: a } = new URL(e), r = [s, a];
|
|
338
389
|
let i = {};
|
|
339
|
-
for (let o = 0; o <
|
|
340
|
-
const c =
|
|
390
|
+
for (let o = 0; o < r.length; o++) {
|
|
391
|
+
const c = r[o];
|
|
341
392
|
if (c) {
|
|
342
393
|
const h = c.replace(/#|\//g, "").split("?");
|
|
343
394
|
if (h.length > 1)
|
|
344
395
|
for (let u = 1; u < h.length; u++) {
|
|
345
396
|
let d;
|
|
346
397
|
for (; d = n.exec(h[u]); )
|
|
347
|
-
i[d[1]] =
|
|
398
|
+
i[d[1]] = t ? decodeURIComponent(d[2]) : d[2];
|
|
348
399
|
}
|
|
349
400
|
}
|
|
350
401
|
}
|
|
351
402
|
return i;
|
|
352
403
|
},
|
|
353
404
|
getExplorer() {
|
|
354
|
-
var
|
|
355
|
-
if (
|
|
405
|
+
var e = window.navigator.userAgent;
|
|
406
|
+
if (e.indexOf("MSIE") >= 0 || window.ActiveXObject || "ActiveXObject" in window)
|
|
356
407
|
return "IE";
|
|
357
|
-
if (
|
|
408
|
+
if (e.indexOf("Firefox") >= 0)
|
|
358
409
|
return "Firefox";
|
|
359
|
-
if (
|
|
410
|
+
if (e.indexOf("Chrome") >= 0)
|
|
360
411
|
return "Chrome";
|
|
361
|
-
if (
|
|
412
|
+
if (e.indexOf("Opera") >= 0)
|
|
362
413
|
return "Opera";
|
|
363
|
-
if (
|
|
414
|
+
if (e.indexOf("Safari") >= 0)
|
|
364
415
|
return "Safari";
|
|
365
416
|
},
|
|
366
417
|
detectOS() {
|
|
367
|
-
let
|
|
368
|
-
const
|
|
369
|
-
return
|
|
418
|
+
let e = "";
|
|
419
|
+
const t = navigator.userAgent.indexOf("Windows", 0) != -1 ? 1 : 0, n = navigator.userAgent.indexOf("mac", 0) != -1 ? 1 : 0, s = navigator.userAgent.indexOf("Linux", 0) != -1 ? 1 : 0, a = navigator.userAgent.indexOf("X11", 0) != -1 ? 1 : 0;
|
|
420
|
+
return t ? e = "MS Windows" : n ? e = "Apple mac" : s ? e = "Linux" : a && (e = "Unix"), e;
|
|
370
421
|
},
|
|
371
|
-
switchFullScreen(
|
|
372
|
-
if (
|
|
373
|
-
const
|
|
374
|
-
|
|
422
|
+
switchFullScreen(e) {
|
|
423
|
+
if (e) {
|
|
424
|
+
const t = document.documentElement;
|
|
425
|
+
t.requestFullscreen ? t.requestFullscreen() : t.msRequestFullscreen ? t.msRequestFullscreen() : t.mozRequestFullScreen ? t.mozRequestFullScreen() : t.webkitRequestFullscreen && t.webkitRequestFullscreen();
|
|
375
426
|
} else
|
|
376
427
|
document.exitFullscreen ? document.exitFullscreen() : document.msExitFullscreen ? document.msExitFullscreen() : document.mozCancelFullScreen ? document.mozCancelFullScreen() : document.webkitExitFullscreen && document.webkitExitFullscreen();
|
|
377
428
|
},
|
|
@@ -379,124 +430,126 @@ const V = {
|
|
|
379
430
|
* scale屏幕适配方案
|
|
380
431
|
*/
|
|
381
432
|
refreshScale() {
|
|
382
|
-
const
|
|
383
|
-
let
|
|
384
|
-
|
|
433
|
+
const e = document.documentElement.clientWidth, t = document.documentElement.clientHeight, n = document.getElementById("app").style, s = e / t, a = 16 / 9;
|
|
434
|
+
let r = e / 1920;
|
|
435
|
+
s > a && (r = t / 1080), n.transformOrigin = "left top", n.transform = `scale(${r}) translateX(-49.99%)`, n.width = `${e / r}px`;
|
|
385
436
|
},
|
|
386
437
|
/**
|
|
387
438
|
* rem屏幕适配方案
|
|
388
439
|
*/
|
|
389
440
|
getHtmlFontSize() {
|
|
390
|
-
const
|
|
391
|
-
|
|
441
|
+
const e = document.documentElement.clientWidth || document.body.clientWidth, t = document.querySelector("html");
|
|
442
|
+
t.style.fontSize = e / 192 + "px";
|
|
392
443
|
}
|
|
393
|
-
},
|
|
394
|
-
set: function(
|
|
395
|
-
var
|
|
396
|
-
|
|
397
|
-
},
|
|
398
|
-
remove: function(
|
|
399
|
-
var
|
|
400
|
-
|
|
401
|
-
var n = this.get(
|
|
402
|
-
n != null && (document.cookie =
|
|
403
|
-
},
|
|
404
|
-
get: function(
|
|
405
|
-
var
|
|
406
|
-
return
|
|
444
|
+
}, st = {
|
|
445
|
+
set: function(e, t, n = 30) {
|
|
446
|
+
var s = /* @__PURE__ */ new Date();
|
|
447
|
+
s.setTime(s.getTime() + n * 24 * 60 * 60 * 1e3), document.cookie = e + "=" + escape(t) + ";expires=" + s.toUTCString();
|
|
448
|
+
},
|
|
449
|
+
remove: function(e) {
|
|
450
|
+
var t = /* @__PURE__ */ new Date();
|
|
451
|
+
t.setTime(t.getTime() - 1);
|
|
452
|
+
var n = this.get(e);
|
|
453
|
+
n != null && (document.cookie = e + "=" + n + ";expires=" + t.toUTCString());
|
|
454
|
+
},
|
|
455
|
+
get: function(e) {
|
|
456
|
+
var t = document.cookie.match(new RegExp("(^| )" + e + "=([^;]*)(;|$)"));
|
|
457
|
+
return t != null ? t[2] : "";
|
|
407
458
|
}
|
|
408
|
-
},
|
|
459
|
+
}, rt = {
|
|
409
460
|
PI: 3.141592653589793,
|
|
410
461
|
XPI: 3.141592653589793 * 3e3 / 180,
|
|
411
|
-
delta(
|
|
412
|
-
const
|
|
413
|
-
let a = this.transformLat(
|
|
414
|
-
const i =
|
|
462
|
+
delta(e, t) {
|
|
463
|
+
const s = 0.006693421622965943;
|
|
464
|
+
let a = this.transformLat(t - 105, e - 35), r = this.transformLon(t - 105, e - 35);
|
|
465
|
+
const i = e / 180 * this.PI;
|
|
415
466
|
let o = Math.sin(i);
|
|
416
|
-
o = 1 -
|
|
467
|
+
o = 1 - s * o * o;
|
|
417
468
|
const c = Math.sqrt(o);
|
|
418
|
-
return a = a * 180 / (6378245 * (1 -
|
|
469
|
+
return a = a * 180 / (6378245 * (1 - s) / (o * c) * this.PI), r = r * 180 / (6378245 / c * Math.cos(i) * this.PI), { lat: a, lng: r };
|
|
419
470
|
},
|
|
420
471
|
// WGS-84 to GCJ-02
|
|
421
|
-
gcjEncrypt(
|
|
422
|
-
if (this.outOfChina(
|
|
423
|
-
return { lat:
|
|
424
|
-
const n = this.delta(
|
|
425
|
-
return { lat:
|
|
472
|
+
gcjEncrypt(e, t) {
|
|
473
|
+
if (this.outOfChina(e, t))
|
|
474
|
+
return { lat: e, lng: t };
|
|
475
|
+
const n = this.delta(e, t);
|
|
476
|
+
return { lat: e + n.lat, lng: t + n.lng };
|
|
426
477
|
},
|
|
427
478
|
// GCJ-02 to WGS-84
|
|
428
|
-
gcjDecrypt(
|
|
429
|
-
if (this.outOfChina(
|
|
430
|
-
return { lat:
|
|
431
|
-
const n = this.delta(
|
|
432
|
-
return { lat:
|
|
479
|
+
gcjDecrypt(e, t) {
|
|
480
|
+
if (this.outOfChina(e, t))
|
|
481
|
+
return { lat: e, lng: t };
|
|
482
|
+
const n = this.delta(e, t);
|
|
483
|
+
return { lat: e - n.lat, lng: t - n.lng };
|
|
433
484
|
},
|
|
434
485
|
// GCJ-02 to WGS-84 exactly
|
|
435
|
-
gcjDecryptExact(
|
|
436
|
-
let a = 0.01,
|
|
486
|
+
gcjDecryptExact(e, t) {
|
|
487
|
+
let a = 0.01, r = 0.01, i = e - a, o = t - r, c = e + a, l = t + r, h = 0, u = 0, d = 0;
|
|
437
488
|
for (; ; ) {
|
|
438
489
|
h = (i + c) / 2, u = (o + l) / 2;
|
|
439
|
-
const
|
|
440
|
-
if (a =
|
|
490
|
+
const R = this.gcjEncrypt(h, u);
|
|
491
|
+
if (a = R.lat - e, r = R.lng - t, Math.abs(a) < 1e-9 && Math.abs(r) < 1e-9 || (a > 0 ? c = h : i = h, r > 0 ? l = u : o = u, ++d > 1e4)) break;
|
|
441
492
|
}
|
|
442
493
|
return { lat: h, lng: u };
|
|
443
494
|
},
|
|
444
495
|
// GCJ-02 to BD-09
|
|
445
|
-
bdEncrypt(
|
|
446
|
-
const n =
|
|
447
|
-
return { lat: a * Math.sin(
|
|
496
|
+
bdEncrypt(e, t) {
|
|
497
|
+
const n = t, s = e, a = Math.sqrt(n * n + s * s) + 2e-5 * Math.sin(s * this.XPI), r = Math.atan2(s, n) + 3e-6 * Math.cos(n * this.XPI), i = a * Math.cos(r) + 65e-4;
|
|
498
|
+
return { lat: a * Math.sin(r) + 6e-3, lng: i };
|
|
448
499
|
},
|
|
449
500
|
// BD-09 to GCJ-02
|
|
450
|
-
bdDecrypt(
|
|
451
|
-
const n =
|
|
452
|
-
return { lat: a * Math.sin(
|
|
501
|
+
bdDecrypt(e, t) {
|
|
502
|
+
const n = t - 65e-4, s = e - 6e-3, a = Math.sqrt(n * n + s * s) - 2e-5 * Math.sin(s * this.XPI), r = Math.atan2(s, n) - 3e-6 * Math.cos(n * this.XPI), i = a * Math.cos(r);
|
|
503
|
+
return { lat: a * Math.sin(r), lng: i };
|
|
453
504
|
},
|
|
454
505
|
// WGS-84 to Web mercator
|
|
455
506
|
// mercatorLat -> y mercatorLon -> x
|
|
456
|
-
mercatorEncrypt(
|
|
457
|
-
const n =
|
|
458
|
-
let
|
|
459
|
-
return
|
|
507
|
+
mercatorEncrypt(e, t) {
|
|
508
|
+
const n = t * 2003750834e-2 / 180;
|
|
509
|
+
let s = Math.log(Math.tan((90 + e) * this.PI / 360)) / (this.PI / 180);
|
|
510
|
+
return s = s * 2003750834e-2 / 180, { lat: s, lng: n };
|
|
460
511
|
},
|
|
461
512
|
// Web mercator to WGS-84
|
|
462
513
|
// mercatorLat -> y mercatorLon -> x
|
|
463
|
-
mercatorDecrypt(
|
|
464
|
-
const n =
|
|
465
|
-
let
|
|
466
|
-
return
|
|
514
|
+
mercatorDecrypt(e, t) {
|
|
515
|
+
const n = t / 2003750834e-2 * 180;
|
|
516
|
+
let s = e / 2003750834e-2 * 180;
|
|
517
|
+
return s = 180 / this.PI * (2 * Math.atan(Math.exp(s * this.PI / 180)) - this.PI / 2), { lat: s, lng: n };
|
|
467
518
|
},
|
|
468
519
|
// two point's distance
|
|
469
|
-
distance(
|
|
470
|
-
const
|
|
471
|
-
let o =
|
|
520
|
+
distance(e, t, n, s) {
|
|
521
|
+
const r = Math.cos(e * this.PI / 180) * Math.cos(n * this.PI / 180) * Math.cos((t - s) * this.PI / 180), i = Math.sin(e * this.PI / 180) * Math.sin(n * this.PI / 180);
|
|
522
|
+
let o = r + i;
|
|
472
523
|
return o > 1 && (o = 1), o < -1 && (o = -1), Math.acos(o) * 6371e3;
|
|
473
524
|
},
|
|
474
|
-
outOfChina(
|
|
475
|
-
return
|
|
525
|
+
outOfChina(e, t) {
|
|
526
|
+
return t < 72.004 || t > 137.8347 || e < 0.8293 || e > 55.8271;
|
|
476
527
|
},
|
|
477
|
-
transformLat(
|
|
478
|
-
let n = -100 + 2 *
|
|
479
|
-
return n += (20 * Math.sin(6 *
|
|
528
|
+
transformLat(e, t) {
|
|
529
|
+
let n = -100 + 2 * e + 3 * t + 0.2 * t * t + 0.1 * e * t + 0.2 * Math.sqrt(Math.abs(e));
|
|
530
|
+
return n += (20 * Math.sin(6 * e * this.PI) + 20 * Math.sin(2 * e * this.PI)) * 2 / 3, n += (20 * Math.sin(t * this.PI) + 40 * Math.sin(t / 3 * this.PI)) * 2 / 3, n += (160 * Math.sin(t / 12 * this.PI) + 320 * Math.sin(t * this.PI / 30)) * 2 / 3, n;
|
|
480
531
|
},
|
|
481
|
-
transformLon(
|
|
482
|
-
let n = 300 +
|
|
483
|
-
return n += (20 * Math.sin(6 *
|
|
532
|
+
transformLon(e, t) {
|
|
533
|
+
let n = 300 + e + 2 * t + 0.1 * e * e + 0.1 * e * t + 0.1 * Math.sqrt(Math.abs(e));
|
|
534
|
+
return n += (20 * Math.sin(6 * e * this.PI) + 20 * Math.sin(2 * e * this.PI)) * 2 / 3, n += (20 * Math.sin(e * this.PI) + 40 * Math.sin(e / 3 * this.PI)) * 2 / 3, n += (150 * Math.sin(e / 12 * this.PI) + 300 * Math.sin(e / 30 * this.PI)) * 2 / 3, n;
|
|
484
535
|
},
|
|
485
|
-
randomCoordinate(
|
|
536
|
+
randomCoordinate(e, t, n, s) {
|
|
486
537
|
return {
|
|
487
|
-
lat: Math.random() * (
|
|
488
|
-
lng: Math.random() * (n -
|
|
538
|
+
lat: Math.random() * (s - t) + t,
|
|
539
|
+
lng: Math.random() * (n - e) + e
|
|
489
540
|
};
|
|
490
541
|
}
|
|
491
542
|
};
|
|
492
|
-
Date.prototype.format = function(
|
|
493
|
-
const
|
|
543
|
+
Date.prototype.format = function(e) {
|
|
544
|
+
const t = {
|
|
494
545
|
"M+": this.getMonth() + 1,
|
|
495
546
|
// 月份
|
|
496
547
|
"d+": this.getDate(),
|
|
497
548
|
// 日
|
|
498
|
-
"h+": this.getHours(),
|
|
549
|
+
"h+": this.getHours() % 12,
|
|
499
550
|
// 小时
|
|
551
|
+
"H+": this.getHours(),
|
|
552
|
+
// 小时 (24小时制)
|
|
500
553
|
"m+": this.getMinutes(),
|
|
501
554
|
// 分
|
|
502
555
|
"s+": this.getSeconds(),
|
|
@@ -506,45 +559,48 @@ Date.prototype.format = function(t) {
|
|
|
506
559
|
S: this.getMilliseconds()
|
|
507
560
|
// 毫秒
|
|
508
561
|
};
|
|
509
|
-
/(y+)/.test(
|
|
510
|
-
for (const n in
|
|
511
|
-
new RegExp("(" + n + ")").test(
|
|
512
|
-
|
|
562
|
+
/(y+)/.test(e) && (e = e.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)));
|
|
563
|
+
for (const n in t)
|
|
564
|
+
if (new RegExp("(" + n + ")").test(e)) {
|
|
565
|
+
const s = n.length === 1 ? 1 : Number(n.slice(1));
|
|
566
|
+
e = e.replace(RegExp.$1, ("00" + t[n]).substr(("" + t[n]).length + s - (t[n] + "").length));
|
|
567
|
+
}
|
|
568
|
+
return e;
|
|
513
569
|
};
|
|
514
|
-
Date.prototype.addDate = function(
|
|
570
|
+
Date.prototype.addDate = function(e, t) {
|
|
515
571
|
const n = new Date(this);
|
|
516
|
-
switch (
|
|
572
|
+
switch (e) {
|
|
517
573
|
case "y":
|
|
518
|
-
n.setFullYear(this.getFullYear() +
|
|
574
|
+
n.setFullYear(this.getFullYear() + t);
|
|
519
575
|
break;
|
|
520
576
|
case "q":
|
|
521
|
-
n.setMonth(this.getMonth() +
|
|
577
|
+
n.setMonth(this.getMonth() + t * 3);
|
|
522
578
|
break;
|
|
523
579
|
case "M":
|
|
524
|
-
n.setMonth(this.getMonth() +
|
|
580
|
+
n.setMonth(this.getMonth() + t);
|
|
525
581
|
break;
|
|
526
582
|
case "w":
|
|
527
|
-
n.setDate(this.getDate() +
|
|
583
|
+
n.setDate(this.getDate() + t * 7);
|
|
528
584
|
break;
|
|
529
585
|
case "d":
|
|
530
|
-
n.setDate(this.getDate() +
|
|
586
|
+
n.setDate(this.getDate() + t);
|
|
531
587
|
break;
|
|
532
588
|
case "h":
|
|
533
|
-
n.setHours(this.getHours() +
|
|
589
|
+
n.setHours(this.getHours() + t);
|
|
534
590
|
break;
|
|
535
591
|
case "m":
|
|
536
|
-
n.setMinutes(this.getMinutes() +
|
|
592
|
+
n.setMinutes(this.getMinutes() + t);
|
|
537
593
|
break;
|
|
538
594
|
case "s":
|
|
539
|
-
n.setSeconds(this.getSeconds() +
|
|
595
|
+
n.setSeconds(this.getSeconds() + t);
|
|
540
596
|
break;
|
|
541
597
|
default:
|
|
542
|
-
n.setDate(this.getDate() +
|
|
598
|
+
n.setDate(this.getDate() + t);
|
|
543
599
|
break;
|
|
544
600
|
}
|
|
545
601
|
return n;
|
|
546
602
|
};
|
|
547
|
-
const
|
|
603
|
+
const at = {
|
|
548
604
|
lastMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth() - 1, 1),
|
|
549
605
|
thisMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), 1),
|
|
550
606
|
nextMonthDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth() + 1, 1),
|
|
@@ -554,28 +610,28 @@ const tt = {
|
|
|
554
610
|
lastDayDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate() - 1),
|
|
555
611
|
thisDayDate: new Date((/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0)),
|
|
556
612
|
nextDayDate: new Date((/* @__PURE__ */ new Date()).getFullYear(), (/* @__PURE__ */ new Date()).getMonth(), (/* @__PURE__ */ new Date()).getDate() + 1),
|
|
557
|
-
parseDate(
|
|
558
|
-
if (typeof
|
|
559
|
-
var
|
|
560
|
-
if (
|
|
561
|
-
if (
|
|
613
|
+
parseDate(e) {
|
|
614
|
+
if (typeof e == "string") {
|
|
615
|
+
var t = e.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) *$/);
|
|
616
|
+
if (t && t.length > 3) return new Date(parseInt(t[1]), parseInt(t[2]) - 1, parseInt(t[3]));
|
|
617
|
+
if (t = e.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2}) *$/), t && t.length > 6)
|
|
562
618
|
return new Date(
|
|
563
|
-
parseInt(
|
|
564
|
-
parseInt(
|
|
565
|
-
parseInt(
|
|
566
|
-
parseInt(
|
|
567
|
-
parseInt(
|
|
568
|
-
parseInt(
|
|
619
|
+
parseInt(t[1]),
|
|
620
|
+
parseInt(t[2]) - 1,
|
|
621
|
+
parseInt(t[3]),
|
|
622
|
+
parseInt(t[4]),
|
|
623
|
+
parseInt(t[5]),
|
|
624
|
+
parseInt(t[6])
|
|
569
625
|
);
|
|
570
|
-
if (
|
|
626
|
+
if (t = e.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2})\.(\d{1,9}) *$/), t && t.length > 7)
|
|
571
627
|
return new Date(
|
|
572
|
-
parseInt(
|
|
573
|
-
parseInt(
|
|
574
|
-
parseInt(
|
|
575
|
-
parseInt(
|
|
576
|
-
parseInt(
|
|
577
|
-
parseInt(
|
|
578
|
-
parseInt(
|
|
628
|
+
parseInt(t[1]),
|
|
629
|
+
parseInt(t[2]) - 1,
|
|
630
|
+
parseInt(t[3]),
|
|
631
|
+
parseInt(t[4]),
|
|
632
|
+
parseInt(t[5]),
|
|
633
|
+
parseInt(t[6]),
|
|
634
|
+
parseInt(t[7])
|
|
579
635
|
);
|
|
580
636
|
}
|
|
581
637
|
return null;
|
|
@@ -587,91 +643,168 @@ const tt = {
|
|
|
587
643
|
* @param {*} endTime
|
|
588
644
|
* @returns {*}
|
|
589
645
|
*/
|
|
590
|
-
formatDateInterval(
|
|
591
|
-
const n = new Date(
|
|
646
|
+
formatDateInterval(e, t) {
|
|
647
|
+
const n = new Date(e), a = new Date(t).getTime() - n.getTime(), r = Math.floor(a / (24 * 3600 * 1e3)), i = a % (24 * 3600 * 1e3), o = Math.floor(i / (3600 * 1e3)), c = i % (3600 * 1e3), l = Math.floor(c / (60 * 1e3)), h = c % (60 * 1e3), u = Math.round(h / 1e3);
|
|
592
648
|
let d = "";
|
|
593
|
-
return
|
|
649
|
+
return r > 0 && (d += r + "天"), o > 0 && (d += o + "时"), l > 0 && (d += l + "分"), u > 0 && (d += u + "秒"), r === 0 && o === 0 && l === 0 && u === 0 && (d = "少于1秒"), d;
|
|
594
650
|
},
|
|
595
|
-
formatterCounter(
|
|
596
|
-
const
|
|
651
|
+
formatterCounter(e) {
|
|
652
|
+
const t = function(o) {
|
|
597
653
|
return (o > 10 ? "" : "0") + (o || 0);
|
|
598
|
-
}, n =
|
|
654
|
+
}, n = t(Math.floor(e / 3600)), s = e % 3600, a = t(Math.floor(s / 60)), r = s % 60, i = t(Math.round(r));
|
|
599
655
|
return `${n}:${a}:${i}`;
|
|
600
656
|
},
|
|
601
|
-
sleep(
|
|
657
|
+
sleep(e) {
|
|
602
658
|
}
|
|
603
659
|
};
|
|
604
|
-
function
|
|
605
|
-
return
|
|
660
|
+
function j(e) {
|
|
661
|
+
return e.trim ? e.trim() : e.replace(/^\s+|\s+$/g, "");
|
|
606
662
|
}
|
|
607
|
-
function
|
|
608
|
-
return
|
|
663
|
+
function U(e) {
|
|
664
|
+
return j(e).split(/\s+/);
|
|
609
665
|
}
|
|
610
|
-
const
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
666
|
+
const it = {
|
|
667
|
+
/**
|
|
668
|
+
* 获取元素的样式值
|
|
669
|
+
*
|
|
670
|
+
* @param el 元素对象
|
|
671
|
+
* @param style 样式属性名称
|
|
672
|
+
* @returns 元素的样式值,如果获取不到则返回 null
|
|
673
|
+
*/
|
|
674
|
+
getStyle(e, t) {
|
|
675
|
+
var s;
|
|
676
|
+
let n = e.style[t];
|
|
677
|
+
if (!n || n === "auto") {
|
|
678
|
+
const a = (s = document.defaultView) == null ? void 0 : s.getComputedStyle(e, null);
|
|
679
|
+
n = a ? a[t] : null, n === "auto" && (n = null);
|
|
616
680
|
}
|
|
617
|
-
return n
|
|
681
|
+
return n;
|
|
618
682
|
},
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
683
|
+
/**
|
|
684
|
+
* 创建一个HTML元素
|
|
685
|
+
*
|
|
686
|
+
* @param tagName 元素标签名
|
|
687
|
+
* @param className 元素类名
|
|
688
|
+
* @param container 父容器,若传入,则新创建的元素会被添加到该容器中
|
|
689
|
+
* @returns 返回新创建的HTML元素
|
|
690
|
+
*/
|
|
691
|
+
create(e, t, n) {
|
|
692
|
+
const s = document.createElement(e);
|
|
693
|
+
return s.className = t || "", n && n.appendChild(s), s;
|
|
622
694
|
},
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
695
|
+
/**
|
|
696
|
+
* 从父节点中移除指定元素。
|
|
697
|
+
*
|
|
698
|
+
* @param el 要移除的元素对象,必须包含parentNode属性。
|
|
699
|
+
*/
|
|
700
|
+
remove(e) {
|
|
701
|
+
const t = e.parentNode;
|
|
702
|
+
t && t.removeChild(e);
|
|
703
|
+
},
|
|
704
|
+
/**
|
|
705
|
+
* 清空给定元素的子节点
|
|
706
|
+
*
|
|
707
|
+
* @param el 要清空子节点的元素,包含firstChild和removeChild属性
|
|
708
|
+
*/
|
|
709
|
+
empty(e) {
|
|
710
|
+
for (; e.firstChild; )
|
|
711
|
+
e.removeChild(e.firstChild);
|
|
712
|
+
},
|
|
713
|
+
/**
|
|
714
|
+
* 将元素移到父节点的最前面
|
|
715
|
+
*
|
|
716
|
+
* @param el 要移动的元素,需要包含 parentNode 属性
|
|
717
|
+
*/
|
|
718
|
+
toFront(e) {
|
|
719
|
+
const t = e.parentNode;
|
|
720
|
+
t && t.lastChild !== e && t.appendChild(e);
|
|
721
|
+
},
|
|
722
|
+
/**
|
|
723
|
+
* 将元素移动到其父节点的最前面
|
|
724
|
+
*
|
|
725
|
+
* @param el 要移动的元素,需要包含parentNode属性
|
|
726
|
+
*/
|
|
727
|
+
toBack(e) {
|
|
728
|
+
const t = e.parentNode;
|
|
729
|
+
t && t.firstChild !== e && t.insertBefore(e, t.firstChild);
|
|
730
|
+
},
|
|
731
|
+
/**
|
|
732
|
+
* 获取元素的类名
|
|
733
|
+
*
|
|
734
|
+
* @param el 包含对应元素和类名的对象
|
|
735
|
+
* @param el.correspondingElement 对应的元素
|
|
736
|
+
* @param el.className 类名对象
|
|
737
|
+
* @param el.className.baseVal 类名字符串
|
|
738
|
+
* @returns 返回元素的类名字符串
|
|
739
|
+
*/
|
|
740
|
+
getClass(e) {
|
|
741
|
+
return ((e == null ? void 0 : e.host) || e).className.toString();
|
|
742
|
+
},
|
|
743
|
+
/**
|
|
744
|
+
* 判断元素是否包含指定类名
|
|
745
|
+
*
|
|
746
|
+
* @param el 元素对象,包含classList属性,classList属性包含contains方法
|
|
747
|
+
* @param name 要判断的类名
|
|
748
|
+
* @returns 返回一个布尔值,表示元素是否包含指定类名
|
|
749
|
+
*/
|
|
750
|
+
hasClass(e, t) {
|
|
751
|
+
var s;
|
|
752
|
+
if ((s = e.classList) != null && s.contains(t))
|
|
753
|
+
return !0;
|
|
754
|
+
const n = this.getClass(e);
|
|
755
|
+
return n.length > 0 && new RegExp(`(^|\\s)${t}(\\s|$)`).test(n);
|
|
756
|
+
},
|
|
757
|
+
/**
|
|
758
|
+
* 给指定的 HTML 元素添加类名
|
|
759
|
+
*
|
|
760
|
+
* @param el 要添加类名的 HTML 元素
|
|
761
|
+
* @param name 要添加的类名,多个类名之间用空格分隔
|
|
762
|
+
*/
|
|
763
|
+
addClass(e, t) {
|
|
764
|
+
if (e.classList !== void 0) {
|
|
765
|
+
const n = U(t);
|
|
766
|
+
for (let s = 0, a = n.length; s < a; s++)
|
|
767
|
+
e.classList.add(n[s]);
|
|
768
|
+
} else if (!this.hasClass(e, t)) {
|
|
769
|
+
const n = this.getClass(e);
|
|
770
|
+
this.setClass(e, (n ? n + " " : "") + t);
|
|
656
771
|
}
|
|
657
772
|
},
|
|
658
|
-
|
|
659
|
-
|
|
773
|
+
/**
|
|
774
|
+
* 从元素中移除指定类名
|
|
775
|
+
*
|
|
776
|
+
* @param el 要移除类名的元素
|
|
777
|
+
* @param name 要移除的类名,多个类名用空格分隔
|
|
778
|
+
*/
|
|
779
|
+
removeClass(e, t) {
|
|
780
|
+
e.classList !== void 0 ? U(t).forEach((s) => e.classList.remove(s)) : this.setClass(e, (" " + this.getClass(e) + " ").replace(" " + t + " ", " ").trim());
|
|
660
781
|
},
|
|
661
|
-
|
|
662
|
-
|
|
782
|
+
/**
|
|
783
|
+
* 设置元素的 CSS 类名
|
|
784
|
+
*
|
|
785
|
+
* @param el HTML 或 SVG 元素
|
|
786
|
+
* @param name 要设置的类名,多个类名之间用空格分隔
|
|
787
|
+
*/
|
|
788
|
+
setClass(e, t) {
|
|
789
|
+
"classList" in e && (e.classList.value = "", t.split(" ").forEach((n) => e.classList.add(n)));
|
|
663
790
|
},
|
|
664
|
-
|
|
665
|
-
|
|
791
|
+
/**
|
|
792
|
+
* 从字符串中解析XML文档,并返回根节点
|
|
793
|
+
*
|
|
794
|
+
* @param str 要解析的XML字符串
|
|
795
|
+
* @returns 解析后的XML文档的根节点
|
|
796
|
+
*/
|
|
797
|
+
parseFromString(e) {
|
|
798
|
+
return new DOMParser().parseFromString(e, "text/xml").children[0];
|
|
666
799
|
}
|
|
667
800
|
}, g = {
|
|
668
801
|
DEG2RAD: Math.PI / 180,
|
|
669
802
|
RAD2DEG: 180 / Math.PI,
|
|
670
|
-
randInt(
|
|
671
|
-
return
|
|
803
|
+
randInt(e, t) {
|
|
804
|
+
return e + Math.floor(Math.random() * (t - e + 1));
|
|
672
805
|
},
|
|
673
|
-
randFloat(
|
|
674
|
-
return
|
|
806
|
+
randFloat(e, t) {
|
|
807
|
+
return e + Math.random() * (t - e);
|
|
675
808
|
},
|
|
676
809
|
/**
|
|
677
810
|
* 角度转弧度
|
|
@@ -679,8 +812,8 @@ const et = {
|
|
|
679
812
|
* @param {*} degrees
|
|
680
813
|
* @returns {*}
|
|
681
814
|
*/
|
|
682
|
-
degreesToRadians(
|
|
683
|
-
return
|
|
815
|
+
degreesToRadians(e) {
|
|
816
|
+
return e * this.DEG2RAD;
|
|
684
817
|
},
|
|
685
818
|
/**
|
|
686
819
|
* 角度转弧度
|
|
@@ -688,8 +821,8 @@ const et = {
|
|
|
688
821
|
* @param {*} degrees
|
|
689
822
|
* @returns {*}
|
|
690
823
|
*/
|
|
691
|
-
toRadians(
|
|
692
|
-
return
|
|
824
|
+
toRadians(e) {
|
|
825
|
+
return e * this.DEG2RAD;
|
|
693
826
|
},
|
|
694
827
|
/**
|
|
695
828
|
* 弧度转角度
|
|
@@ -697,8 +830,8 @@ const et = {
|
|
|
697
830
|
* @param {*} radians
|
|
698
831
|
* @returns {*}
|
|
699
832
|
*/
|
|
700
|
-
radiansToDegrees(
|
|
701
|
-
return
|
|
833
|
+
radiansToDegrees(e) {
|
|
834
|
+
return e * this.RAD2DEG;
|
|
702
835
|
},
|
|
703
836
|
/**
|
|
704
837
|
* 弧度转角度
|
|
@@ -706,74 +839,76 @@ const et = {
|
|
|
706
839
|
* @param {*} radians
|
|
707
840
|
* @returns {*}
|
|
708
841
|
*/
|
|
709
|
-
toDegrees(
|
|
710
|
-
return
|
|
842
|
+
toDegrees(e) {
|
|
843
|
+
return e * this.RAD2DEG;
|
|
711
844
|
},
|
|
712
|
-
formatFloat(
|
|
713
|
-
return Math.round(
|
|
845
|
+
formatFloat(e, t = 2) {
|
|
846
|
+
return Math.round(e * Math.pow(10, t)) / Math.pow(10, t);
|
|
714
847
|
}
|
|
715
|
-
},
|
|
848
|
+
}, q = {
|
|
716
849
|
toRadian: Math.PI / 180,
|
|
717
850
|
R: 6371393,
|
|
718
851
|
/**
|
|
719
|
-
*
|
|
852
|
+
* 判断给定的经纬度是否合法
|
|
720
853
|
*
|
|
721
|
-
* @param
|
|
722
|
-
* @param
|
|
723
|
-
* @returns
|
|
854
|
+
* @param lng 经度值
|
|
855
|
+
* @param lat 纬度值
|
|
856
|
+
* @returns 如果经纬度合法,返回true;否则返回false
|
|
724
857
|
*/
|
|
725
|
-
isLnglat(
|
|
726
|
-
return !isNaN(
|
|
858
|
+
isLnglat(e, t) {
|
|
859
|
+
return !isNaN(e) && !isNaN(t) && +t > -90 && +t < 90 && +e > -180 && +e < 180;
|
|
727
860
|
},
|
|
728
861
|
/**
|
|
729
|
-
*
|
|
862
|
+
* 格式化经纬度为度分秒格式
|
|
730
863
|
*
|
|
731
|
-
* @param
|
|
732
|
-
* @param
|
|
733
|
-
* @returns
|
|
864
|
+
* @param lng 经度
|
|
865
|
+
* @param lat 纬度
|
|
866
|
+
* @returns 返回格式化后的经纬度字符串,格式为:经度度分秒,纬度度分秒
|
|
734
867
|
*/
|
|
735
|
-
formatLnglat(
|
|
868
|
+
formatLnglat(e, t) {
|
|
736
869
|
let n = "";
|
|
737
|
-
function
|
|
738
|
-
const
|
|
739
|
-
|
|
740
|
-
return i + "°" + o + "′" + c.toFixed(2) + "″";
|
|
870
|
+
function s(a) {
|
|
871
|
+
const r = Math.floor(a), i = Math.floor((a - r) * 60), o = (a - r) * 3600 - i * 60;
|
|
872
|
+
return `${r}°${i}′${o.toFixed(2)}″`;
|
|
741
873
|
}
|
|
742
|
-
return t
|
|
874
|
+
return this.isLnglat(e, t) ? n = s(e) + "," + s(t) : isNaN(e) ? isNaN(t) || (n = s(t)) : n = s(e), n;
|
|
743
875
|
},
|
|
744
876
|
/**
|
|
745
|
-
*
|
|
877
|
+
* 将经纬度字符串转换为度
|
|
746
878
|
*
|
|
747
|
-
* @param
|
|
748
|
-
* @param
|
|
749
|
-
* @returns
|
|
879
|
+
* @param lng 经度字符串
|
|
880
|
+
* @param lat 纬度字符串
|
|
881
|
+
* @returns 转换后的经纬度对象
|
|
750
882
|
*/
|
|
751
|
-
transformLnglat(
|
|
752
|
-
function n(
|
|
753
|
-
|
|
754
|
-
|
|
883
|
+
transformLnglat(e, t) {
|
|
884
|
+
function n(s) {
|
|
885
|
+
let r = /[sw]/i.test(s) ? -1 : 1;
|
|
886
|
+
const i = s.match(/[\d.]+/g) || [];
|
|
887
|
+
let o = 0;
|
|
888
|
+
for (let c = 0; c < i.length; c++)
|
|
889
|
+
o += parseFloat(i[c]) / r, r *= 60;
|
|
755
890
|
return o;
|
|
756
891
|
}
|
|
757
|
-
if (
|
|
892
|
+
if (e && t)
|
|
758
893
|
return {
|
|
759
|
-
lng: n(
|
|
760
|
-
lat: n(
|
|
894
|
+
lng: n(e),
|
|
895
|
+
lat: n(t)
|
|
761
896
|
};
|
|
762
897
|
},
|
|
763
898
|
/**
|
|
764
|
-
*
|
|
899
|
+
* 射线法判断点是否在多边形内
|
|
765
900
|
*
|
|
766
|
-
* @param
|
|
767
|
-
* @param
|
|
768
|
-
* @returns
|
|
901
|
+
* @param p 点对象,包含x和y属性
|
|
902
|
+
* @param poly 多边形顶点数组,可以是字符串数组或对象数组
|
|
903
|
+
* @returns 返回字符串,表示点相对于多边形的位置:'in'表示在多边形内,'out'表示在多边形外,'on'表示在多边形上
|
|
769
904
|
*/
|
|
770
|
-
rayCasting(
|
|
771
|
-
for (var n =
|
|
772
|
-
var c =
|
|
773
|
-
if (c === n && l ===
|
|
905
|
+
rayCasting(e, t) {
|
|
906
|
+
for (var n = e.x, s = e.y, a = !1, r = 0, i = t.length, o = i - 1; r < i; o = r, r++) {
|
|
907
|
+
var c = t[r].x, l = t[r].y, h = t[o].x, u = t[o].y;
|
|
908
|
+
if (c === n && l === s || h === n && u === s)
|
|
774
909
|
return "on";
|
|
775
|
-
if (l <
|
|
776
|
-
var d = c + (
|
|
910
|
+
if (l < s && u >= s || l >= s && u < s) {
|
|
911
|
+
var d = c + (s - l) * (h - c) / (u - l);
|
|
777
912
|
if (d === n)
|
|
778
913
|
return "on";
|
|
779
914
|
d > n && (a = !a);
|
|
@@ -782,148 +917,172 @@ const et = {
|
|
|
782
917
|
return a ? "in" : "out";
|
|
783
918
|
},
|
|
784
919
|
/**
|
|
785
|
-
*
|
|
920
|
+
* 计算两个WGS-84坐标点之间的距离
|
|
786
921
|
*
|
|
787
|
-
* @param
|
|
788
|
-
* @param
|
|
789
|
-
* @returns
|
|
922
|
+
* @param fromPoint 起始点坐标
|
|
923
|
+
* @param toPoint 目标点坐标
|
|
924
|
+
* @returns 返回两个坐标点之间的距离,单位为米
|
|
790
925
|
*/
|
|
791
|
-
wgs84PointsDistance(
|
|
926
|
+
wgs84PointsDistance(e, t) {
|
|
792
927
|
var n = Math.PI;
|
|
793
|
-
function
|
|
794
|
-
return
|
|
928
|
+
function s(G) {
|
|
929
|
+
return G * n / 180;
|
|
795
930
|
}
|
|
796
931
|
if (arguments.length != 2)
|
|
797
932
|
return 0;
|
|
798
|
-
|
|
799
|
-
var
|
|
933
|
+
const a = e.x, r = e.y, i = t.x, o = t.y;
|
|
934
|
+
var c = 6378137, l = 63567523142e-4, h = 1 / 298.257223563, u = s(i - a), d = Math.atan((1 - h) * Math.tan(s(r))), R = Math.atan((1 - h) * Math.tan(s(o))), O = Math.sin(d), v = Math.cos(d), A = Math.sin(R), w = Math.cos(R), D = u, L, N = 100;
|
|
800
935
|
do {
|
|
801
|
-
var
|
|
802
|
-
|
|
936
|
+
var I = Math.sin(D), T = Math.cos(D), y = Math.sqrt(
|
|
937
|
+
w * I * (w * I) + (v * A - O * w * T) * (v * A - O * w * T)
|
|
803
938
|
);
|
|
804
|
-
if (
|
|
805
|
-
var
|
|
806
|
-
isNaN(
|
|
807
|
-
var
|
|
808
|
-
|
|
809
|
-
} while (Math.abs(
|
|
810
|
-
if (
|
|
939
|
+
if (y == 0) return 0;
|
|
940
|
+
var S = O * A + v * w * T, k = Math.atan2(y, S), C = v * w * I / y, b = 1 - C * C, m = S - 2 * O * A / b;
|
|
941
|
+
isNaN(m) && (m = 0);
|
|
942
|
+
var _ = h / 16 * b * (4 + h * (4 - 3 * b));
|
|
943
|
+
L = D, D = u + (1 - _) * h * C * (k + _ * y * (m + _ * S * (-1 + 2 * m * m)));
|
|
944
|
+
} while (Math.abs(D - L) > 1e-12 && --N > 0);
|
|
945
|
+
if (N == 0)
|
|
811
946
|
return NaN;
|
|
812
|
-
var M =
|
|
813
|
-
return
|
|
947
|
+
var M = b * (c * c - l * l) / (l * l), $ = 1 + M / 16384 * (4096 + M * (-768 + M * (320 - 175 * M))), P = M / 1024 * (256 + M * (-128 + M * (74 - 47 * M))), B = P * y * (m + P / 4 * (S * (-1 + 2 * m * m) - P / 6 * m * (-3 + 4 * y * y) * (-3 + 4 * m * m))), W = l * $ * (k - B);
|
|
948
|
+
return W;
|
|
814
949
|
},
|
|
815
950
|
/**
|
|
816
|
-
*
|
|
951
|
+
* 旋转点
|
|
817
952
|
*
|
|
818
|
-
* @param
|
|
819
|
-
* @param
|
|
820
|
-
* @param
|
|
953
|
+
* @param p1 旋转前点坐标
|
|
954
|
+
* @param p2 旋转中心坐标
|
|
955
|
+
* @param θ 旋转角度(顺时针旋转为正)
|
|
956
|
+
* @returns 旋转后点坐标
|
|
821
957
|
*/
|
|
822
|
-
rotatePoint(
|
|
823
|
-
const
|
|
824
|
-
return { x:
|
|
958
|
+
rotatePoint(e, t, n) {
|
|
959
|
+
const s = (e.x - t.x) * Math.cos(Math.PI / 180 * -n) - (e.y - t.y) * Math.sin(Math.PI / 180 * -n) + t.x, a = (e.x - t.x) * Math.sin(Math.PI / 180 * -n) + (e.y - t.y) * Math.cos(Math.PI / 180 * -n) + t.y;
|
|
960
|
+
return { x: s, y: a };
|
|
825
961
|
},
|
|
826
|
-
|
|
827
|
-
|
|
962
|
+
/**
|
|
963
|
+
* 根据两个平面坐标点计算方位角和距离
|
|
964
|
+
*
|
|
965
|
+
* @param p1 第一个点的坐标对象
|
|
966
|
+
* @param p2 第二个点的坐标对象
|
|
967
|
+
* @returns 返回一个对象,包含angle和distance属性,分别表示两点之间的角度(以度为单位,取值范围为0~359)和距离
|
|
968
|
+
*/
|
|
969
|
+
calcBearAndDis(e, t) {
|
|
970
|
+
const { x: n, y: s } = e, { x: a, y: r } = t, i = a - n, o = r - s, c = Math.sqrt(i * i + o * o);
|
|
828
971
|
return { angle: (Math.atan2(o, i) * (180 / Math.PI) + 360 + 90) % 360, distance: c };
|
|
829
972
|
},
|
|
830
973
|
/**
|
|
831
|
-
*
|
|
974
|
+
* 根据两个经纬度点计算方位角和距离
|
|
832
975
|
*
|
|
833
|
-
* @param
|
|
834
|
-
* @param
|
|
835
|
-
* @returns
|
|
976
|
+
* @param latlng1 第一个经纬度点
|
|
977
|
+
* @param latlng2 第二个经纬度点
|
|
978
|
+
* @returns 包含方位角和距离的对象
|
|
836
979
|
*/
|
|
837
|
-
calcBearAndDisByPoints(
|
|
838
|
-
var n =
|
|
980
|
+
calcBearAndDisByPoints(e, t) {
|
|
981
|
+
var n = e.lat * 1, s = e.lng * 1, a = t.lat * 1, r = t.lng * 1, i = Math.sin((r - s) * this.toRadian) * Math.cos(a * this.toRadian), o = Math.cos(n * this.toRadian) * Math.sin(a * this.toRadian) - Math.sin(n * this.toRadian) * Math.cos(a * this.toRadian) * Math.cos((r - s) * this.toRadian), c = Math.atan2(i, o) * (180 / Math.PI), l = (a - n) * this.toRadian, h = (r - s) * this.toRadian, u = Math.sin(l / 2) * Math.sin(l / 2) + Math.cos(n * this.toRadian) * Math.cos(a * this.toRadian) * Math.sin(h / 2) * Math.sin(h / 2), d = 2 * Math.atan2(Math.sqrt(u), Math.sqrt(1 - u)), R = this.R * d;
|
|
839
982
|
return {
|
|
840
983
|
angle: c,
|
|
841
|
-
distance:
|
|
984
|
+
distance: R
|
|
842
985
|
};
|
|
843
986
|
},
|
|
844
987
|
/**
|
|
845
|
-
*
|
|
988
|
+
* 根据给定的经纬度、角度和距离计算新的经纬度点
|
|
846
989
|
*
|
|
847
|
-
* @param
|
|
848
|
-
* @param
|
|
849
|
-
* @param
|
|
850
|
-
* @returns {
|
|
990
|
+
* @param latlng 给定的经纬度点,类型为LngLat
|
|
991
|
+
* @param angle 角度值,单位为度,表示从当前点出发的方向
|
|
992
|
+
* @param distance 距离值,单位为米,表示从当前点出发的距离
|
|
993
|
+
* @returns 返回计算后的新经纬度点,类型为{lat: number, lng: number}
|
|
851
994
|
*/
|
|
852
|
-
calcPointByBearAndDis(
|
|
853
|
-
const
|
|
854
|
-
|
|
855
|
-
const s =
|
|
856
|
-
e = g.toRadians(e);
|
|
857
|
-
const i = Math.asin(Math.sin(r) * Math.cos(s) + Math.cos(r) * Math.sin(s) * Math.cos(e)), o = a + Math.atan2(Math.sin(e) * Math.sin(s) * Math.cos(r), Math.cos(s) - Math.sin(r) * Math.sin(i));
|
|
995
|
+
calcPointByBearAndDis(e, t, n) {
|
|
996
|
+
const s = g.toRadians(e.lat * 1), a = g.toRadians(e.lng * 1), r = n / this.R;
|
|
997
|
+
t = g.toRadians(t);
|
|
998
|
+
const i = Math.asin(Math.sin(s) * Math.cos(r) + Math.cos(s) * Math.sin(r) * Math.cos(t)), o = a + Math.atan2(Math.sin(t) * Math.sin(r) * Math.cos(s), Math.cos(r) - Math.sin(s) * Math.sin(i));
|
|
858
999
|
return {
|
|
859
1000
|
lat: g.toDegrees(i),
|
|
860
1001
|
lng: g.toDegrees(o)
|
|
861
1002
|
};
|
|
862
1003
|
},
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
1004
|
+
/**
|
|
1005
|
+
* 将墨卡托坐标转换为经纬度坐标
|
|
1006
|
+
*
|
|
1007
|
+
* @param x 墨卡托坐标的x值
|
|
1008
|
+
* @param y 墨卡托坐标的y值
|
|
1009
|
+
* @returns 返回包含转换后的经度lng和纬度lat的对象
|
|
1010
|
+
*/
|
|
1011
|
+
mercatorTolonlat(e, t) {
|
|
1012
|
+
const n = e / 2003750834e-2 * 180;
|
|
1013
|
+
var s = t / 2003750834e-2 * 180;
|
|
1014
|
+
const a = 180 / Math.PI * (2 * Math.atan(Math.exp(s * Math.PI / 180)) - Math.PI / 2);
|
|
867
1015
|
return { lng: n, lat: a };
|
|
868
1016
|
},
|
|
869
|
-
|
|
1017
|
+
/**
|
|
1018
|
+
* 将经纬度坐标转换为墨卡托坐标
|
|
1019
|
+
*
|
|
1020
|
+
* @param lng 经度值
|
|
1021
|
+
* @param lat 纬度值
|
|
1022
|
+
* @returns 墨卡托坐标对象,包含x和y属性
|
|
1023
|
+
*/
|
|
1024
|
+
lonlatToMercator(e, t) {
|
|
870
1025
|
var n = 6378137;
|
|
871
|
-
const
|
|
872
|
-
var a =
|
|
873
|
-
const
|
|
874
|
-
return { x:
|
|
1026
|
+
const s = e * Math.PI / 180 * n;
|
|
1027
|
+
var a = t * Math.PI / 180;
|
|
1028
|
+
const r = n / 2 * Math.log((1 + Math.sin(a)) / (1 - Math.sin(a)));
|
|
1029
|
+
return { x: s, y: r };
|
|
875
1030
|
}
|
|
876
|
-
},
|
|
1031
|
+
}, ot = {
|
|
877
1032
|
/**
|
|
878
|
-
* 将
|
|
1033
|
+
* 将Base64编码的字符串转换为Blob对象
|
|
879
1034
|
*
|
|
880
|
-
* @param
|
|
881
|
-
* @returns
|
|
1035
|
+
* @param data Base64编码的字符串
|
|
1036
|
+
* @returns 转换后的Blob对象
|
|
882
1037
|
*/
|
|
883
|
-
convertBase64ToBlob(
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
}), i);
|
|
1038
|
+
convertBase64ToBlob(e) {
|
|
1039
|
+
const t = e.split(",")[0].split(":")[1].split(";")[0], n = atob(e.split(",")[1]), s = new Array(n.length);
|
|
1040
|
+
for (let i = 0; i < n.length; i++)
|
|
1041
|
+
s[i] = n.charCodeAt(i);
|
|
1042
|
+
const a = new Uint8Array(s);
|
|
1043
|
+
return new Blob([a], { type: t });
|
|
890
1044
|
},
|
|
891
1045
|
/**
|
|
892
|
-
*
|
|
1046
|
+
* 将图片的URL转换为Base64编码
|
|
893
1047
|
*
|
|
894
|
-
* @param
|
|
895
|
-
* @param
|
|
896
|
-
* @param
|
|
897
|
-
* @returns
|
|
1048
|
+
* @param url 图片的URL地址
|
|
1049
|
+
* @param width 图片的宽度,默认为图片原始宽度
|
|
1050
|
+
* @param height 图片的高度,默认为图片原始高度
|
|
1051
|
+
* @returns 返回Promise对象,解析后得到包含Base64编码数据的对象
|
|
898
1052
|
*/
|
|
899
|
-
convertUrlToBase64(
|
|
900
|
-
return new Promise(
|
|
901
|
-
var
|
|
902
|
-
|
|
1053
|
+
convertUrlToBase64(e, t, n) {
|
|
1054
|
+
return new Promise((s, a) => {
|
|
1055
|
+
var r = new Image();
|
|
1056
|
+
r.crossOrigin = "Anonymous", r.src = e, r.onload = function() {
|
|
903
1057
|
var i = document.createElement("canvas");
|
|
904
|
-
i.width =
|
|
1058
|
+
i.width = t || r.width, i.height = n || r.height;
|
|
905
1059
|
var o = i.getContext("2d");
|
|
906
|
-
o
|
|
907
|
-
|
|
1060
|
+
if (!o) {
|
|
1061
|
+
a(new Error("Failed to get canvas context"));
|
|
1062
|
+
return;
|
|
1063
|
+
}
|
|
1064
|
+
o.drawImage(r, 0, 0, r.width, r.height);
|
|
1065
|
+
var c = r.src.substring(r.src.lastIndexOf(".") + 1).toLowerCase(), l = i.toDataURL("image/" + c), h = {
|
|
908
1066
|
dataURL: l,
|
|
909
1067
|
type: "image/" + c,
|
|
910
1068
|
ext: c
|
|
911
1069
|
};
|
|
912
|
-
|
|
913
|
-
};
|
|
1070
|
+
s(h);
|
|
1071
|
+
}, r.onerror = a;
|
|
914
1072
|
});
|
|
915
1073
|
},
|
|
916
1074
|
/**
|
|
917
|
-
* 将base64
|
|
1075
|
+
* 将base64字符串转换为文件对象
|
|
918
1076
|
*
|
|
919
|
-
* @param
|
|
920
|
-
* @param
|
|
921
|
-
* @returns
|
|
1077
|
+
* @param dataurl 包含base64字符串的数据URL
|
|
1078
|
+
* @param filename 文件的名称
|
|
1079
|
+
* @returns 返回文件对象
|
|
922
1080
|
*/
|
|
923
|
-
convertBase64ToFile(
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
1081
|
+
convertBase64ToFile(e, t) {
|
|
1082
|
+
const n = e.split(","), s = n[0].match(/:(.*?);/), a = s ? s[1] : "image/png", r = atob(n[1]), i = new Uint8Array(r.length);
|
|
1083
|
+
for (let c = 0; c < r.length; c++)
|
|
1084
|
+
i[c] = r.charCodeAt(c);
|
|
1085
|
+
return new File([i], t, { type: a });
|
|
927
1086
|
},
|
|
928
1087
|
/**
|
|
929
1088
|
* 直接下载文件,支持blob类型和url类型
|
|
@@ -931,164 +1090,175 @@ const et = {
|
|
|
931
1090
|
* @param {*} data
|
|
932
1091
|
* @param {*} saveName
|
|
933
1092
|
*/
|
|
934
|
-
downloadFromFile(
|
|
935
|
-
if (typeof
|
|
936
|
-
if (
|
|
937
|
-
|
|
1093
|
+
downloadFromFile(e, t) {
|
|
1094
|
+
if (typeof e == "object")
|
|
1095
|
+
if (e instanceof Blob)
|
|
1096
|
+
e = URL.createObjectURL(e);
|
|
938
1097
|
else {
|
|
939
|
-
const
|
|
940
|
-
|
|
1098
|
+
const s = JSON.stringify(e), a = new Blob([s], { type: "text/json" });
|
|
1099
|
+
e = window.URL.createObjectURL(a);
|
|
941
1100
|
}
|
|
942
|
-
else if (typeof
|
|
943
|
-
const
|
|
944
|
-
|
|
1101
|
+
else if (typeof e == "string" && e.indexOf("http") === -1) {
|
|
1102
|
+
const s = new Blob([e], { type: "text/json" });
|
|
1103
|
+
e = window.URL.createObjectURL(s);
|
|
945
1104
|
}
|
|
946
1105
|
var n = document.createElement("a");
|
|
947
|
-
n.href =
|
|
1106
|
+
n.href = e, n.download = t || "", n.click(), window.URL.revokeObjectURL(n.href);
|
|
948
1107
|
}
|
|
949
|
-
},
|
|
1108
|
+
}, ct = {
|
|
950
1109
|
/**
|
|
951
|
-
*
|
|
952
|
-
*
|
|
953
|
-
* @param
|
|
954
|
-
* @param
|
|
955
|
-
* @param
|
|
956
|
-
*
|
|
957
|
-
* @returns {*}
|
|
1110
|
+
* 防抖函数,在指定的等待时间内,如果连续触发事件,则只在最后一次触发后执行函数。
|
|
1111
|
+
*
|
|
1112
|
+
* @param func 需要防抖的函数。
|
|
1113
|
+
* @param wait 等待时间,单位毫秒。
|
|
1114
|
+
* @param immediate 是否立即执行函数,默认为true。
|
|
1115
|
+
* @returns 返回防抖后的函数。
|
|
958
1116
|
*/
|
|
959
|
-
debounce(
|
|
960
|
-
let
|
|
1117
|
+
debounce(e, t, n = !0) {
|
|
1118
|
+
let s = null, a, r, i, o;
|
|
961
1119
|
const c = function() {
|
|
962
|
-
const l =
|
|
963
|
-
l <
|
|
1120
|
+
const l = Date.now() - i;
|
|
1121
|
+
l < t && l > 0 ? s = setTimeout(c, t - l) : (s = null, n || (o = e.apply(r, a)));
|
|
964
1122
|
};
|
|
965
1123
|
return function(...l) {
|
|
966
|
-
|
|
967
|
-
const h = n && !
|
|
968
|
-
return
|
|
1124
|
+
r = this, i = Date.now();
|
|
1125
|
+
const h = n && !s;
|
|
1126
|
+
return s || (s = setTimeout(c, t)), h && (o = e.apply(r, l), s || (r = l = null)), o;
|
|
969
1127
|
};
|
|
970
1128
|
},
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
* @param {*} wait
|
|
976
|
-
* @param {*} type 1 表时间戳版,2 表定时器版
|
|
977
|
-
* @returns {*}
|
|
978
|
-
*/
|
|
979
|
-
throttle(t, e, n) {
|
|
980
|
-
if (n === 1)
|
|
981
|
-
var r = 0;
|
|
982
|
-
else if (n === 2)
|
|
983
|
-
var a;
|
|
984
|
-
return function() {
|
|
985
|
-
let s = this, i = arguments;
|
|
1129
|
+
throttle(e, t, n) {
|
|
1130
|
+
let s = 0, a = null;
|
|
1131
|
+
return function(...r) {
|
|
1132
|
+
const i = this;
|
|
986
1133
|
if (n === 1) {
|
|
987
|
-
|
|
988
|
-
o -
|
|
1134
|
+
const o = Date.now();
|
|
1135
|
+
o - s > t && (e.apply(i, r), s = o);
|
|
989
1136
|
} else n === 2 && (a || (a = setTimeout(() => {
|
|
990
|
-
a = null,
|
|
991
|
-
},
|
|
1137
|
+
a = null, e.apply(i, r);
|
|
1138
|
+
}, t)));
|
|
992
1139
|
};
|
|
993
1140
|
},
|
|
994
1141
|
/**
|
|
995
|
-
*
|
|
1142
|
+
* 递归调用函数,以一定的频率和持续时间执行。
|
|
996
1143
|
*
|
|
997
|
-
* @param
|
|
998
|
-
* @param
|
|
1144
|
+
* @param fun 要递归调用的函数。
|
|
1145
|
+
* @param frequency 每次调用函数之间的时间间隔,单位为毫秒,默认为500毫秒。
|
|
1146
|
+
* @param duration 函数递归调用的总时长,单位为毫秒,默认为5000毫秒。
|
|
999
1147
|
*/
|
|
1000
|
-
recurve(
|
|
1001
|
-
let
|
|
1002
|
-
setTimeout(
|
|
1003
|
-
|
|
1004
|
-
});
|
|
1148
|
+
recurve(e, t = 500, n = 5e3) {
|
|
1149
|
+
let s = 0;
|
|
1150
|
+
setTimeout(() => {
|
|
1151
|
+
s++, s < Math.floor(n / t) && (e.call(this), setTimeout(this.recurve.bind(this, e, t, n), t));
|
|
1152
|
+
}, t);
|
|
1005
1153
|
}
|
|
1006
|
-
},
|
|
1154
|
+
}, Y = {
|
|
1007
1155
|
/**
|
|
1008
|
-
*
|
|
1156
|
+
* 校验字符串是否符合指定类型
|
|
1009
1157
|
*
|
|
1010
|
-
* @param
|
|
1011
|
-
* @param
|
|
1012
|
-
*
|
|
1158
|
+
* @param str 待校验字符串
|
|
1159
|
+
* @param type 校验类型,可选值包括:
|
|
1160
|
+
* - 'phone': 手机号码
|
|
1161
|
+
* - 'tel': 座机
|
|
1162
|
+
* - 'card': 身份证
|
|
1163
|
+
* - 'pwd': 密码(以字母开头,长度在6~18之间,只能包含字母、数字和下划线)
|
|
1164
|
+
* - 'postal': 邮政编码
|
|
1165
|
+
* - 'QQ': QQ号
|
|
1166
|
+
* - 'email': 邮箱
|
|
1167
|
+
* - 'money': 金额(小数点2位)
|
|
1168
|
+
* - 'URL': 网址
|
|
1169
|
+
* - 'IP': IP地址
|
|
1170
|
+
* - 'date': 日期时间
|
|
1171
|
+
* - 'number': 数字
|
|
1172
|
+
* - 'english': 英文
|
|
1173
|
+
* - 'chinese': 中文
|
|
1174
|
+
* - 'lower': 小写字母
|
|
1175
|
+
* - 'upper': 大写字母
|
|
1176
|
+
* - 'HTML': HTML标记
|
|
1177
|
+
* @returns 校验结果,符合返回true,否则返回false
|
|
1013
1178
|
*/
|
|
1014
|
-
checkStr(
|
|
1015
|
-
switch (
|
|
1179
|
+
checkStr(e, t) {
|
|
1180
|
+
switch (t) {
|
|
1016
1181
|
case "phone":
|
|
1017
|
-
return /^1[3|4|5|6|7|8|9][0-9]{9}$/.test(
|
|
1182
|
+
return /^1[3|4|5|6|7|8|9][0-9]{9}$/.test(e);
|
|
1018
1183
|
case "tel":
|
|
1019
|
-
return /^(0\d{2,3}-\d{7,8})(-\d{1,4})?$/.test(
|
|
1184
|
+
return /^(0\d{2,3}-\d{7,8})(-\d{1,4})?$/.test(e);
|
|
1020
1185
|
case "card":
|
|
1021
|
-
return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(
|
|
1186
|
+
return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(e);
|
|
1022
1187
|
case "pwd":
|
|
1023
|
-
return /^[a-zA-Z]\w{5,17}$/.test(
|
|
1188
|
+
return /^[a-zA-Z]\w{5,17}$/.test(e);
|
|
1024
1189
|
case "postal":
|
|
1025
|
-
return /[1-9]\d{5}(?!\d)/.test(
|
|
1190
|
+
return /[1-9]\d{5}(?!\d)/.test(e);
|
|
1026
1191
|
case "QQ":
|
|
1027
|
-
return /^[1-9][0-9]{4,9}$/.test(
|
|
1192
|
+
return /^[1-9][0-9]{4,9}$/.test(e);
|
|
1028
1193
|
case "email":
|
|
1029
|
-
return /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(
|
|
1194
|
+
return /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(e);
|
|
1030
1195
|
case "money":
|
|
1031
|
-
return /^\d*(?:\.\d{0,2})?$/.test(
|
|
1196
|
+
return /^\d*(?:\.\d{0,2})?$/.test(e);
|
|
1032
1197
|
case "URL":
|
|
1033
|
-
return /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/.test(
|
|
1198
|
+
return /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/.test(e);
|
|
1034
1199
|
case "IP":
|
|
1035
|
-
return /((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))/.test(
|
|
1200
|
+
return /((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))/.test(e);
|
|
1036
1201
|
case "date":
|
|
1037
|
-
return /^(\d{4})\-(\d{2})\-(\d{2}) (\d{2})(?:\:\d{2}|:(\d{2}):(\d{2}))$/.test(
|
|
1202
|
+
return /^(\d{4})\-(\d{2})\-(\d{2}) (\d{2})(?:\:\d{2}|:(\d{2}):(\d{2}))$/.test(e) || /^(\d{4})\-(\d{2})\-(\d{2})$/.test(e);
|
|
1038
1203
|
case "number":
|
|
1039
|
-
return /^[0-9]$/.test(
|
|
1204
|
+
return /^[0-9]$/.test(e);
|
|
1040
1205
|
case "english":
|
|
1041
|
-
return /^[a-zA-Z]+$/.test(
|
|
1206
|
+
return /^[a-zA-Z]+$/.test(e);
|
|
1042
1207
|
case "chinese":
|
|
1043
|
-
return /^[\u4E00-\u9FA5]+$/.test(
|
|
1208
|
+
return /^[\u4E00-\u9FA5]+$/.test(e);
|
|
1044
1209
|
case "lower":
|
|
1045
|
-
return /^[a-z]+$/.test(
|
|
1210
|
+
return /^[a-z]+$/.test(e);
|
|
1046
1211
|
case "upper":
|
|
1047
|
-
return /^[A-Z]+$/.test(
|
|
1212
|
+
return /^[A-Z]+$/.test(e);
|
|
1048
1213
|
case "HTML":
|
|
1049
|
-
return /<("[^"]*"|'[^']*'|[^'">])*>/.test(
|
|
1214
|
+
return /<("[^"]*"|'[^']*'|[^'">])*>/.test(e);
|
|
1050
1215
|
default:
|
|
1051
1216
|
return !0;
|
|
1052
1217
|
}
|
|
1053
1218
|
},
|
|
1054
1219
|
/**
|
|
1055
|
-
*
|
|
1220
|
+
* 转换字符串大小写
|
|
1056
1221
|
*
|
|
1057
|
-
* @param
|
|
1058
|
-
* @param
|
|
1059
|
-
*
|
|
1222
|
+
* @param str 待转换的字符串
|
|
1223
|
+
* @param type 转换类型,可选值为 1-5,默认为 4
|
|
1224
|
+
* 1:首字母大写,其余小写
|
|
1225
|
+
* 2:首字母小写,其余大写
|
|
1226
|
+
* 3:字母大小写反转
|
|
1227
|
+
* 4:全部大写
|
|
1228
|
+
* 5:全部小写
|
|
1229
|
+
* @returns 转换后的字符串
|
|
1060
1230
|
*/
|
|
1061
|
-
changeCase(
|
|
1062
|
-
switch (
|
|
1231
|
+
changeCase(e, t) {
|
|
1232
|
+
switch (t = t || 4, t) {
|
|
1063
1233
|
case 1:
|
|
1064
|
-
return
|
|
1234
|
+
return e.replace(/\b\w+\b/g, function(n) {
|
|
1065
1235
|
return n.substring(0, 1).toUpperCase() + n.substring(1).toLowerCase();
|
|
1066
1236
|
});
|
|
1067
1237
|
case 2:
|
|
1068
|
-
return
|
|
1238
|
+
return e.replace(/\b\w+\b/g, function(n) {
|
|
1069
1239
|
return n.substring(0, 1).toLowerCase() + n.substring(1).toUpperCase();
|
|
1070
1240
|
});
|
|
1071
1241
|
case 3:
|
|
1072
|
-
return
|
|
1242
|
+
return e.split("").map(function(n) {
|
|
1073
1243
|
return /[a-z]/.test(n) ? n.toUpperCase() : n.toLowerCase();
|
|
1074
1244
|
}).join("");
|
|
1075
1245
|
case 4:
|
|
1076
|
-
return
|
|
1246
|
+
return e.toUpperCase();
|
|
1077
1247
|
case 5:
|
|
1078
|
-
return
|
|
1248
|
+
return e.toLowerCase();
|
|
1079
1249
|
default:
|
|
1080
|
-
return
|
|
1250
|
+
return e;
|
|
1081
1251
|
}
|
|
1082
1252
|
},
|
|
1083
1253
|
/**
|
|
1084
|
-
*
|
|
1085
|
-
*
|
|
1086
|
-
* @param
|
|
1087
|
-
* @param {
|
|
1088
|
-
* @returns
|
|
1254
|
+
* 根据字符串数组和参数生成新的字符串
|
|
1255
|
+
*
|
|
1256
|
+
* @param strArray 字符串数组
|
|
1257
|
+
* @param args 可变参数列表,支持 Object、Array 类型和任意其他类型,若为 null 或 undefined,则按类型默认转换为 '{}'、'[]' 或 ''
|
|
1258
|
+
* @returns 返回生成的新字符串
|
|
1089
1259
|
*/
|
|
1090
|
-
tag(
|
|
1091
|
-
return
|
|
1260
|
+
tag(e, ...t) {
|
|
1261
|
+
return t = t.map((n) => {
|
|
1092
1262
|
switch (E.getDataType(n)) {
|
|
1093
1263
|
case "Object":
|
|
1094
1264
|
return n || "{}";
|
|
@@ -1097,150 +1267,159 @@ const et = {
|
|
|
1097
1267
|
default:
|
|
1098
1268
|
return n || "";
|
|
1099
1269
|
}
|
|
1100
|
-
}),
|
|
1270
|
+
}), e.reduce((n, s, a) => `${n}${t[a - 1]}${s}`);
|
|
1101
1271
|
},
|
|
1102
1272
|
/**
|
|
1103
|
-
*
|
|
1104
|
-
*
|
|
1105
|
-
* @
|
|
1273
|
+
* 计算字符串的字节长度
|
|
1274
|
+
*
|
|
1275
|
+
* @param str 需要计算字节长度的字符串
|
|
1276
|
+
* @returns 返回字符串的字节长度
|
|
1106
1277
|
*/
|
|
1107
|
-
getByteLength(
|
|
1108
|
-
return
|
|
1278
|
+
getByteLength(e) {
|
|
1279
|
+
return e.replace(/[\u0391-\uFFE5]/g, "aa").length;
|
|
1109
1280
|
},
|
|
1110
1281
|
/**
|
|
1111
|
-
*
|
|
1112
|
-
*
|
|
1113
|
-
* @param
|
|
1114
|
-
* @
|
|
1282
|
+
* 截取字符串中指定字节长度的子串
|
|
1283
|
+
*
|
|
1284
|
+
* @param str 字符串对象,包含replace、length和substring方法
|
|
1285
|
+
* @param start 截取起始位置
|
|
1286
|
+
* @param n 截取字节长度
|
|
1287
|
+
* @returns 返回截取后的子串
|
|
1115
1288
|
*/
|
|
1116
|
-
subStringByte(
|
|
1117
|
-
var
|
|
1118
|
-
if (
|
|
1119
|
-
return
|
|
1120
|
-
for (var a = Math.floor(n / 2),
|
|
1121
|
-
let i =
|
|
1122
|
-
if (i.replace(
|
|
1289
|
+
subStringByte(e, t, n) {
|
|
1290
|
+
var s = /[^\x00-\xff]/g;
|
|
1291
|
+
if (e.replace(s, "mm").length <= n)
|
|
1292
|
+
return e;
|
|
1293
|
+
for (var a = Math.floor(n / 2), r = a; r < e.length; r++) {
|
|
1294
|
+
let i = e.substring(t, r);
|
|
1295
|
+
if (i.replace(s, "mm").length >= n)
|
|
1123
1296
|
return i;
|
|
1124
1297
|
}
|
|
1125
|
-
return
|
|
1298
|
+
return e;
|
|
1126
1299
|
},
|
|
1127
|
-
|
|
1128
|
-
|
|
1300
|
+
/**
|
|
1301
|
+
* 将值转换为字符串
|
|
1302
|
+
*
|
|
1303
|
+
* @param value 要转换的值
|
|
1304
|
+
* @returns 转换后的字符串,如果值为空,则返回空字符串
|
|
1305
|
+
*/
|
|
1306
|
+
asString(e) {
|
|
1307
|
+
if (E.isEmpty(e))
|
|
1129
1308
|
return "";
|
|
1130
|
-
switch (E.getDataType()) {
|
|
1309
|
+
switch (E.getDataType(e)) {
|
|
1131
1310
|
case "Object":
|
|
1132
1311
|
case "Array":
|
|
1133
|
-
return JSON.stringify(
|
|
1312
|
+
return JSON.stringify(e);
|
|
1134
1313
|
default:
|
|
1135
|
-
return
|
|
1314
|
+
return e;
|
|
1136
1315
|
}
|
|
1137
1316
|
}
|
|
1138
|
-
},
|
|
1139
|
-
notNull(
|
|
1140
|
-
if (E.isEmpty(
|
|
1141
|
-
throw Error("不能为空:>>>" +
|
|
1317
|
+
}, lt = {
|
|
1318
|
+
notNull(e) {
|
|
1319
|
+
if (E.isEmpty(e))
|
|
1320
|
+
throw Error("不能为空:>>>" + e);
|
|
1142
1321
|
},
|
|
1143
|
-
legalLnglat(
|
|
1144
|
-
if (!
|
|
1145
|
-
throw Error(
|
|
1322
|
+
legalLnglat(e, t) {
|
|
1323
|
+
if (!q.isLnglat(e, t))
|
|
1324
|
+
throw Error(p.COORDINATE_ERROR);
|
|
1146
1325
|
},
|
|
1147
|
-
contain(
|
|
1326
|
+
contain(e, ...t) {
|
|
1148
1327
|
let n = !1;
|
|
1149
|
-
const
|
|
1150
|
-
for (let a = 0,
|
|
1151
|
-
n =
|
|
1328
|
+
const s = t.length || 0;
|
|
1329
|
+
for (let a = 0, r = s; a < r; a++)
|
|
1330
|
+
n = e.indexOf(t[a]) >= 0;
|
|
1152
1331
|
if (n)
|
|
1153
|
-
throw Error(
|
|
1332
|
+
throw Error(p.STRING_CHECK_LOSS);
|
|
1154
1333
|
},
|
|
1155
1334
|
verify: {
|
|
1156
|
-
array(
|
|
1157
|
-
if (E.getDataType(
|
|
1158
|
-
throw Error(
|
|
1335
|
+
array(e) {
|
|
1336
|
+
if (E.getDataType(e) !== "Array")
|
|
1337
|
+
throw Error(p.PARAMETER_ERROR_ARRAY + ":>>>" + e);
|
|
1159
1338
|
},
|
|
1160
|
-
function(
|
|
1161
|
-
if (E.getDataType(
|
|
1162
|
-
throw Error(
|
|
1339
|
+
function(e) {
|
|
1340
|
+
if (E.getDataType(e) !== "Function")
|
|
1341
|
+
throw Error(p.PARAMETER_ERROR_FUNCTION + ":>>>" + e);
|
|
1163
1342
|
},
|
|
1164
|
-
object(
|
|
1165
|
-
if (E.getDataType(
|
|
1166
|
-
throw Error(
|
|
1343
|
+
object(e) {
|
|
1344
|
+
if (E.getDataType(e) !== "Object")
|
|
1345
|
+
throw Error(p.PARAMETER_ERROR_OBJECT + ":>>>" + e);
|
|
1167
1346
|
}
|
|
1168
1347
|
},
|
|
1169
|
-
legalJSON(
|
|
1348
|
+
legalJSON(e) {
|
|
1170
1349
|
try {
|
|
1171
|
-
JSON.parse(
|
|
1350
|
+
JSON.parse(e);
|
|
1172
1351
|
} catch {
|
|
1173
|
-
throw Error(
|
|
1352
|
+
throw Error(p.JSON_PARSE_ERROR + ":>>>" + e);
|
|
1174
1353
|
}
|
|
1175
1354
|
},
|
|
1176
|
-
legalData(
|
|
1177
|
-
const n =
|
|
1178
|
-
let
|
|
1179
|
-
switch (
|
|
1355
|
+
legalData(e, t) {
|
|
1356
|
+
const n = Y.checkStr(e, t);
|
|
1357
|
+
let s = "";
|
|
1358
|
+
switch (t) {
|
|
1180
1359
|
case "phone":
|
|
1181
|
-
|
|
1360
|
+
s = "电话";
|
|
1182
1361
|
break;
|
|
1183
1362
|
case "tel":
|
|
1184
|
-
|
|
1363
|
+
s = "座机";
|
|
1185
1364
|
break;
|
|
1186
1365
|
case "card":
|
|
1187
|
-
|
|
1366
|
+
s = "身份证";
|
|
1188
1367
|
break;
|
|
1189
1368
|
case "pwd":
|
|
1190
|
-
|
|
1369
|
+
s = "密码";
|
|
1191
1370
|
break;
|
|
1192
1371
|
case "postal":
|
|
1193
|
-
|
|
1372
|
+
s = "邮政编码";
|
|
1194
1373
|
break;
|
|
1195
1374
|
case "QQ":
|
|
1196
|
-
|
|
1375
|
+
s = "QQ";
|
|
1197
1376
|
break;
|
|
1198
1377
|
case "email":
|
|
1199
|
-
|
|
1378
|
+
s = "邮箱";
|
|
1200
1379
|
break;
|
|
1201
1380
|
case "money":
|
|
1202
|
-
|
|
1381
|
+
s = "金额";
|
|
1203
1382
|
break;
|
|
1204
1383
|
case "URL":
|
|
1205
|
-
|
|
1384
|
+
s = "网址";
|
|
1206
1385
|
break;
|
|
1207
1386
|
case "IP":
|
|
1208
|
-
|
|
1387
|
+
s = "IP";
|
|
1209
1388
|
break;
|
|
1210
1389
|
case "date":
|
|
1211
|
-
|
|
1390
|
+
s = "日期时间";
|
|
1212
1391
|
break;
|
|
1213
1392
|
case "number":
|
|
1214
|
-
|
|
1393
|
+
s = "数字";
|
|
1215
1394
|
break;
|
|
1216
1395
|
case "english":
|
|
1217
|
-
|
|
1396
|
+
s = "英文";
|
|
1218
1397
|
break;
|
|
1219
1398
|
case "chinese":
|
|
1220
|
-
|
|
1399
|
+
s = "中文";
|
|
1221
1400
|
break;
|
|
1222
1401
|
case "lower":
|
|
1223
|
-
|
|
1402
|
+
s = "小写";
|
|
1224
1403
|
break;
|
|
1225
1404
|
case "upper":
|
|
1226
|
-
|
|
1405
|
+
s = "大写";
|
|
1227
1406
|
break;
|
|
1228
1407
|
case "HTML":
|
|
1229
|
-
|
|
1408
|
+
s = "HTML标记";
|
|
1230
1409
|
break;
|
|
1231
1410
|
}
|
|
1232
1411
|
if (!n)
|
|
1233
|
-
throw Error(
|
|
1412
|
+
throw Error(p.PARAMETER_ERROR + ":>>>不是" + s);
|
|
1234
1413
|
}
|
|
1235
1414
|
};
|
|
1236
|
-
class
|
|
1237
|
-
constructor(
|
|
1415
|
+
class ht {
|
|
1416
|
+
constructor(t) {
|
|
1238
1417
|
/**
|
|
1239
1418
|
* Creates an instance of AudioPlayer.
|
|
1240
1419
|
* @param {*} url
|
|
1241
1420
|
*/
|
|
1242
|
-
|
|
1243
|
-
this.audio = new Audio(), this.audio.src =
|
|
1421
|
+
f(this, "audio");
|
|
1422
|
+
this.audio = new Audio(), this.audio.src = t;
|
|
1244
1423
|
}
|
|
1245
1424
|
play() {
|
|
1246
1425
|
!this.muted && this.audio.play();
|
|
@@ -1254,18 +1433,18 @@ class at {
|
|
|
1254
1433
|
/**
|
|
1255
1434
|
* @description 设置静音状态,如果静音,autoplay属性将失效
|
|
1256
1435
|
*/
|
|
1257
|
-
set muted(
|
|
1258
|
-
this.audio.muted =
|
|
1436
|
+
set muted(t) {
|
|
1437
|
+
this.audio.muted = t;
|
|
1259
1438
|
}
|
|
1260
1439
|
}
|
|
1261
|
-
class
|
|
1262
|
-
constructor(
|
|
1263
|
-
E.getDataType(
|
|
1440
|
+
class ut {
|
|
1441
|
+
constructor(t) {
|
|
1442
|
+
E.getDataType(t) === "String" && (t = document.querySelector("#" + t)), this.ctx = t.getContext("2d");
|
|
1264
1443
|
}
|
|
1265
|
-
drawLine(
|
|
1444
|
+
drawLine(t, n, s, a, r = {}) {
|
|
1266
1445
|
this.cxt.beginPath();
|
|
1267
|
-
const i =
|
|
1268
|
-
this.cxt.lineWidth = i, this.cxt.fillStyle = o, this.cxt.moveTo(
|
|
1446
|
+
const i = r.width || 1, o = r.color || "#000";
|
|
1447
|
+
this.cxt.lineWidth = i, this.cxt.fillStyle = o, this.cxt.moveTo(t, n), this.cxt.lineTo(s, a), this.cxt.closePath(), this.cxt.fill();
|
|
1269
1448
|
}
|
|
1270
1449
|
/**
|
|
1271
1450
|
* 绘制圆弧
|
|
@@ -1280,18 +1459,18 @@ class it {
|
|
|
1280
1459
|
* @param {*} bgColor 圆弧的颜色
|
|
1281
1460
|
* @memberof CanvasDrawer
|
|
1282
1461
|
*/
|
|
1283
|
-
drawArc(
|
|
1284
|
-
o ? (this.cxt.fillStyle = c, this.cxt.beginPath(), this.cxt.arc(
|
|
1462
|
+
drawArc(t, n, s, a, r, i, o, c) {
|
|
1463
|
+
o ? (this.cxt.fillStyle = c, this.cxt.beginPath(), this.cxt.arc(t, n, s, g.degreesToRadians(a), g.degreesToRadians(r), i), this.cxt.closePath(), this.cxt.fill()) : (this.cxt.strokeStyle = c, this.cxt.beginPath(), this.cxt.arc(t, n, s, g.degreesToRadians(a), g.degreesToRadians(r), i), this.cxt.stroke());
|
|
1285
1464
|
}
|
|
1286
1465
|
}
|
|
1287
|
-
class
|
|
1288
|
-
constructor(
|
|
1289
|
-
this.magnification =
|
|
1466
|
+
class dt {
|
|
1467
|
+
constructor(t = 1) {
|
|
1468
|
+
this.magnification = t;
|
|
1290
1469
|
}
|
|
1291
1470
|
// 获取系统类型
|
|
1292
1471
|
_getSystem() {
|
|
1293
|
-
var
|
|
1294
|
-
if (
|
|
1472
|
+
var t = navigator.userAgent.toLowerCase();
|
|
1473
|
+
if (t.indexOf("windows") >= 0)
|
|
1295
1474
|
return !0;
|
|
1296
1475
|
}
|
|
1297
1476
|
// 获取页面缩放比例
|
|
@@ -1299,143 +1478,146 @@ class ot {
|
|
|
1299
1478
|
// let t = this;
|
|
1300
1479
|
// }
|
|
1301
1480
|
// 监听方法兼容写法
|
|
1302
|
-
_addHandler(
|
|
1303
|
-
|
|
1481
|
+
_addHandler(t, n, s) {
|
|
1482
|
+
t.addEventListener ? t.addEventListener(n, s, !1) : t.attachEvent ? t.attachEvent("on" + n, s) : t["on" + n] = s;
|
|
1304
1483
|
}
|
|
1305
1484
|
// 校正浏览器缩放比例
|
|
1306
1485
|
_correct() {
|
|
1307
|
-
let
|
|
1308
|
-
if (typeof
|
|
1309
|
-
const
|
|
1310
|
-
document.documentElement.style.fontSize = this.magnification * 75 * Math.min(
|
|
1311
|
-
} else if (
|
|
1312
|
-
const
|
|
1313
|
-
document.documentElement.style.fontSize = this.magnification * 85 * Math.min(
|
|
1486
|
+
let t = window.innerWidth;
|
|
1487
|
+
if (typeof t != "number" && (document.compatMode == "CSS1Compat" ? t = document.documentElement.clientWidth : t = document.body.clientWidth), t <= 750) {
|
|
1488
|
+
const s = document.documentElement.clientWidth / t;
|
|
1489
|
+
document.documentElement.style.fontSize = this.magnification * 75 * Math.min(s, 2) + "px";
|
|
1490
|
+
} else if (t > 750 && t <= 1200) {
|
|
1491
|
+
const s = document.documentElement.clientWidth / t;
|
|
1492
|
+
document.documentElement.style.fontSize = this.magnification * 85 * Math.min(s, 2) + "px";
|
|
1314
1493
|
} else {
|
|
1315
|
-
const
|
|
1316
|
-
document.documentElement.style.fontSize = this.magnification * 100 * Math.min(
|
|
1494
|
+
const s = document.documentElement.clientWidth / 1920;
|
|
1495
|
+
document.documentElement.style.fontSize = this.magnification * 100 * Math.min(s, 2) + "px";
|
|
1317
1496
|
}
|
|
1318
1497
|
}
|
|
1319
1498
|
// 监听页面缩放
|
|
1320
1499
|
_watch() {
|
|
1321
|
-
let
|
|
1322
|
-
|
|
1323
|
-
|
|
1500
|
+
let t = this;
|
|
1501
|
+
t._addHandler(window, "resize", function() {
|
|
1502
|
+
t._correct();
|
|
1324
1503
|
});
|
|
1325
1504
|
}
|
|
1326
1505
|
// 初始化页面比例
|
|
1327
1506
|
init() {
|
|
1328
|
-
let
|
|
1329
|
-
|
|
1507
|
+
let t = this;
|
|
1508
|
+
t._getSystem() && (t._correct(), t._watch());
|
|
1330
1509
|
}
|
|
1331
1510
|
}
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
return n[t] !== void 0 && n[t].indexOf(e) !== -1;
|
|
1350
|
-
},
|
|
1351
|
-
removeEventListener(t, e) {
|
|
1511
|
+
class K {
|
|
1512
|
+
constructor() {
|
|
1513
|
+
f(this, "_listeners");
|
|
1514
|
+
f(this, "_mutex", {});
|
|
1515
|
+
f(this, "_context");
|
|
1516
|
+
}
|
|
1517
|
+
addEventListener(t, n, s, a = !1) {
|
|
1518
|
+
this._listeners === void 0 && (this._listeners = {}), this._context = s;
|
|
1519
|
+
const r = this._mutex, i = this._listeners;
|
|
1520
|
+
return i[t] === void 0 && (i[t] = []), i[t].indexOf(n) === -1 && (a && (r[t] = n), i[t].push(n)), this;
|
|
1521
|
+
}
|
|
1522
|
+
hasEventListener(t, n) {
|
|
1523
|
+
if (this._listeners === null || this._listeners === void 0) return !1;
|
|
1524
|
+
const s = this._listeners;
|
|
1525
|
+
return s[t] !== void 0 && s[t].indexOf(n) !== -1;
|
|
1526
|
+
}
|
|
1527
|
+
removeEventListener(t, n) {
|
|
1352
1528
|
if (this._listeners === void 0) return;
|
|
1353
|
-
const
|
|
1354
|
-
if (this._mutex[t] ===
|
|
1355
|
-
const
|
|
1356
|
-
|
|
1529
|
+
const a = this._listeners[t];
|
|
1530
|
+
if (this._mutex[t] === n && (this._mutex[t] = null), a !== void 0) {
|
|
1531
|
+
const r = a.map((i) => i.toString()).indexOf(n.toString());
|
|
1532
|
+
r !== -1 && a.splice(r, 1);
|
|
1357
1533
|
}
|
|
1358
|
-
}
|
|
1359
|
-
/**
|
|
1360
|
-
* 派发事件
|
|
1361
|
-
* @param event{{type: string, message: {}}}
|
|
1362
|
-
*/
|
|
1534
|
+
}
|
|
1363
1535
|
dispatchEvent(t) {
|
|
1364
1536
|
if (this._listeners === void 0) return;
|
|
1365
|
-
const
|
|
1366
|
-
if (
|
|
1537
|
+
const s = this._listeners[t.type];
|
|
1538
|
+
if (s !== void 0) {
|
|
1367
1539
|
t.target = this;
|
|
1368
|
-
const
|
|
1369
|
-
if (this._mutex[t.type]) {
|
|
1370
|
-
r.find((
|
|
1371
|
-
|
|
1540
|
+
const a = s.slice(0);
|
|
1541
|
+
if (this._mutex[t.type] !== void 0) {
|
|
1542
|
+
const r = a.find((i) => i === this._mutex[t.type]);
|
|
1543
|
+
if (r) {
|
|
1544
|
+
r.call(this._context || this, t);
|
|
1545
|
+
return;
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
for (let r = 0, i = a.length; r < i; r++) {
|
|
1549
|
+
const o = a[r];
|
|
1550
|
+
typeof o == "function" && o.call(this._context || this, t);
|
|
1372
1551
|
}
|
|
1373
|
-
for (let a = 0, s = r.length; a < s; a++)
|
|
1374
|
-
r[a].call(this._context || this, t);
|
|
1375
1552
|
}
|
|
1376
|
-
}
|
|
1553
|
+
}
|
|
1377
1554
|
removeAllListener() {
|
|
1378
1555
|
this._mutex = {};
|
|
1379
1556
|
for (const t in this._listeners)
|
|
1380
1557
|
this._listeners[t] = [];
|
|
1381
1558
|
}
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1559
|
+
}
|
|
1560
|
+
class F extends Map {
|
|
1384
1561
|
isEmpty() {
|
|
1385
1562
|
return this.size === 0;
|
|
1386
|
-
}
|
|
1563
|
+
}
|
|
1387
1564
|
_values() {
|
|
1388
|
-
return Array.from(
|
|
1389
|
-
}
|
|
1565
|
+
return Array.from(this.values());
|
|
1566
|
+
}
|
|
1390
1567
|
_keys() {
|
|
1391
|
-
return Array.from(
|
|
1392
|
-
}
|
|
1568
|
+
return Array.from(this.keys());
|
|
1569
|
+
}
|
|
1393
1570
|
_entries() {
|
|
1394
|
-
return Array.from(
|
|
1571
|
+
return Array.from(this.entries());
|
|
1572
|
+
}
|
|
1573
|
+
fromEntries() {
|
|
1395
1574
|
}
|
|
1396
|
-
});
|
|
1397
|
-
function N() {
|
|
1398
|
-
return /* @__PURE__ */ new Map();
|
|
1399
1575
|
}
|
|
1400
|
-
|
|
1401
|
-
const
|
|
1402
|
-
return
|
|
1403
|
-
Array.isArray(n) && n.length === 2 &&
|
|
1404
|
-
}),
|
|
1576
|
+
F.prototype.fromEntries = function(e = []) {
|
|
1577
|
+
const t = new F();
|
|
1578
|
+
return e.forEach((n) => {
|
|
1579
|
+
Array.isArray(n) && n.length === 2 && t.set(n[0], n[1]);
|
|
1580
|
+
}), t;
|
|
1405
1581
|
};
|
|
1406
|
-
class
|
|
1407
|
-
constructor(
|
|
1408
|
-
super()
|
|
1582
|
+
class ft extends K {
|
|
1583
|
+
constructor(n = "ws://127.0.0.1:10088") {
|
|
1584
|
+
super();
|
|
1585
|
+
f(this, "maxCheckTimes", 10);
|
|
1586
|
+
f(this, "url");
|
|
1587
|
+
f(this, "checkTimes", 0);
|
|
1588
|
+
f(this, "connectStatus", !1);
|
|
1589
|
+
f(this, "client", null);
|
|
1590
|
+
this.maxCheckTimes = 10, this.url = n, this.checkTimes = 0, this.connect(), this.connCheckStatus(this.maxCheckTimes);
|
|
1409
1591
|
}
|
|
1410
1592
|
connect() {
|
|
1411
1593
|
if (this.disconnect(), this.url)
|
|
1412
1594
|
try {
|
|
1413
1595
|
if (console.info("创建ws连接>>>" + this.url), this.client = new WebSocket(this.url), this.client) {
|
|
1414
|
-
const
|
|
1415
|
-
this.client.onopen = function(
|
|
1416
|
-
|
|
1417
|
-
type:
|
|
1418
|
-
message:
|
|
1596
|
+
const n = this;
|
|
1597
|
+
this.client.onopen = function(s) {
|
|
1598
|
+
n.dispatchEvent({
|
|
1599
|
+
type: x.WEB_SOCKET_CONNECT,
|
|
1600
|
+
message: s
|
|
1419
1601
|
});
|
|
1420
|
-
}, this.client.onmessage = function(
|
|
1421
|
-
|
|
1422
|
-
type:
|
|
1423
|
-
message:
|
|
1602
|
+
}, this.client.onmessage = function(s) {
|
|
1603
|
+
n.connectStatus = !0, n.dispatchEvent({
|
|
1604
|
+
type: x.WEB_SOCKET_MESSAGE,
|
|
1605
|
+
message: s
|
|
1424
1606
|
});
|
|
1425
|
-
}, this.client.onclose = function(
|
|
1426
|
-
|
|
1427
|
-
type:
|
|
1428
|
-
message:
|
|
1607
|
+
}, this.client.onclose = function(s) {
|
|
1608
|
+
n.dispatchEvent({
|
|
1609
|
+
type: x.WEB_SOCKET_CLOSE,
|
|
1610
|
+
message: s
|
|
1429
1611
|
});
|
|
1430
|
-
}, this.checkTimes === this.maxCheckTimes && (this.client.onerror = function(
|
|
1431
|
-
|
|
1432
|
-
type:
|
|
1433
|
-
message:
|
|
1612
|
+
}, this.checkTimes === this.maxCheckTimes && (this.client.onerror = function(s) {
|
|
1613
|
+
n.dispatchEvent({
|
|
1614
|
+
type: x.WEB_SOCKET_ERROR,
|
|
1615
|
+
message: s
|
|
1434
1616
|
});
|
|
1435
1617
|
});
|
|
1436
1618
|
}
|
|
1437
|
-
} catch (
|
|
1438
|
-
console.error("创建ws连接失败" + this.url + ":" +
|
|
1619
|
+
} catch (n) {
|
|
1620
|
+
console.error("创建ws连接失败" + this.url + ":" + n);
|
|
1439
1621
|
}
|
|
1440
1622
|
}
|
|
1441
1623
|
disconnect() {
|
|
@@ -1446,36 +1628,30 @@ class y extends k {
|
|
|
1446
1628
|
this.client = null;
|
|
1447
1629
|
}
|
|
1448
1630
|
}
|
|
1449
|
-
connCheckStatus(
|
|
1450
|
-
this.checkTimes >
|
|
1451
|
-
this.checkTimes++, this.client && this.client.readyState !== 0 && this.client.readyState !== 1 && this.connect(), this.connCheckStatus(
|
|
1631
|
+
connCheckStatus(n) {
|
|
1632
|
+
this.checkTimes > n || setTimeout(() => {
|
|
1633
|
+
this.checkTimes++, this.client && this.client.readyState !== 0 && this.client.readyState !== 1 && this.connect(), this.connCheckStatus(n);
|
|
1452
1634
|
}, 2e3);
|
|
1453
1635
|
}
|
|
1454
|
-
send(
|
|
1455
|
-
return this.client && this.client.readyState === 1 ? (this.client.send(
|
|
1636
|
+
send(n) {
|
|
1637
|
+
return this.client && this.client.readyState === 1 ? (this.client.send(n), !0) : (console.error(this.url + "消息发送失败:" + n), !1);
|
|
1456
1638
|
}
|
|
1457
1639
|
heartbeat() {
|
|
1458
1640
|
setTimeout(() => {
|
|
1459
1641
|
this.client && this.client.readyState === 1 && this.send("HeartBeat"), console.log("HeartBeat," + this.url), setTimeout(this.heartbeat, 3e4);
|
|
1460
1642
|
}, 1e3);
|
|
1461
1643
|
}
|
|
1462
|
-
static getInstance() {
|
|
1463
|
-
return y.instance ? y.instance : Object.freeze(new y());
|
|
1464
|
-
}
|
|
1465
|
-
static get _instance() {
|
|
1466
|
-
return this.getInstance();
|
|
1467
|
-
}
|
|
1468
1644
|
}
|
|
1469
|
-
class
|
|
1470
|
-
constructor(
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
if (this.cacheType =
|
|
1645
|
+
class mt {
|
|
1646
|
+
constructor(t = 1) {
|
|
1647
|
+
f(this, "cacheType");
|
|
1648
|
+
f(this, "storage");
|
|
1649
|
+
if (this.cacheType = t, t === 1)
|
|
1474
1650
|
this.storage = window.localStorage;
|
|
1475
|
-
else if (
|
|
1651
|
+
else if (t === 2)
|
|
1476
1652
|
this.storage = window.sessionStorage;
|
|
1477
1653
|
else
|
|
1478
|
-
throw new Error(
|
|
1654
|
+
throw new Error(p.PARAMETER_ERROR);
|
|
1479
1655
|
}
|
|
1480
1656
|
/**
|
|
1481
1657
|
* 设置带过期时间的LocalStorage
|
|
@@ -1484,39 +1660,39 @@ class ct {
|
|
|
1484
1660
|
* @param expired 以秒为单位,默认为1小时
|
|
1485
1661
|
* @returns {Object}
|
|
1486
1662
|
*/
|
|
1487
|
-
setItem(
|
|
1488
|
-
const a = { key:
|
|
1663
|
+
setItem(t, n, s) {
|
|
1664
|
+
const a = { key: t, value: n };
|
|
1489
1665
|
if (this.cacheType === 1) {
|
|
1490
|
-
const
|
|
1491
|
-
|
|
1666
|
+
const r = Date.now();
|
|
1667
|
+
s && (a.expired = r + s * 1e3);
|
|
1492
1668
|
}
|
|
1493
|
-
return this.storage[
|
|
1669
|
+
return this.storage[t] = JSON.stringify(a), a;
|
|
1494
1670
|
}
|
|
1495
1671
|
/***
|
|
1496
1672
|
* 获取带过期时间的缓存
|
|
1497
1673
|
* @param key
|
|
1498
1674
|
* @returns {null|*}
|
|
1499
1675
|
*/
|
|
1500
|
-
getItem(
|
|
1501
|
-
const n = this.storage.getItem(
|
|
1676
|
+
getItem(t) {
|
|
1677
|
+
const n = this.storage.getItem(t);
|
|
1502
1678
|
if (n === null)
|
|
1503
1679
|
return null;
|
|
1504
|
-
const
|
|
1680
|
+
const s = JSON.parse(n) || {};
|
|
1505
1681
|
if (this.cacheType === 1) {
|
|
1506
|
-
const a =
|
|
1682
|
+
const a = s.expired ? new Date(s.expired).getTime() : Date.now();
|
|
1507
1683
|
if (Date.now() > a)
|
|
1508
|
-
return this.remove(
|
|
1684
|
+
return this.remove(t), null;
|
|
1509
1685
|
}
|
|
1510
|
-
return
|
|
1686
|
+
return s.value;
|
|
1511
1687
|
}
|
|
1512
1688
|
/**
|
|
1513
1689
|
* 移除指定缓存
|
|
1514
1690
|
* @param keys
|
|
1515
1691
|
*/
|
|
1516
|
-
remove(
|
|
1517
|
-
|
|
1692
|
+
remove(t) {
|
|
1693
|
+
t && (t.indexOf(",") > -1 ? t.split(",").forEach((n) => {
|
|
1518
1694
|
this.storage.removeItem(n);
|
|
1519
|
-
}) : this.storage.removeItem(
|
|
1695
|
+
}) : this.storage.removeItem(t));
|
|
1520
1696
|
}
|
|
1521
1697
|
/**
|
|
1522
1698
|
* 移出全部缓存
|
|
@@ -1526,29 +1702,31 @@ class ct {
|
|
|
1526
1702
|
}
|
|
1527
1703
|
}
|
|
1528
1704
|
export {
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1705
|
+
tt as AnimateUtils,
|
|
1706
|
+
et as ArrayUtils,
|
|
1707
|
+
lt as AssertUtils,
|
|
1708
|
+
ht as AudioPlayer,
|
|
1709
|
+
nt as BrowserUtils,
|
|
1710
|
+
ut as CanvasDrawer,
|
|
1711
|
+
st as Cookie,
|
|
1712
|
+
rt as CoordsUtils,
|
|
1713
|
+
at as DateUtils,
|
|
1714
|
+
dt as DevicePixelRatio,
|
|
1715
|
+
it as DomUtils,
|
|
1716
|
+
p as ErrorType,
|
|
1717
|
+
K as EventDispatcher,
|
|
1718
|
+
x as EventType,
|
|
1719
|
+
ot as FileUtils,
|
|
1720
|
+
q as GeoUtils,
|
|
1721
|
+
X as GraphicType,
|
|
1722
|
+
F as HashMap,
|
|
1723
|
+
Q as LayerType,
|
|
1548
1724
|
g as MathUtils,
|
|
1549
|
-
|
|
1550
|
-
|
|
1725
|
+
V as MeasureMode,
|
|
1726
|
+
Z as ObjectState,
|
|
1727
|
+
ct as OptimizeUtils,
|
|
1728
|
+
Y as StringUtils,
|
|
1551
1729
|
E as Utils,
|
|
1552
|
-
|
|
1553
|
-
|
|
1730
|
+
ft as WebSocketClient,
|
|
1731
|
+
mt as WebStorage
|
|
1554
1732
|
};
|