gis-common 1.0.15 → 1.0.19
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/resource.min.js +91 -57
- package/package.json +1 -1
package/dist/resource.min.js
CHANGED
|
@@ -316,7 +316,7 @@ __webpack_require__.d(__webpack_exports__, "WebStorage", function() { return /*
|
|
|
316
316
|
* @param {*} json
|
|
317
317
|
* @returns {*}
|
|
318
318
|
*/
|
|
319
|
-
|
|
319
|
+
json2Query: function json2Query(json) {
|
|
320
320
|
var tempArr = [];
|
|
321
321
|
for (var i in json) {
|
|
322
322
|
var key = i;
|
|
@@ -717,22 +717,22 @@ Array.prototype.clear = function () {
|
|
|
717
717
|
|
|
718
718
|
var exp = new Date();
|
|
719
719
|
exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
|
|
720
|
-
document.cookie = name +
|
|
720
|
+
document.cookie = name + '=' + escape(value) + ';expires=' + exp.toGMTString();
|
|
721
721
|
},
|
|
722
722
|
remove: function remove(name) {
|
|
723
723
|
var exp = new Date();
|
|
724
724
|
exp.setTime(exp.getTime() - 1);
|
|
725
|
-
var cval =
|
|
725
|
+
var cval = this.get(name);
|
|
726
726
|
if (cval != null) {
|
|
727
|
-
document.cookie = name +
|
|
727
|
+
document.cookie = name + '=' + cval + ';expires=' + exp.toGMTString();
|
|
728
728
|
}
|
|
729
729
|
},
|
|
730
730
|
get: function get(name) {
|
|
731
|
-
var arr = document.cookie.match(new RegExp(
|
|
731
|
+
var arr = document.cookie.match(new RegExp('(^| )' + name + '=([^;]*)(;|$)'));
|
|
732
732
|
if (arr != null) {
|
|
733
733
|
return arr[2];
|
|
734
734
|
} else {
|
|
735
|
-
return
|
|
735
|
+
return '';
|
|
736
736
|
}
|
|
737
737
|
}
|
|
738
738
|
});
|
|
@@ -1611,6 +1611,14 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
1611
1611
|
return str;
|
|
1612
1612
|
}
|
|
1613
1613
|
},
|
|
1614
|
+
|
|
1615
|
+
/**
|
|
1616
|
+
* 处理字符串模板
|
|
1617
|
+
* eg: tag`${abc}`
|
|
1618
|
+
* @param {*} strArray
|
|
1619
|
+
* @param {*} args
|
|
1620
|
+
* @returns {*}
|
|
1621
|
+
*/
|
|
1614
1622
|
tag: function tag(strArray) {
|
|
1615
1623
|
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1616
1624
|
args[_key - 1] = arguments[_key];
|
|
@@ -1629,6 +1637,36 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
1629
1637
|
return strArray.reduce(function (prev, next, index) {
|
|
1630
1638
|
return '' + prev + args[index - 1] + next;
|
|
1631
1639
|
});
|
|
1640
|
+
},
|
|
1641
|
+
|
|
1642
|
+
/**
|
|
1643
|
+
* 获取字符串字节长度
|
|
1644
|
+
* @param {*} str
|
|
1645
|
+
* @returns {*}
|
|
1646
|
+
*/
|
|
1647
|
+
getByteLength: function getByteLength(str) {
|
|
1648
|
+
return str.replace(/[\u0391-\uFFE5]/g, 'aa').length;
|
|
1649
|
+
},
|
|
1650
|
+
|
|
1651
|
+
/**
|
|
1652
|
+
* 根据字节长度截取字符串
|
|
1653
|
+
* @param {*} str
|
|
1654
|
+
* @param {*} n
|
|
1655
|
+
* @returns {*}
|
|
1656
|
+
*/
|
|
1657
|
+
subStringByte: function subStringByte(str, n) {
|
|
1658
|
+
var r = /[^\x00-\xff]/g;
|
|
1659
|
+
if (str.replace(r, 'mm').length <= n) {
|
|
1660
|
+
return str;
|
|
1661
|
+
}
|
|
1662
|
+
var m = Math.floor(n / 2);
|
|
1663
|
+
for (var i = m; i < str.length; i++) {
|
|
1664
|
+
var sub = str.substring(0, i);
|
|
1665
|
+
if (sub.replace(r, 'mm').length >= n) {
|
|
1666
|
+
return sub;
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
return str;
|
|
1632
1670
|
}
|
|
1633
1671
|
});
|
|
1634
1672
|
// CONCATENATED MODULE: ./src/utils/index.js
|
|
@@ -2227,7 +2265,7 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
|
2227
2265
|
WebSocketClient_inherits(WebSocketClient, _EventDispatcher);
|
|
2228
2266
|
|
|
2229
2267
|
function WebSocketClient() {
|
|
2230
|
-
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
2268
|
+
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'ws://127.0.0.1:10088';
|
|
2231
2269
|
|
|
2232
2270
|
WebSocketClient_classCallCheck(this, WebSocketClient);
|
|
2233
2271
|
|
|
@@ -2245,57 +2283,53 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
|
2245
2283
|
}
|
|
2246
2284
|
|
|
2247
2285
|
WebSocketClient_createClass(WebSocketClient, [{
|
|
2248
|
-
key:
|
|
2286
|
+
key: 'connect',
|
|
2249
2287
|
value: function connect() {
|
|
2250
|
-
var _this2 = this;
|
|
2251
|
-
|
|
2252
2288
|
this.checkTimes++;
|
|
2253
2289
|
this.disconnect();
|
|
2254
2290
|
if (this.url) {
|
|
2255
2291
|
try {
|
|
2256
|
-
console.info(
|
|
2292
|
+
console.info('创建ws连接' + this.url);
|
|
2257
2293
|
this.client = new WebSocket(this.url);
|
|
2258
2294
|
if (this.client) {
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
};
|
|
2286
|
-
}
|
|
2295
|
+
var self = this;
|
|
2296
|
+
this.client.onopen = function (message) {
|
|
2297
|
+
self.dispatchEvent({
|
|
2298
|
+
type: EventTypeConstant.WEB_SOCKET_CONNECT,
|
|
2299
|
+
message: message
|
|
2300
|
+
});
|
|
2301
|
+
};
|
|
2302
|
+
this.client.onmessage = function (message) {
|
|
2303
|
+
self.connectStatus = true;
|
|
2304
|
+
self.dispatchEvent({
|
|
2305
|
+
type: EventTypeConstant.WEB_SOCKET_MESSAGE,
|
|
2306
|
+
message: message
|
|
2307
|
+
});
|
|
2308
|
+
};
|
|
2309
|
+
this.client.onclose = function (message) {
|
|
2310
|
+
self.dispatchEvent({
|
|
2311
|
+
type: EventTypeConstant.WEB_SOCKET_CLOSE,
|
|
2312
|
+
message: message
|
|
2313
|
+
});
|
|
2314
|
+
};
|
|
2315
|
+
this.client.onerror = function (message) {
|
|
2316
|
+
self.dispatchEvent({
|
|
2317
|
+
type: EventTypeConstant.WEB_SOCKET_ERROR,
|
|
2318
|
+
message: message
|
|
2319
|
+
});
|
|
2320
|
+
};
|
|
2287
2321
|
}
|
|
2288
2322
|
} catch (ex) {
|
|
2289
|
-
console.error(
|
|
2323
|
+
console.error('创建ws连接失败' + this.url + ':' + ex);
|
|
2290
2324
|
}
|
|
2291
2325
|
}
|
|
2292
2326
|
}
|
|
2293
2327
|
}, {
|
|
2294
|
-
key:
|
|
2328
|
+
key: 'disconnect',
|
|
2295
2329
|
value: function disconnect() {
|
|
2296
2330
|
if (this.client) {
|
|
2297
2331
|
try {
|
|
2298
|
-
console.log(
|
|
2332
|
+
console.log('ws断开连接' + this.url);
|
|
2299
2333
|
this.client.close();
|
|
2300
2334
|
this.client = null;
|
|
2301
2335
|
} catch (ex) {
|
|
@@ -2304,43 +2338,43 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
|
2304
2338
|
}
|
|
2305
2339
|
}
|
|
2306
2340
|
}, {
|
|
2307
|
-
key:
|
|
2341
|
+
key: 'connCheckStatus',
|
|
2308
2342
|
value: function connCheckStatus(times) {
|
|
2309
|
-
var
|
|
2343
|
+
var _this2 = this;
|
|
2310
2344
|
|
|
2311
2345
|
if (this.checkTimes > times) return;
|
|
2312
2346
|
setTimeout(function () {
|
|
2313
|
-
if (
|
|
2314
|
-
|
|
2347
|
+
if (_this2.client && _this2.client.readyState !== 0 && _this2.client.readyState !== 1) {
|
|
2348
|
+
_this2.connect();
|
|
2315
2349
|
}
|
|
2316
|
-
|
|
2350
|
+
_this2.connCheckStatus(times);
|
|
2317
2351
|
}, 2000);
|
|
2318
2352
|
}
|
|
2319
2353
|
}, {
|
|
2320
|
-
key:
|
|
2354
|
+
key: 'send',
|
|
2321
2355
|
value: function send(message) {
|
|
2322
2356
|
if (this.client && this.client.readyState === 1) {
|
|
2323
2357
|
this.client.send(message);
|
|
2324
2358
|
return true;
|
|
2325
2359
|
}
|
|
2326
|
-
console.error(this.url +
|
|
2360
|
+
console.error(this.url + '消息发送失败:' + message);
|
|
2327
2361
|
return false;
|
|
2328
2362
|
}
|
|
2329
2363
|
}, {
|
|
2330
|
-
key:
|
|
2364
|
+
key: 'heartbeat',
|
|
2331
2365
|
value: function heartbeat() {
|
|
2332
|
-
var
|
|
2366
|
+
var _this3 = this;
|
|
2333
2367
|
|
|
2334
2368
|
setTimeout(function () {
|
|
2335
|
-
if (
|
|
2336
|
-
|
|
2369
|
+
if (_this3.client && _this3.client.readyState === 1) {
|
|
2370
|
+
_this3.send('HeartBeat');
|
|
2337
2371
|
}
|
|
2338
|
-
console.log(
|
|
2339
|
-
setTimeout(
|
|
2372
|
+
console.log('HeartBeat,' + _this3.url);
|
|
2373
|
+
setTimeout(_this3.heartbeat, 30000);
|
|
2340
2374
|
}, 1000);
|
|
2341
2375
|
}
|
|
2342
2376
|
}], [{
|
|
2343
|
-
key:
|
|
2377
|
+
key: 'getInstance',
|
|
2344
2378
|
value: function getInstance() {
|
|
2345
2379
|
if (WebSocketClient.instance) {
|
|
2346
2380
|
return WebSocketClient.instance;
|
|
@@ -2349,7 +2383,7 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
|
2349
2383
|
}
|
|
2350
2384
|
}
|
|
2351
2385
|
}, {
|
|
2352
|
-
key:
|
|
2386
|
+
key: '_instance',
|
|
2353
2387
|
get: function get() {
|
|
2354
2388
|
return this.getInstance();
|
|
2355
2389
|
}
|