ztxkutils 2.7.13 → 2.7.16

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/print.d.ts CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @author 陈亚雄
3
+ * @description 打印相关方法
4
+ */
5
+ import { jsPDF } from 'jspdf';
1
6
  /**
2
7
  * 添加水印
3
8
  */
@@ -16,10 +21,17 @@ interface IParams {
16
21
  hiddenClassNames?: string[];
17
22
  }
18
23
  export declare function printCurrentDom({ hiddenClassNames }?: IParams): void;
19
- export declare function htmlToPdf({ pageClassName, dom, pdfName, isShowPage, }: {
24
+ export declare function htmlToPdf({ pageClassName, dom, pdfName, isShowPage, noDownload, }: {
20
25
  pageClassName?: string;
21
26
  dom: HTMLElement;
22
27
  pdfName: string;
23
28
  isShowPage?: boolean;
24
- }): Promise<void>;
29
+ noDownload?: boolean;
30
+ }): Promise<{
31
+ pdf: jsPDF;
32
+ pdfBase64: any[];
33
+ }> | Promise<{
34
+ pdf: jsPDF;
35
+ pdfBase64: string;
36
+ }>;
25
37
  export {};
package/dist/print.js CHANGED
@@ -102,12 +102,13 @@ function createPdf(canvas, pdf) {
102
102
  }
103
103
  }
