gis-common 1.0.17 → 1.1.1

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.
@@ -316,7 +316,7 @@ __webpack_require__.d(__webpack_exports__, "WebStorage", function() { return /*
316
316
  * @param {*} json
317
317
  * @returns {*}
318
318
  */
319
- jsontoQuery: function jsontoQuery(json) {
319
+ json2Query: function json2Query(json) {
320
320
  var tempArr = [];
321
321
  for (var i in json) {
322
322
  var key = i;
@@ -1494,26 +1494,6 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
1494
1494
  });
1495
1495
  // CONCATENATED MODULE: ./src/utils/StringUtils.js
1496
1496
 
1497
- /**
1498
- * 获取字节长度
1499
- */
1500
- String.prototype.bLength = function () {
1501
- return this.replace(/[\u0391-\uFFE5]/g, 'aa').length;
1502
- };
1503
- String.prototype.subStringByte = function (n) {
1504
- var r = /[^\x00-\xff]/g;
1505
- if (this.replace(r, 'mm').length <= n) {
1506
- return this;
1507
- }
1508
- var m = Math.floor(n / 2);
1509
- for (var i = m; i < this.length; i++) {
1510
- var sub = this.substring(0, i);
1511
- if (sub.replace(r, 'mm').length >= n) {
1512
- return sub;
1513
- }
1514
- }
1515
- return this;
1516
- };
1517
1497
  /* harmony default export */ var StringUtils = ({
1518
1498
  /**
1519
1499
  * 常用正则验证
@@ -1631,6 +1611,14 @@ String.prototype.subStringByte = function (n) {
1631
1611
  return str;
1632
1612
  }
1633
1613
  },
1614
+
1615
+ /**
1616
+ * 处理字符串模板
1617
+ * eg: tag`${abc}`
1618
+ * @param {*} strArray
1619
+ * @param {*} args
1620
+ * @returns {*}
1621
+ */
1634
1622
  tag: function tag(strArray) {
1635
1623
  for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1636
1624
  args[_key - 1] = arguments[_key];
@@ -1649,6 +1637,36 @@ String.prototype.subStringByte = function (n) {
1649
1637
  return strArray.reduce(function (prev, next, index) {
1650
1638
  return '' + prev + args[index - 1] + next;
1651
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;
1652
1670
  }
1653
1671
  });
1654
1672
  // CONCATENATED MODULE: ./src/utils/index.js
@@ -2247,7 +2265,7 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
2247
2265
  WebSocketClient_inherits(WebSocketClient, _EventDispatcher);
2248
2266
 
2249
2267
  function WebSocketClient() {
2250
- var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "ws://127.0.0.1:10088";
2268
+ var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'ws://127.0.0.1:10088';
2251
2269
 
2252
2270
  WebSocketClient_classCallCheck(this, WebSocketClient);
2253
2271
 
@@ -2265,40 +2283,37 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
2265
2283
  }
2266
2284
 
2267
2285
  WebSocketClient_createClass(WebSocketClient, [{
2268
- key: "connect",
2286
+ key: 'connect',
2269
2287
  value: function connect() {
2270
- var _this2 = this;
2271
-
2272
- this.checkTimes++;
2273
2288
  this.disconnect();
2274
2289
  if (this.url) {
2275
2290
  try {
2276
- console.info("创建ws连接" + this.url);
2291
+ console.info('创建ws连接' + this.url);
2277
2292
  this.client = new WebSocket(this.url);
2278
2293
  if (this.client) {
2279
- // 当连接成功或连接失败达到最大重连次数的一半时
2280
- if (!this.connectStatus && this.checkTimes === Math.floor(this.maxCheckTimes / 2) || this.connectStatus) {
2281
- this.client.onopen = function (message) {
2282
- _this2.dispatchEvent({
2283
- type: EventTypeConstant.WEB_SOCKET_CONNECT,
2284
- message: message
2285
- });
2286
- };
2287
- this.client.onmessage = function (message) {
2288
- _this2.connectStatus = true;
2289
- _this2.dispatchEvent({
2290
- type: EventTypeConstant.WEB_SOCKET_MESSAGE,
2291
- message: message
2292
- });
2293
- };
2294
- this.client.onclose = function (message) {
2295
- _this2.dispatchEvent({
2296
- type: EventTypeConstant.WEB_SOCKET_CLOSE,
2297
- message: message
2298
- });
2299
- };
2294
+ var self = this;
2295
+ this.client.onopen = function (message) {
2296
+ self.dispatchEvent({
2297
+ type: EventTypeConstant.WEB_SOCKET_CONNECT,
2298
+ message: message
2299
+ });
2300
+ };
2301
+ this.client.onmessage = function (message) {
2302
+ self.connectStatus = true;
2303
+ self.dispatchEvent({
2304
+ type: EventTypeConstant.WEB_SOCKET_MESSAGE,
2305
+ message: message
2306
+ });
2307
+ };
2308
+ this.client.onclose = function (message) {
2309
+ self.dispatchEvent({
2310
+ type: EventTypeConstant.WEB_SOCKET_CLOSE,
2311
+ message: message
2312
+ });
2313
+ };
2314
+ if (this.checkTimes === this.maxCheckTimes) {
2300
2315
  this.client.onerror = function (message) {
2301
- _this2.dispatchEvent({
2316
+ self.dispatchEvent({
2302
2317
  type: EventTypeConstant.WEB_SOCKET_ERROR,
2303
2318
  message: message
2304
2319
  });
@@ -2306,16 +2321,16 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
2306
2321
  }
2307
2322
  }
2308
2323
  } catch (ex) {
2309
- console.error("创建ws连接失败" + this.url + ":" + ex);
2324
+ console.error('创建ws连接失败' + this.url + ':' + ex);
2310
2325
  }
2311
2326
  }
2312
2327
  }
2313
2328
  }, {
2314
- key: "disconnect",
2329
+ key: 'disconnect',
2315
2330
  value: function disconnect() {
2316
2331
  if (this.client) {
2317
2332
  try {
2318
- console.log("ws断开连接" + this.url);
2333
+ console.log('ws断开连接' + this.url);
2319
2334
  this.client.close();
2320
2335
  this.client = null;
2321
2336
  } catch (ex) {
@@ -2324,43 +2339,44 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
2324
2339
  }
2325
2340
  }
2326
2341
  }, {
2327
- key: "connCheckStatus",
2342
+ key: 'connCheckStatus',
2328
2343
  value: function connCheckStatus(times) {
2329
- var _this3 = this;
2344
+ var _this2 = this;
2330
2345
 
2331
2346
  if (this.checkTimes > times) return;
2332
2347
  setTimeout(function () {
2333
- if (_this3.client && _this3.client.readyState !== 0 && _this3.client.readyState !== 1) {
2334
- _this3.connect();
2348
+ _this2.checkTimes++;
2349
+ if (_this2.client && _this2.client.readyState !== 0 && _this2.client.readyState !== 1) {
2350
+ _this2.connect();
2335
2351
  }
2336
- _this3.connCheckStatus(times);
2352
+ _this2.connCheckStatus(times);
2337
2353
  }, 2000);
2338
2354
  }
2339
2355
  }, {
2340
- key: "send",
2356
+ key: 'send',
2341
2357
  value: function send(message) {
2342
2358
  if (this.client && this.client.readyState === 1) {
2343
2359
  this.client.send(message);
2344
2360
  return true;
2345
2361
  }
2346
- console.error(this.url + "消息发送失败:" + message);
2362
+ console.error(this.url + '消息发送失败:' + message);
2347
2363
  return false;
2348
2364
  }
2349
2365
  }, {
2350
- key: "heartbeat",
2366
+ key: 'heartbeat',
2351
2367
  value: function heartbeat() {
2352
- var _this4 = this;
2368
+ var _this3 = this;
2353
2369
 
2354
2370
  setTimeout(function () {
2355
- if (_this4.client && _this4.client.readyState === 1) {
2356
- _this4.send("HeartBeat");
2371
+ if (_this3.client && _this3.client.readyState === 1) {
2372
+ _this3.send('HeartBeat');
2357
2373
  }
2358
- console.log("HeartBeat," + _this4.url);
2359
- setTimeout(_this4.heartbeat, 30000);
2374
+ console.log('HeartBeat,' + _this3.url);
2375
+ setTimeout(_this3.heartbeat, 30000);
2360
2376
  }, 1000);
2361
2377
  }
2362
2378
  }], [{
2363
- key: "getInstance",
2379
+ key: 'getInstance',
2364
2380
  value: function getInstance() {
2365
2381
  if (WebSocketClient.instance) {
2366
2382
  return WebSocketClient.instance;
@@ -2369,7 +2385,7 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
2369
2385
  }
2370
2386
  }
2371
2387
  }, {
2372
- key: "_instance",
2388
+ key: '_instance',
2373
2389
  get: function get() {
2374
2390
  return this.getInstance();
2375
2391
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "gis-common",
3
3
  "description": "gis-common",
4
4
  "main": "dist/resource.min.js",
5
- "version": "1.0.17",
5
+ "version": "1.1.1",
6
6
  "author": "Guo.Yan <luv02@vip.qq.com>",
7
7
  "license": "MIT",
8
8
  "private": false,