@das-fed/upf-utils 6.4.0-dev.216 → 6.4.0-dev.218

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.
Files changed (109) hide show
  1. package/api-services/es5.js +1908 -1849
  2. package/api-services/index.js +1428 -1428
  3. package/api-services/index.js.gz +0 -0
  4. package/api-services/modules/app-manage/es5.js +1640 -1594
  5. package/api-services/modules/app-manage/index.js +1299 -1318
  6. package/api-services/modules/app-manage/index.js.gz +0 -0
  7. package/api-services/modules/authentication/es5.js +1640 -1594
  8. package/api-services/modules/authentication/index.js +1299 -1318
  9. package/api-services/modules/authentication/index.js.gz +0 -0
  10. package/api-services/modules/bems/es5.js +1471 -1416
  11. package/api-services/modules/bems/index.js +1177 -1182
  12. package/api-services/modules/bems/index.js.gz +0 -0
  13. package/api-services/modules/contract/es5.js +1640 -1594
  14. package/api-services/modules/contract/index.js +1299 -1318
  15. package/api-services/modules/contract/index.js.gz +0 -0
  16. package/api-services/modules/duty-manage/es5.js +1645 -1599
  17. package/api-services/modules/duty-manage/index.js +1304 -1323
  18. package/api-services/modules/duty-manage/index.js.gz +0 -0
  19. package/api-services/modules/enterpriseright/es5.js +1392 -1334
  20. package/api-services/modules/enterpriseright/index.js +1107 -1108
  21. package/api-services/modules/enterpriseright/index.js.gz +0 -0
  22. package/api-services/modules/es5.js +1574 -1515
  23. package/api-services/modules/file/es5.js +1728 -1681
  24. package/api-services/modules/file/index.js +1289 -1307
  25. package/api-services/modules/file/index.js.gz +0 -0
  26. package/api-services/modules/gateway-edge/es5.js +1640 -1594
  27. package/api-services/modules/gateway-edge/index.js +1299 -1318
  28. package/api-services/modules/gateway-edge/index.js.gz +0 -0
  29. package/api-services/modules/index.js +1079 -1079
  30. package/api-services/modules/index.js.gz +0 -0
  31. package/api-services/modules/iot/es5.js +1453 -1407
  32. package/api-services/modules/iot/index.js +1114 -1133
  33. package/api-services/modules/iot/index.js.gz +0 -0
  34. package/api-services/modules/justauth/es5.js +1410 -1354
  35. package/api-services/modules/justauth/index.js +1107 -1112
  36. package/api-services/modules/justauth/index.js.gz +0 -0
  37. package/api-services/modules/knowledge/es5.js +1617 -1547
  38. package/api-services/modules/knowledge/index.js +1291 -1274
  39. package/api-services/modules/knowledge/index.js.gz +0 -0
  40. package/api-services/modules/link/es5.js +1617 -1547
  41. package/api-services/modules/link/index.js +1293 -1276
  42. package/api-services/modules/link/index.js.gz +0 -0
  43. package/api-services/modules/permission/es5.js +1597 -1548
  44. package/api-services/modules/permission/index.js +1268 -1283
  45. package/api-services/modules/permission/index.js.gz +0 -0
  46. package/api-services/modules/platformManage/es5.js +1399 -1341
  47. package/api-services/modules/platformManage/index.js +1110 -1111
  48. package/api-services/modules/platformManage/index.js.gz +0 -0
  49. package/api-services/modules/portal/es5.js +1617 -1547
  50. package/api-services/modules/portal/index.js +1293 -1276
  51. package/api-services/modules/portal/index.js.gz +0 -0
  52. package/api-services/modules/space-manage/es5.js +1392 -1334
  53. package/api-services/modules/space-manage/index.js +1107 -1108
  54. package/api-services/modules/space-manage/index.js.gz +0 -0
  55. package/api-services/modules/super-admin/es5.js +1653 -1607
  56. package/api-services/modules/super-admin/index.js +1310 -1329
  57. package/api-services/modules/super-admin/index.js.gz +0 -0
  58. package/api-services/modules/supplier/es5.js +1455 -1397
  59. package/api-services/modules/supplier/index.js +1160 -1161
  60. package/api-services/modules/supplier/index.js.gz +0 -0
  61. package/api-services/modules/supplychain-manage/es5.js +1402 -1344
  62. package/api-services/modules/supplychain-manage/index.js +1115 -1116
  63. package/api-services/modules/supplychain-manage/index.js.gz +0 -0
  64. package/api-services/modules/systemConfiguration/es5.js +1640 -1594
  65. package/api-services/modules/systemConfiguration/index.js +1299 -1318
  66. package/api-services/modules/systemConfiguration/index.js.gz +0 -0
  67. package/api-services/modules/tool/es5.js +1640 -1594
  68. package/api-services/modules/tool/index.js +1299 -1318
  69. package/api-services/modules/tool/index.js.gz +0 -0
  70. package/api-services/src/create-service/es5.js +1638 -1592
  71. package/api-services/src/create-service/index.js +1298 -1317
  72. package/api-services/src/create-service/index.js.gz +0 -0
  73. package/common-info/es5.js +9 -11
  74. package/common-info/getInfoFromUrl/es5.js +40 -40
  75. package/common-info/getInfoFromUrl/index.js +36 -36
  76. package/common-info/getInfoFromUrl/index.js.gz +0 -0
  77. package/common-info/index.js +13 -17
  78. package/common-info/index.js.gz +0 -0
  79. package/common-info/set-personal-info/es5.js +775 -681
  80. package/common-info/set-personal-info/index.js +670 -598
  81. package/common-info/set-personal-info/index.js.gz +0 -0
  82. package/common-tools/extract-file-name/es5.js +2 -2
  83. package/common-tools/extract-file-name/index.js +2 -7
  84. package/common-tools/extract-file-name/index.js.gz +0 -0
  85. package/common-tools/handle-data/es5.js +111 -118
  86. package/common-tools/handle-data/index.js +86 -89
  87. package/common-tools/handle-data/index.js.gz +0 -0
  88. package/create-api-service/check-token/es5.js +125 -127
  89. package/create-api-service/check-token/index.js +118 -123
  90. package/create-api-service/check-token/index.js.gz +0 -0
  91. package/create-api-service/es5.js +1617 -1547
  92. package/create-api-service/index.js +1293 -1276
  93. package/create-api-service/index.js.gz +0 -0
  94. package/create-api-service/sso/es5.js +317 -325
  95. package/create-api-service/sso/index.js +273 -279
  96. package/create-api-service/sso/index.js.gz +0 -0
  97. package/curring-http/es5.js +2 -2
  98. package/curring-http/index.js +2 -7
  99. package/curring-http/index.js.gz +0 -0
  100. package/front-end/i18n/front-end-page/dasutils_en-US.js +20 -1
  101. package/front-end/i18n/front-end-page/dasutils_zh-CN.js +19 -1
  102. package/front-end/i18n/front-end-page/dasutils_zh-MO.js +19 -1
  103. package/package.json +4 -4
  104. package/pinyin-first-character/es5.js +1 -1
  105. package/pinyin-first-character/index.js +1 -1
  106. package/pinyin-first-character/index.js.gz +0 -0
  107. package/webSocket-service/es5.js +41 -53
  108. package/webSocket-service/index.js +40 -50
  109. package/webSocket-service/index.js.gz +0 -0