104
104
  function htmlToPdf(_a) {
105
- var pageClassName = _a.pageClassName, dom = _a.dom, pdfName = _a.pdfName, isShowPage = _a.isShowPage;
105
+ var pageClassName = _a.pageClassName, dom = _a.dom, pdfName = _a.pdfName, isShowPage = _a.isShowPage, noDownload = _a.noDownload;
106
106
  var pdf = new jsPDF(undefined, 'pt', 'a4');
107
107
  var allDom = document.querySelectorAll(pageClassName ? pageClassName : '.html2canvas-container-page');
108
108
  if (allDom.length > 0 && isShowPage) {
109
109
  var allDomArray = Array.prototype.slice.call(allDom);
110
110
  var promiseAllDomArray_1 = allDomArray.map(function (dom) { return html2canvas(dom); });
111
+ var pdfBase64_1 = [];
111
112
  return (function () {
112
113
  return __awaiter(this, void 0, void 0, function () {
113
114
  var i, _i, promiseAllDomArray_2, item, canvas;
@@ -128,13 +129,19 @@ function htmlToPdf(_a) {
128
129
  if (i < promiseAllDomArray_1.length) {
129
130
  pdf.addPage();
130
131
  }
132
+ pdfBase64_1.push(pdf.output('dataurlstring'));
131
133
  _a.label = 3;
132
134
  case 3:
133
135
  _i++;
134
136
  return [3 /*break*/, 1];
135
137
  case 4:
136
- pdf.save(pdfName + ".pdf");
137
- return [2 /*return*/, Promise.resolve()];
138
+ if (!noDownload) {
139
+ pdf.save(pdfName + ".pdf");
140
+ }
141
+ return [2 /*return*/, Promise.resolve({
142
+ pdf: pdf,
143
+ pdfBase64: pdfBase64_1,
144
+ })];
138
145
  }
139
146
  });
140
147
  });
@@ -143,7 +150,13 @@ function htmlToPdf(_a) {
143
150
  else {
144
151
  return html2canvas(dom).then(function (canvas) {
145
152
  createPdf(canvas, pdf);
146
- pdf.save(pdfName + ".pdf");
153
+ if (!noDownload) {
154
+ pdf.save(pdfName + ".pdf");
155
+ }
156
+ return {
157
+ pdf: pdf,
158
+ pdfBase64: pdf.output('dataurlstring'),
159
+ };
147
160
  });
148
161
  }
149
162
  }
@@ -43,21 +43,18 @@ var StompClient = /** @class */ (function () {
43
43
  this.clearIsClient = setTimeout(function () {
44
44
  _this.clearIsClient = null;
45
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!");
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!system=" + _this.connectWsConfig.systemType);
47
47
  try {
48
48
  _this.client.disconnect(function () {
49
- // const timeInterval =
50
- // Math.ceil(this.reconnectionNum / 5) *
51
- // (this.connectWsConfig.reconnectionTime ?? 3000);
49
+ _this.client = null;
52
50
  });
53
51
  }
54
52
  catch (err) {
55
53
  console.log('---连接未建立的关闭出错---', err);
56
54
  }
57
- _this.client = null;
58
55
  _this.reconnectionNum++;
59
56
  var timeInterval = 3000;
60
- console.log("---\u7B2C" + _this.reconnectionNum + "\u6B21\u91CD\u8FDE\uFF01---");
57
+ console.log("---\u7B2C" + _this.reconnectionNum + "\u6B21\u91CD\u8FDE\uFF01time=" + Date.now() + "system=" + _this.connectWsConfig.systemType + "---");
61
58
  if (_this.clearIsClientNo) {
62
59
  clearTimeout(_this.clearIsClientNo);
63
60
  _this.clearIsClientNo = null;
@@ -95,7 +92,7 @@ var StompClient = /** @class */ (function () {
95
92
  _this.clearIsClientYes = null;
96
93
  }
97
94
  _this.reconnectionNum = 0;
98
- console.log('---------连接成功--------');
95
+ console.log("---------\u8FDE\u63A5\u6210\u529F time=" + Date.now() + " system=" + _this.connectWsConfig.systemType + " time=" + Date.now() + "--------");
99
96
  // 连接成功后,将当前已注册的,未执行的 连接通道 连接
100
97
  var subscriptionsFnKeys = Object.keys(_this.subscriptionsFn);
101
98
  if (Array.isArray(subscriptionsFnKeys)) {
@@ -128,7 +125,7 @@ var StompClient = /** @class */ (function () {
128
125
  },
129
126
  // 连接失败回调
130
127
  function (err) {
131
- console.log('---------连接失败--------');
128
+ console.log("---------\u8FDE\u63A5\u5931\u8D25 system=" + _this.connectWsConfig.systemType + " time=" + Date.now() + "--------");
132
129
  console.log(err);
133
130
  _this.isClient = true;
134
131
  if (_this.clearIsClient) {
@@ -173,21 +170,18 @@ var StompClient = /** @class */ (function () {
173
170
  // 重连间隔,每隔5秒递增,超过最大间隔时间后,取最大间隔时间重连
174
171
  try {
175
172
  _this.client.disconnect(function () {
176
- // const timeInterval =
177
- // Math.ceil(this.reconnectionNum / 5) *
178
- // (this.connectWsConfig.reconnectionTime ?? 3000);
173
+ _this.client = null;
179
174
  });
180
175
  }
181
176
  catch (err) {
182
- console.log('---连接已建立的关闭出错---', err);
177
+ console.log("---\u8FDE\u63A5\u5DF2\u5EFA\u7ACB\u7684\u5173\u95ED\u51FA\u9519 time=" + Date.now() + "system=" + _this.connectWsConfig.systemType + "---", err);
183
178
  }
184
- _this.client = null;
185
179
  _this.reconnectionNum++;
186
180
  // const timeInterval =
187
181
  // Math.ceil(this.reconnectionNum / 5) *
188
182
  // (this.connectWsConfig.reconnectionTime ?? 3000);
189
183
  var timeInterval = 3000;
190
- console.log("---\u7B2C" + _this.reconnectionNum + "\u6B21\u91CD\u8FDE\uFF01");
184
+ console.log("---\u7B2C" + _this.reconnectionNum + "\u6B21\u91CD\u8FDE\uFF01time=" + Date.now() + "system=" + _this.connectWsConfig.systemType);
191
185
  _this.clearIsClientYes = setTimeout(function () {
192
186
  _this.init();
193
187
  }, timeInterval);
@@ -217,10 +211,12 @@ var StompClient = /** @class */ (function () {
217
211
  callback = undefined;
218
212
  }
219
213
  var subscriptionsFn = function () {
220
- var subscription = _this.client.subscribe(pipe, function (response) {
221
- callback && callback(response);
222
- }, headers);
223
- _this.subscriptions[subscribeId] = subscription;
214
+ if (_this.client) {
215
+ var subscription = _this.client.subscribe(pipe, function (response) {
216
+ callback && callback(response);
217
+ }, headers);
218
+ _this.subscriptions[subscribeId] = subscription;
219
+ }
224
220
  };
225
221
  if ((_a = this.client) === null || _a === void 0 ? void 0 : _a.connected) {
226
222
  // 如果是连接状态 正常执行函数
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkutils",
3
- "version": "2.7.13",
3
+ "version": "2.7.16",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",