gis-common 1.0.19 → 2.0.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.
- package/dist/resource.min.js +58 -100
- package/package.json +35 -35
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
|
+
jsontoQuery: function jsontoQuery(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 = getCookie(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
|
});
|
|
@@ -1493,7 +1493,6 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
1493
1493
|
}
|
|
1494
1494
|
});
|
|
1495
1495
|
// CONCATENATED MODULE: ./src/utils/StringUtils.js
|
|
1496
|
-
|
|
1497
1496
|
/* harmony default export */ var StringUtils = ({
|
|
1498
1497
|
/**
|
|
1499
1498
|
* 常用正则验证
|
|
@@ -1611,62 +1610,17 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
1611
1610
|
return str;
|
|
1612
1611
|
}
|
|
1613
1612
|
},
|
|
1614
|
-
|
|
1615
|
-
/**
|
|
1616
|
-
* 处理字符串模板
|
|
1617
|
-
* eg: tag`${abc}`
|
|
1618
|
-
* @param {*} strArray
|
|
1619
|
-
* @param {*} args
|
|
1620
|
-
* @returns {*}
|
|
1621
|
-
*/
|
|
1622
1613
|
tag: function tag(strArray) {
|
|
1623
1614
|
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1624
1615
|
args[_key - 1] = arguments[_key];
|
|
1625
1616
|
}
|
|
1626
1617
|
|
|
1627
1618
|
args = args.map(function (val) {
|
|
1628
|
-
|
|
1629
|
-
case 'Object':
|
|
1630
|
-
return val || '{}';
|
|
1631
|
-
case 'Array':
|
|
1632
|
-
return val || '[]';
|
|
1633
|
-
default:
|
|
1634
|
-
return val || '';
|
|
1635
|
-
}
|
|
1619
|
+
return val || '';
|
|
1636
1620
|
});
|
|
1637
1621
|
return strArray.reduce(function (prev, next, index) {
|
|
1638
1622
|
return '' + prev + args[index - 1] + next;
|
|
1639
1623
|
});
|
|
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;
|
|
1670
1624
|
}
|
|
1671
1625
|
});
|
|
1672
1626
|
// CONCATENATED MODULE: ./src/utils/index.js
|
|
@@ -2265,7 +2219,7 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
|
2265
2219
|
WebSocketClient_inherits(WebSocketClient, _EventDispatcher);
|
|
2266
2220
|
|
|
2267
2221
|
function WebSocketClient() {
|
|
2268
|
-
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
2222
|
+
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "ws://127.0.0.1:10088";
|
|
2269
2223
|
|
|
2270
2224
|
WebSocketClient_classCallCheck(this, WebSocketClient);
|
|
2271
2225
|
|
|
@@ -2283,53 +2237,57 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
|
2283
2237
|
}
|
|
2284
2238
|
|
|
2285
2239
|
WebSocketClient_createClass(WebSocketClient, [{
|
|
2286
|
-
key:
|
|
2240
|
+
key: "connect",
|
|
2287
2241
|
value: function connect() {
|
|
2242
|
+
var _this2 = this;
|
|
2243
|
+
|
|
2288
2244
|
this.checkTimes++;
|
|
2289
2245
|
this.disconnect();
|
|
2290
2246
|
if (this.url) {
|
|
2291
2247
|
try {
|
|
2292
|
-
console.info(
|
|
2248
|
+
console.info("创建ws连接" + this.url);
|
|
2293
2249
|
this.client = new WebSocket(this.url);
|
|
2294
2250
|
if (this.client) {
|
|
2295
|
-
|
|
2296
|
-
this.
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2251
|
+
// 当连接成功或连接失败达到最大重连次数的一半时
|
|
2252
|
+
if (!this.connectStatus && this.checkTimes === Math.floor(this.maxCheckTimes / 2) || this.connectStatus) {
|
|
2253
|
+
this.client.onopen = function (message) {
|
|
2254
|
+
_this2.dispatchEvent({
|
|
2255
|
+
type: EventTypeConstant.WEB_SOCKET_CONNECT,
|
|
2256
|
+
message: message
|
|
2257
|
+
});
|
|
2258
|
+
};
|
|
2259
|
+
this.client.onmessage = function (message) {
|
|
2260
|
+
_this2.connectStatus = true;
|
|
2261
|
+
_this2.dispatchEvent({
|
|
2262
|
+
type: EventTypeConstant.WEB_SOCKET_MESSAGE,
|
|
2263
|
+
message: message
|
|
2264
|
+
});
|
|
2265
|
+
};
|
|
2266
|
+
this.client.onclose = function (message) {
|
|
2267
|
+
_this2.dispatchEvent({
|
|
2268
|
+
type: EventTypeConstant.WEB_SOCKET_CLOSE,
|
|
2269
|
+
message: message
|
|
2270
|
+
});
|
|
2271
|
+
};
|
|
2272
|
+
this.client.onerror = function (message) {
|
|
2273
|
+
_this2.dispatchEvent({
|
|
2274
|
+
type: EventTypeConstant.WEB_SOCKET_ERROR,
|
|
2275
|
+
message: message
|
|
2276
|
+
});
|
|
2277
|
+
};
|
|
2278
|
+
}
|
|
2321
2279
|
}
|
|
2322
2280
|
} catch (ex) {
|
|
2323
|
-
console.error(
|
|
2281
|
+
console.error("创建ws连接失败" + this.url + ":" + ex);
|
|
2324
2282
|
}
|
|
2325
2283
|
}
|
|
2326
2284
|
}
|
|
2327
2285
|
}, {
|
|
2328
|
-
key:
|
|
2286
|
+
key: "disconnect",
|
|
2329
2287
|
value: function disconnect() {
|
|
2330
2288
|
if (this.client) {
|
|
2331
2289
|
try {
|
|
2332
|
-
console.log(
|
|
2290
|
+
console.log("ws断开连接" + this.url);
|
|
2333
2291
|
this.client.close();
|
|
2334
2292
|
this.client = null;
|
|
2335
2293
|
} catch (ex) {
|
|
@@ -2338,43 +2296,43 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
|
2338
2296
|
}
|
|
2339
2297
|
}
|
|
2340
2298
|
}, {
|
|
2341
|
-
key:
|
|
2299
|
+
key: "connCheckStatus",
|
|
2342
2300
|
value: function connCheckStatus(times) {
|
|
2343
|
-
var
|
|
2301
|
+
var _this3 = this;
|
|
2344
2302
|
|
|
2345
2303
|
if (this.checkTimes > times) return;
|
|
2346
2304
|
setTimeout(function () {
|
|
2347
|
-
if (
|
|
2348
|
-
|
|
2305
|
+
if (_this3.client && _this3.client.readyState !== 0 && _this3.client.readyState !== 1) {
|
|
2306
|
+
_this3.connect();
|
|
2349
2307
|
}
|
|
2350
|
-
|
|
2308
|
+
_this3.connCheckStatus(times);
|
|
2351
2309
|
}, 2000);
|
|
2352
2310
|
}
|
|
2353
2311
|
}, {
|
|
2354
|
-
key:
|
|
2312
|
+
key: "send",
|
|
2355
2313
|
value: function send(message) {
|
|
2356
2314
|
if (this.client && this.client.readyState === 1) {
|
|
2357
2315
|
this.client.send(message);
|
|
2358
2316
|
return true;
|
|
2359
2317
|
}
|
|
2360
|
-
console.error(this.url +
|
|
2318
|
+
console.error(this.url + "消息发送失败:" + message);
|
|
2361
2319
|
return false;
|
|
2362
2320
|
}
|
|
2363
2321
|
}, {
|
|
2364
|
-
key:
|
|
2322
|
+
key: "heartbeat",
|
|
2365
2323
|
value: function heartbeat() {
|
|
2366
|
-
var
|
|
2324
|
+
var _this4 = this;
|
|
2367
2325
|
|
|
2368
2326
|
setTimeout(function () {
|
|
2369
|
-
if (
|
|
2370
|
-
|
|
2327
|
+
if (_this4.client && _this4.client.readyState === 1) {
|
|
2328
|
+
_this4.send("HeartBeat");
|
|
2371
2329
|
}
|
|
2372
|
-
console.log(
|
|
2373
|
-
setTimeout(
|
|
2330
|
+
console.log("HeartBeat," + _this4.url);
|
|
2331
|
+
setTimeout(_this4.heartbeat, 30000);
|
|
2374
2332
|
}, 1000);
|
|
2375
2333
|
}
|
|
2376
2334
|
}], [{
|
|
2377
|
-
key:
|
|
2335
|
+
key: "getInstance",
|
|
2378
2336
|
value: function getInstance() {
|
|
2379
2337
|
if (WebSocketClient.instance) {
|
|
2380
2338
|
return WebSocketClient.instance;
|
|
@@ -2383,7 +2341,7 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
|
2383
2341
|
}
|
|
2384
2342
|
}
|
|
2385
2343
|
}, {
|
|
2386
|
-
key:
|
|
2344
|
+
key: "_instance",
|
|
2387
2345
|
get: function get() {
|
|
2388
2346
|
return this.getInstance();
|
|
2389
2347
|
}
|
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "gis-common",
|
|
3
|
-
"description": "gis-common",
|
|
4
|
-
"main": "dist/resource.min.js",
|
|
5
|
-
"version": "
|
|
6
|
-
"author": "Guo.Yan <luv02@vip.qq.com>",
|
|
7
|
-
"license": "MIT",
|
|
8
|
-
"private": false,
|
|
9
|
-
"scripts": {
|
|
10
|
-
"dev": "cross-env NODE_ENV=development webpack-dev-server --hot --port 7000",
|
|
11
|
-
"build": "cross-env NODE_ENV=production webpack --progress"
|
|
12
|
-
},
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"babel-
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"webpack": "^
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "gis-common",
|
|
3
|
+
"description": "gis-common",
|
|
4
|
+
"main": "dist/resource.min.js",
|
|
5
|
+
"version": "2.0.1",
|
|
6
|
+
"author": "Guo.Yan <luv02@vip.qq.com>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"private": false,
|
|
9
|
+
"scripts": {
|
|
10
|
+
"dev": "cross-env NODE_ENV=development webpack-dev-server --hot --port 7000",
|
|
11
|
+
"build": "cross-env NODE_ENV=production webpack --progress"
|
|
12
|
+
},
|
|
13
|
+
"browserslist": [
|
|
14
|
+
"> 1%",
|
|
15
|
+
"last 2 versions",
|
|
16
|
+
"not ie <= 8"
|
|
17
|
+
],
|
|
18
|
+
"files": [],
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"babel-core": "^6.26.0",
|
|
21
|
+
"babel-loader": "^7.1.2",
|
|
22
|
+
"babel-preset-env": "^1.6.0",
|
|
23
|
+
"babel-preset-stage-3": "^6.24.1",
|
|
24
|
+
"clean-webpack-plugin": "^4.0.0-alpha.0",
|
|
25
|
+
"cross-env": "^5.0.5",
|
|
26
|
+
"css-loader": "^0.28.7",
|
|
27
|
+
"uglifyjs-webpack-plugin": "^2.2.0",
|
|
28
|
+
"webpack": "^4.23.1",
|
|
29
|
+
"webpack-cli": "^4.9.1",
|
|
30
|
+
"webpack-dev-server": "^2.9.1"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"mqtt": "^4.3.7"
|
|
34
|
+
}
|
|
35
|
+
}
|