Binary file
@@ -1795,12 +1795,12 @@ pe.transitional = function (t, n, r) {
1795
1795
  }
1796
1796
  return function (s, i, c) {
1797
1797
  if (t === false) throw new b(o(i, " has been removed" + (n ? " in " + n : "")), b.ERR_DEPRECATED);
1798
- return n && !et[i] && (et[i] = true, console.warn(o(i, " has been deprecated since v" + n + " and will be removed in the near future"))), t ? t(s, i, c) : true;
1798
+ return n && !et[i] && (et[i] = true), t ? t(s, i, c) : true;
1799
1799
  };
1800
1800
  };
1801
1801
  pe.spelling = function (t) {
1802
1802
  return function (n, r) {
1803
- return console.warn("".concat(r, " is likely a misspelling of ").concat(t)), true;
1803
+ return true;
1804
1804
  };
1805
1805
  };
1806
1806
  function vr(e, t, n) {
@@ -1351,16 +1351,11 @@ pe.transitional = function(t, n, r) {
1351
1351
  o(i, " has been removed" + (n ? " in " + n : "")),
1352
1352
  b.ERR_DEPRECATED
1353
1353
  );
1354
- return n && !et[i] && (et[i] = !0, console.warn(
1355
- o(
1356
- i,
1357
- " has been deprecated since v" + n + " and will be removed in the near future"
1358
- )
1359
- )), t ? t(s, i, c) : !0;
1354
+ return n && !et[i] && (et[i] = !0), t ? t(s, i, c) : !0;
1360
1355
  };
