ztxkutils 2.7.10 → 2.7.13

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/request.d.ts CHANGED
@@ -5,5 +5,6 @@ import { AxiosRequestConfig } from 'axios';
5
5
  export interface IOptions extends AxiosRequestConfig {
6
6
  isFormData?: boolean;
7
7
  encryptionType?: 'aes' | 'des' | boolean;
8
+ isTimeoutMessage?: boolean;
8
9
  }
9
10
  export default function request(myOptions: IOptions): any;
package/dist/request.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import './tslib.es6-f9459658.js';
2
2
  import 'axios';
3
3
  import 'ztxkui';
4
- export { a as default } from './request-5b825e2e.js';
4
+ export { a as default } from './request-5df1ec76.js';
5
5
  import './authority-fad2028d.js';
6
6
  import './crypto-c481f616.js';
7
7
  import 'crypto';
@@ -17,6 +17,8 @@ declare class StompClient {
17
17
  client: any;
18
18
  isClient: any;
19
19
  clearIsClient: any;
20
+ clearIsClientNo: any;
21
+ clearIsClientYes: any;
20
22
  subscriptions: any;
21
23
  subscriptionsFn: any;
22
24
  successCallbacks: any;
@@ -6,6 +6,8 @@ var StompClient = /** @class */ (function () {
6
6
  function StompClient(connectWsConfig) {
7
7
  this.isClient = false; // 是否连接上了
8
8
  this.clearIsClient = null;
9
+ this.clearIsClientNo = null; // 连接10秒内未建立,重新连接
10
+ this.clearIsClientYes = null; // 连接已建立重新连接
9
11
  this.subscriptions = {}; // 连接通道的返回值存储对象
10
12
  this.subscriptionsFn = {}; // 连接通道的函数存储对象
11
13
  this.successCallbacks = {}; // 连接成功执行的回调存储对象
@@ -30,31 +32,41 @@ var StompClient = /** @class */ (function () {
30
32
  clearTimeout(this.clearIsClient);
31
33
  this.clearIsClient = null;
32
34
  }
33
- if (!this.clearIsClient) {
34
- this.clearIsClient = setTimeout(function () {
35
- _this.clearIsClient = null;
36
- if (!_this.isClient) {
37
- console.log("\u8FDE\u63A5\u5DF2\u53D1\u8D77\uFF0C\u4F46\u662F10\u79D2\u540E\u672A\u6210\u529F\u5EFA\u7ACB\u8FDE\u63A5\uFF0C\u624B\u52A8\u65AD\u5F00\u91CD\u8FDE!");
38
- try {
39
- _this.client.disconnect(function () {
40
- // const timeInterval =
41
- // Math.ceil(this.reconnectionNum / 5) *
42
- // (this.connectWsConfig.reconnectionTime ?? 3000);
43
- });
44
- }
45
- catch (err) {
46
- console.log('---关闭出错---', err);
47
- }
48
- _this.client = null;
49
- _this.reconnectionNum++;
50
- var timeInterval = 3000;
51
- console.log("\u7B2C" + _this.reconnectionNum + "\u6B21\u91CD\u8FDE\uFF01");
52
- setTimeout(function () {
53
- _this.init();
54
- }, timeInterval > 10000 ? 10000 : timeInterval);
55
- }
56
- }, 20000);
35
+ if (this.clearIsClientNo) {
36
+ clearTimeout(this.clearIsClientNo);
37
+ this.clearIsClientNo = null;
38
+ }
39
+ if (this.clearIsClientYes) {
40
+ clearTimeout(this.clearIsClientYes);
41
+ this.clearIsClientYes = null;
57
42
  }
43
+ this.clearIsClient = setTimeout(function () {
44
+ _this.clearIsClient = null;
45
+ if (!_this.isClient) {
46
+ console.log("\u8FDE\u63A5\u5DF2\u53D1\u8D77\uFF0C\u4F46\u662F10\u79D2\u540E\u672A\u6210\u529F\u5EFA\u7ACB\u8FDE\u63A5\uFF0C\u624B\u52A8\u65AD\u5F00\u91CD\u8FDE!");
47
+ try {
48
+ _this.client.disconnect(function () {
49
+ // const timeInterval =
50
+ // Math.ceil(this.reconnectionNum / 5) *
51
+ // (this.connectWsConfig.reconnectionTime ?? 3000);
52
+ });
53
+ }
54
+ catch (err) {
55
+ console.log('---连接未建立的关闭出错---', err);
56
+ }
57
+ _this.client = null;
58
+ _this.reconnectionNum++;
59
+ var timeInterval = 3000;
60
+ console.log("---\u7B2C" + _this.reconnectionNum + "\u6B21\u91CD\u8FDE\uFF01---");
61
+ if (_this.clearIsClientNo) {
62
+ clearTimeout(_this.clearIsClientNo);
63
+ _this.clearIsClientNo = null;
64
+ }
65
+ _this.clearIsClientNo = setTimeout(function () {
66
+ _this.init();
67
+ }, timeInterval > 10000 ? 10000 : timeInterval);
68
+ }
69
+ }, 10000);
58
70
  // 拦截输出的一大堆垃圾信息
59
71
  this.client.debug = function (str) {
60
72
  if (_this.connectWsConfig.debug) {
@@ -74,6 +86,14 @@ var StompClient = /** @class */ (function () {
74
86
  clearTimeout(_this.clearIsClient);
75
87
  _this.clearIsClient = null;
76
88
  }
89
+ if (_this.clearIsClientNo) {
90
+ clearTimeout(_this.clearIsClientNo);
91
+ _this.clearIsClientNo = null;
92
+ }
93
+ if (_this.clearIsClientYes) {
94
+ clearTimeout(_this.clearIsClientYes);
95
+ _this.clearIsClientYes = null;
96
+ }
77
97
  _this.reconnectionNum = 0;
78
98
  console.log('---------连接成功--------');
79
99
  // 连接成功后,将当前已注册的,未执行的 连接通道 连接
@@ -115,6 +135,14 @@ var StompClient = /** @class */ (function () {
115
135
  clearTimeout(_this.clearIsClient);
116
136
  _this.clearIsClient = null;
117
137
  }
138
+ if (_this.clearIsClientNo) {
139
+ clearTimeout(_this.clearIsClientNo);
140
+ _this.clearIsClientNo = null;
141
+ }
142
+ if (_this.clearIsClientYes) {
143
+ clearTimeout(_this.clearIsClientYes);
144
+ _this.clearIsClientYes = null;
145
+ }
118
146
  // this.errorCallback(err);
119
147
  // 连接失败后,将当前已注册的 连接通道 全部置为未执行状态
120
148
  var subscriptionsFnKeys = Object.keys(_this.subscriptionsFn);
@@ -143,18 +171,26 @@ var StompClient = /** @class */ (function () {
143
171
  }
144
172
  // 重连逻辑, 默认3秒后重连
145
173
  // 重连间隔,每隔5秒递增,超过最大间隔时间后,取最大间隔时间重连
146
- _this.client.disconnect(function () {
147
- _this.client = null;
148
- _this.reconnectionNum++;
149
- // const timeInterval =
150
- // Math.ceil(this.reconnectionNum / 5) *
151
- // (this.connectWsConfig.reconnectionTime ?? 3000);
152
- var timeInterval = 3000;
153
- console.log("\u7B2C" + _this.reconnectionNum + "\u6B21\u91CD\u8FDE\uFF01");
154
- setTimeout(function () {
155
- _this.init();
156
- }, timeInterval);
157
- });
174
+ try {
175
+ _this.client.disconnect(function () {
176
+ // const timeInterval =
177
+ // Math.ceil(this.reconnectionNum / 5) *
178
+ // (this.connectWsConfig.reconnectionTime ?? 3000);
179
+ });
180
+ }
181
+ catch (err) {
182
+ console.log('---连接已建立的关闭出错---', err);
183
+ }
184
+ _this.client = null;
185
+ _this.reconnectionNum++;
186
+ // const timeInterval =
187
+ // Math.ceil(this.reconnectionNum / 5) *
188
+ // (this.connectWsConfig.reconnectionTime ?? 3000);
189
+ var timeInterval = 3000;
190
+ console.log("---\u7B2C" + _this.reconnectionNum + "\u6B21\u91CD\u8FDE\uFF01");
191
+ _this.clearIsClientYes = setTimeout(function () {
192
+ _this.init();
193
+ }, timeInterval);
158
194
  });
159
195
  };
160
196
  // 订阅连接成功回调
@@ -214,11 +250,17 @@ var StompClient = /** @class */ (function () {
214
250
  var _this = this;
215
251
  this.isInit = false;
216
252
  return new Promise(function (resolve, reject) {
217
- _this.client.disconnect(function () {
218
- _this.client = null;
253
+ try {
254
+ _this.client.disconnect(function () {
255
+ _this.client = null;
256
+ callback && callback();
257
+ resolve(null);
258
+ });
259
+ }
260
+ catch (err) {
219
261
  callback && callback();
220
262
  resolve(null);
221
- });
263
+ }
222
264
  });
223
265
  };
224
266
  // 发送消息
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkutils",
3
- "version": "2.7.10",
3
+ "version": "2.7.13",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",