1361
1356
  };
1362
1357
  pe.spelling = function(t) {
1363
- return (n, r) => (console.warn(`${r} is likely a misspelling of ${t}`), !0);
1358
+ return (n, r) => !0;
1364
1359
  };
1365
1360
  function vr(e, t, n) {
1366
1361
  if (typeof e != "object")
Binary file
@@ -1 +1,20 @@
1
- export default {};
1
+ export default {
2
+ "导入进度": "Import Progress",
3
+ "上传失败": "Uploaded Failed",
4
+ "导出进度": "Export Progress",
5
+ "导出成功": "Exported Successfully",
6
+ "导入成功": "Imported Successfully",
7
+ "导出失败": "Exported Failed",
8
+ "导入失败": "Imported Failed",
9
+ "部分导出失败": "Partial exported failed",
10
+ "部分导入失败": "Partial imported failed",
11
+ "部分数据校验不通过,请下载附件并修改,重新导入!":
12
+ "Some data failed to pass the verification. Please download the attachment, make modifications and import it again!",
13
+ "参数校验错误": "Parameter Validation Error",
14
+ "接口地址未找到": "Api endpoint not found",
15
+ "服务器内部错误": "Internal Server Error",
16
+ "解析错误": "Parsing Error",
17
+ "请求配置异常": "Request Configuration Error",
18
+ "网络异常,请检查您的网络情况":
19
+ "Network error, please check your network status",
20
+ };
@@ -1 +1,19 @@
1
- export default {};
1
+ export default {
2
+ "导入进度": "导入进度",
3
+ "上传失败": "上传失败",
4
+ "导出进度": "导出进度",
5
+ "导出成功": "导出成功",
6
+ "导入成功": "导入成功",
7
+ "导出失败": "导出失败",
8
+ "导入失败": "导入失败",
9
+ "部分导出失败": "部分导出失败",
10
+ "部分导入失败": "部分导入失败",
11
+ "部分数据校验不通过,请下载附件并修改,重新导入!":
12
+ "部分数据校验不通过,请下载附件并修改,重新导入!",
13
+ "参数校验错误": "参数校验错误",
14
+ "接口地址未找到": "接口地址未找到",
15
+ "服务器内部错误": "服务器内部错误",
16
+ "解析错误": "解析错误",
17
+ "请求配置异常": "请求配置异常",
18
+ "网络异常,请检查您的网络情况": "网络异常,请检查您的网络情况",
19
+ };
@@ -1 +1,19 @@
1
- export default {};
1
+ export default {
2
+ "导入进度": "導入進度",
3
+ "上传失败": "上傳失敗",
4
+ "导出进度": "導出進度",
5
+ "导出成功": "導出成功",
6
+ "导入成功": "導入成功",
7
+ "导出失败": "導出失敗",
8
+ "导入失败": "導入失敗",
9
+ "部分导出失败": "部分導出失敗",
10
+ "部分导入失败": "部分導入失敗",
11
+ "部分数据校验不通过,请下载附件并修改,重新导入!":
12
+ "部分數據校驗不通過,請下載附件並修改,重新導入!",
13
+ "参数校验错误": "參數校驗錯誤",
14
+ "接口地址未找到": "接口地址未找到",
15
+ "服务器内部错误": "服務器內部錯誤",
16
+ "解析错误": "解析錯誤",
17
+ "请求配置异常": "請求配置異常",
18
+ "网络异常,请检查您的网络情况": "網絡異常,請檢查您的網絡情況",
19
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@das-fed/upf-utils",
3
- "version": "6.4.0-dev.216",
3
+ "version": "6.4.0-dev.218",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -9,7 +9,7 @@
9
9
  "license": "ISC",
10
10
  "dependencies": {
11
11
  "@antv/x6": "^2.18.1",
12
- "@das-fed/upf-utils": "6.4.0-dev.216",
12
+ "@das-fed/upf-utils": "6.4.0-dev.218",
13
13
  "@vue/shared": "^3.4.21",
14
14
  "@vueuse/core": "^9.6.0",
15
15
  "axios": "^1.6.7",
@@ -22,8 +22,8 @@
22
22
  },
23
23
  "devDependencies": {
24
24
  "@babel/preset-env": "7.26.0",
25
- "@das-fed/upf-cli": "6.4.0-dev.216",
26
- "@das-fed/upf-web": "6.4.0-dev.216",
25
+ "@das-fed/upf-cli": "6.4.0-dev.218",
26
+ "@das-fed/upf-web": "6.4.0-dev.218",
27
27
  "@rollup/plugin-babel": "6.0.4",
28
28
  "@types/js-cookie": "^3.0.6",
29
29
  "@types/lodash-es": "^4.17.12",
@@ -9141,7 +9141,7 @@ var mn = new F(),
9141
9141
  }), g.join(" ");
9142
9142
  },
9143
9143
  Sn = function Sn(n) {
9144
- return typeof n != "string" ? (console.error("The first param of pinyin is error: " + n + ' is not assignable to type "string".'), false) : true;
9144
+ return typeof n == "string";
9145
9145
  };
9146
9146
  function p(n, i) {
9147
9147
  return i instanceof RegExp ? i.test(n) : true;
@@ -23799,7 +23799,7 @@ const mn = new F(), pn = () => mn, e = (n) => {
23799
23799
  return n.split(" ").forEach((u) => {
23800
23800
  g.push(i ? u[0] : u);
23801
23801
  }), g.join(" ");
23802
- }, Sn = (n) => typeof n != "string" ? (console.error("The first param of pinyin is error: " + n + ' is not assignable to type "string".'), !1) : !0;
23802
+ }, Sn = (n) => typeof n == "string";
23803
23803
  function p(n, i) {
23804
23804
  return i instanceof RegExp ? i.test(n) : !0;
23805
23805
  }
Binary file
@@ -17,81 +17,74 @@ var c = config.getConfig(),
17
17
  var s = "";
18
18
  return c.baseURL ? s = c.baseURL : s = location.origin, s.replace("https://", "wss://").replace("http://", "ws://") || "";
19
19
  },
20
- b = function b(s) {
21
- var e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
22
- var t = commonTools.objectToUrlparams(e);
23
- return t ? h() + s + "?".concat(t) : h() + s;
20
+ w = function w(s) {
21
+ var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
22
+ var e = commonTools.objectToUrlparams(t);
23
+ return e ? h() + s + "?".concat(e) : h() + s;
24
24
  },
25
- g = function g(s, e) {
26
- return Math.floor(Math.random() * (e - s + 1)) + s;
25
+ p = function p(s, t) {
26
+ return Math.floor(Math.random() * (t - s + 1)) + s;
27
27
  };
28
28
  var R = /*#__PURE__*/function () {
29
29
  function R(_ref) {
30
- var e = _ref.url,
30
+ var t = _ref.url,
31
31
  _ref$params = _ref.params,
32
- t = _ref$params === void 0 ? {} : _ref$params,
33
- n = _ref.opened,
34
- r = _ref.close,
35
- o = _ref.error,
36
- i = _ref.message,
37
- l = _ref.ifReconnect,
38
- a = _ref.reconnectNum,
32
+ e = _ref$params === void 0 ? {} : _ref$params,
33
+ r = _ref.opened,
34
+ n = _ref.close,
35
+ i = _ref.error,
36
+ o = _ref.message,
37
+ a = _ref.ifReconnect,
38
+ l = _ref.reconnectNum,
39
39
  u = _ref.reconnectWhenClose;
40
40
  _classCallCheck(this, R);
41
- if (this.$ws = null, this.url = "", this.params = {}, this.lockReturn = false, this.startTime = 0, this.heartbeatInterval = null, this.ifReconnect = true, this.reconnectId = null, this.reconnectNum = 3, this.reconnectWhenClose = false, this.currentReconnectNum = 0, this.$ws = null, this.startTime = 0, this.heartbeatInterval = null, this.ifReconnect = l !== null && l !== void 0 ? l : true, this.reconnectNum = a !== null && a !== void 0 ? a : 3, this.reconnectWhenClose = u !== null && u !== void 0 ? u : false, this.lockReturn = false, this.currentReconnectNum = 0, this.reconnectId = null, this.params = _objectSpread(_objectSpread({}, t), {}, {
41
+ if (this.$ws = null, this.url = "", this.params = {}, this.lockReturn = false, this.startTime = 0, this.heartbeatInterval = null, this.ifReconnect = true, this.reconnectId = null, this.reconnectNum = 3, this.reconnectWhenClose = false, this.currentReconnectNum = 0, this.$ws = null, this.startTime = 0, this.heartbeatInterval = null, this.ifReconnect = a !== null && a !== void 0 ? a : true, this.reconnectNum = l !== null && l !== void 0 ? l : 3, this.reconnectWhenClose = u !== null && u !== void 0 ? u : false, this.lockReturn = false, this.currentReconnectNum = 0, this.reconnectId = null, this.params = _objectSpread(_objectSpread({}, e), {}, {
42
42
  access_token: commonInfo.getToken()
43
- }), e) this.url = e;else throw new Error("url is required");
44
- n && (this.opened = n), r && (this.close = r), o && (this.error = o), i && (this.afterMsg = i), this.initWebSocket();
43
+ }), t) this.url = t;else throw new Error("url is required");
44
+ r && (this.opened = r), n && (this.close = n), i && (this.error = i), o && (this.afterMsg = o), this.initWebSocket();
45
45
  }
46
46
  return _createClass(R, [{
47
47
  key: "initWebSocket",
48
48
  value: function initWebSocket() {
49
49
  var _this = this;
50
50
  if ((typeof WebSocket === "undefined" ? "undefined" : _typeof(WebSocket)) > "u") throw new Error("您的浏览器不支持websocket");
51
- var e = b(this.url, this.params);
52
- this.$ws = new WebSocket(e), this.$ws.onopen = function () {
51
+ var t = w(this.url, this.params);
52
+ this.$ws = new WebSocket(t), this.$ws.onopen = function () {
53
53
  _this.open();
54
- }, this.$ws.onclose = function (t) {
55
- _this.close(t);
56
- }, this.$ws.onmessage = function (t) {
57
- _this.message(t);
58
- }, this.$ws.onerror = function (t) {
59
- _this.error(t);
54
+ }, this.$ws.onclose = function (e) {
55
+ _this.close(e);
56
+ }, this.$ws.onmessage = function (e) {
57
+ _this.message(e);
58
+ }, this.$ws.onerror = function (e) {
59
+ _this.error(e);
60
60
  };
61
61
  }
62
62
  }, {
63
63
  key: "open",
64
64
  value: function open() {
65
- this.currentReconnectNum = 0, this.startTime = (/* @__PURE__ */new Date()).getTime(), this.opened(this.$ws), this.startHeartbeat(), console.log(this.url + " =>websocket连接成功,可以开始通讯");
65
+ this.currentReconnectNum = 0, this.startTime = (/* @__PURE__ */new Date()).getTime(), this.opened(this.$ws), this.startHeartbeat();
66
66
  }
67
67
  }, {
68
68
  key: "opened",
69
- value: function opened(e) {
70
- console.log(this.url + " =>websocket连接已打开:", e);
71
- }
69
+ value: function opened(t) {}
72
70
  }, {
73
71
  key: "close",
74
- value: function close(e) {
75
- if (this.$ws.readyState === WebSocket.CLOSED) {
76
- var t = (/* @__PURE__ */new Date()).getTime();
77
- this.reconnectWhenClose && this.reconnect(), clearInterval(this.heartbeatInterval), console.log("".concat(this.url, "=>WebSocket\u8FDE\u63A5\u5DF2\u7ECF\u5173\u95ED,\u8FDE\u63A5\u603B\u65F6\u957F: ").concat(t - this.startTime, "ms"));
78
- }
72
+ value: function close(t) {
73
+ this.$ws.readyState === WebSocket.CLOSED && ((/* @__PURE__ */new Date()).getTime(), this.reconnectWhenClose && this.reconnect(), clearInterval(this.heartbeatInterval));
79
74
  }
80
75
  }, {
81
76
  key: "message",
82
- value: function message(e) {
83
- var t = _typeof(e.data) == "object" ? e.data : JSON.parse(e.data);
84
- this.afterMsg(t);
77
+ value: function message(t) {
78
+ var e = _typeof(t.data) == "object" ? t.data : JSON.parse(t.data);
79
+ this.afterMsg(e);
85
80
  }
86
81
  }, {
87
82
  key: "afterMsg",
88
- value: function afterMsg(e) {
89
- console.log(this.url + " =>接收到websocket的消息:", e);
90
- }
83
+ value: function afterMsg(t) {}
91
84
  }, {
92
85
  key: "error",
93
- value: function error(e) {
94
- return this.ifReconnect && this.reconnect(), e;
86
+ value: function error(t) {
87
+ return this.ifReconnect && this.reconnect(), t;
95
88
  }
96
89
  /** websocket重连 */
97
90
  }, {
@@ -105,13 +98,9 @@ var R = /*#__PURE__*/function () {
105
98
  /** 发送消息给服务器 */
106
99
  }, {
107
100
  key: "send",
108
- value: function send(e) {
109
- var t;
110
- if (((t = this.$ws) == null ? undefined : t.readyState) !== WebSocket.OPEN) {
111
- console.log(this.url + "=>websocket连接未建立,还不能发送消息");
112
- return;
113
- }
114
- this.$ws.send(e);
101
+ value: function send(t) {
102
+ var e;
103
+ ((e = this.$ws) == null ? undefined : e.readyState) === WebSocket.OPEN && this.$ws.send(t);
115
104
  }
116
105
  // 启动心跳检测==>30s-5分钟内随机发一次心跳保持会话(时间区间内随机是为了降低突增流量的概率)
117
106
  }, {
@@ -119,15 +108,14 @@ var R = /*#__PURE__*/function () {
119
108
  value: function startHeartbeat() {
120
109
  var _this3 = this;
121
110
  this.heartbeatInterval = setInterval(function () {
122
- var e = "";
123
- _this3.send(e), console.log(_this3.url + "=>心跳检测发送消息:", e);
124
- }, g(3e4, 3e5));
111
+ _this3.send("");
112
+ }, p(3e4, 3e5));
125
113
  }
126
114
  /** 断开连接 */
127
115
  }, {
128
116
  key: "disconnect",
129
117
  value: function disconnect() {
130
- this.$ws.close(), console.log(this.url + " =>主动断开websocket连接");
118
+ this.$ws.close();
131
119
  }
132
120
  }]);
133
121
  }();
@@ -1,65 +1,60 @@
1
1
  import { getConfig as m } from "@das-fed/upf-utils/config";
2
2
  import { getToken as f } from "@das-fed/upf-utils/common-info";
3
- import { objectToUrlparams as w } from "@das-fed/upf-utils/common-tools";
3
+ import { objectToUrlparams as d } from "@das-fed/upf-utils/common-tools";
4
4
  const c = m(), h = () => {
5
5
  let s = "";
6
6
  return c.baseURL ? s = c.baseURL : s = location.origin, s.replace("https://", "wss://").replace("http://", "ws://") || "";
7
- }, b = (s, e = {}) => {
8
- const t = w(e);
9
- return t ? h() + s + `?${t}` : h() + s;
10
- }, g = (s, e) => Math.floor(Math.random() * (e - s + 1)) + s;
7
+ }, w = (s, t = {}) => {
8
+ const e = d(t);
9
+ return e ? h() + s + `?${e}` : h() + s;
10
+ }, p = (s, t) => Math.floor(Math.random() * (t - s + 1)) + s;
11
11
  class R {
12
12
  constructor({
13
- url: e,
14
- params: t = {},
15
- opened: n,
16
- close: r,
17
- error: o,
18
- message: i,
19
- ifReconnect: l,
20
- reconnectNum: a,
13
+ url: t,
14
+ params: e = {},
15
+ opened: r,
16
+ close: n,
17
+ error: i,
18
+ message: o,
19
+ ifReconnect: a,
20
+ reconnectNum: l,
21
21
  reconnectWhenClose: u
22
22
  }) {
23
- if (this.$ws = null, this.url = "", this.params = {}, this.lockReturn = !1, this.startTime = 0, this.heartbeatInterval = null, this.ifReconnect = !0, this.reconnectId = null, this.reconnectNum = 3, this.reconnectWhenClose = !1, this.currentReconnectNum = 0, this.$ws = null, this.startTime = 0, this.heartbeatInterval = null, this.ifReconnect = l ?? !0, this.reconnectNum = a ?? 3, this.reconnectWhenClose = u ?? !1, this.lockReturn = !1, this.currentReconnectNum = 0, this.reconnectId = null, this.params = { ...t, access_token: f() }, e)
24
- this.url = e;
23
+ if (this.$ws = null, this.url = "", this.params = {}, this.lockReturn = !1, this.startTime = 0, this.heartbeatInterval = null, this.ifReconnect = !0, this.reconnectId = null, this.reconnectNum = 3, this.reconnectWhenClose = !1, this.currentReconnectNum = 0, this.$ws = null, this.startTime = 0, this.heartbeatInterval = null, this.ifReconnect = a ?? !0, this.reconnectNum = l ?? 3, this.reconnectWhenClose = u ?? !1, this.lockReturn = !1, this.currentReconnectNum = 0, this.reconnectId = null, this.params = { ...e, access_token: f() }, t)
24
+ this.url = t;
25
25
  else
26
26
  throw new Error("url is required");
27
- n && (this.opened = n), r && (this.close = r), o && (this.error = o), i && (this.afterMsg = i), this.initWebSocket();
27
+ r && (this.opened = r), n && (this.close = n), i && (this.error = i), o && (this.afterMsg = o), this.initWebSocket();
28
28
  }
29
29
  initWebSocket() {
30
30
  if (typeof WebSocket > "u") throw new Error("您的浏览器不支持websocket");
31
- const e = b(this.url, this.params);
32
- this.$ws = new WebSocket(e), this.$ws.onopen = () => {
31
+ const t = w(this.url, this.params);
32
+ this.$ws = new WebSocket(t), this.$ws.onopen = () => {
33
33
  this.open();
34
- }, this.$ws.onclose = (t) => {
35
- this.close(t);
36
- }, this.$ws.onmessage = (t) => {
37
- this.message(t);
38
- }, this.$ws.onerror = (t) => {
39
- this.error(t);
34
+ }, this.$ws.onclose = (e) => {
35
+ this.close(e);
36
+ }, this.$ws.onmessage = (e) => {
37
+ this.message(e);
38
+ }, this.$ws.onerror = (e) => {
39
+ this.error(e);
40
40
  };
41
41
  }
42
42
  open() {
43
- this.currentReconnectNum = 0, this.startTime = (/* @__PURE__ */ new Date()).getTime(), this.opened(this.$ws), this.startHeartbeat(), console.log(this.url + " =>websocket连接成功,可以开始通讯");
43
+ this.currentReconnectNum = 0, this.startTime = (/* @__PURE__ */ new Date()).getTime(), this.opened(this.$ws), this.startHeartbeat();
44
44
  }
45
- opened(e) {
46
- console.log(this.url + " =>websocket连接已打开:", e);
45
+ opened(t) {
47
46
  }
48
- close(e) {
49
- if (this.$ws.readyState === WebSocket.CLOSED) {
50
- const t = (/* @__PURE__ */ new Date()).getTime();
51
- this.reconnectWhenClose && this.reconnect(), clearInterval(this.heartbeatInterval), console.log(`${this.url}=>WebSocket连接已经关闭,连接总时长: ${t - this.startTime}ms`);
52
- }
47
+ close(t) {
48
+ this.$ws.readyState === WebSocket.CLOSED && ((/* @__PURE__ */ new Date()).getTime(), this.reconnectWhenClose && this.reconnect(), clearInterval(this.heartbeatInterval));
53
49
  }
54
- message(e) {
55
- const t = typeof e.data == "object" ? e.data : JSON.parse(e.data);
56
- this.afterMsg(t);
50
+ message(t) {
51
+ const e = typeof t.data == "object" ? t.data : JSON.parse(t.data);
52
+ this.afterMsg(e);
57
53
  }
58
- afterMsg(e) {
59
- console.log(this.url + " =>接收到websocket的消息:", e);
54
+ afterMsg(t) {
60
55
  }
61
- error(e) {
62
- return this.ifReconnect && this.reconnect(), e;
56
+ error(t) {
57
+ return this.ifReconnect && this.reconnect(), t;
63
58
  }
64
59
  /** websocket重连 */
65
60
  reconnect() {
@@ -68,24 +63,19 @@ class R {
68
63
  }, 3e3)));
69
64
  }
70
65
  /** 发送消息给服务器 */
71
- send(e) {
72
- var t;
73
- if (((t = this.$ws) == null ? void 0 : t.readyState) !== WebSocket.OPEN) {
74
- console.log(this.url + "=>websocket连接未建立,还不能发送消息");
75
- return;
76
- }
77
- this.$ws.send(e);
66
+ send(t) {
67
+ var e;
68
+ ((e = this.$ws) == null ? void 0 : e.readyState) === WebSocket.OPEN && this.$ws.send(t);
78
69
  }
79
70
  // 启动心跳检测==>30s-5分钟内随机发一次心跳保持会话(时间区间内随机是为了降低突增流量的概率)
80
71
  startHeartbeat() {
81
72
  this.heartbeatInterval = setInterval(() => {
82
- const e = "";
83
- this.send(e), console.log(this.url + "=>心跳检测发送消息:", e);
84
- }, g(3e4, 3e5));
73
+ this.send("");
74
+ }, p(3e4, 3e5));
85
75
  }
86
76
  /** 断开连接 */
87
77
  disconnect() {
88
- this.$ws.close(), console.log(this.url + " =>主动断开websocket连接");
78
+ this.$ws.close();
89
79
  }
90
80
  }
91
81
  export {
Binary file