ztxkutils 2.10.12 → 2.10.14

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.
@@ -12,7 +12,7 @@ interface IOtherOption {
12
12
  zipName?: string;
13
13
  addWaterMark?: boolean;
14
14
  }
15
- export declare function downloadFile(apiUrl: string, fileId: string, fileName: string, authToken?: string): void;
15
+ export declare function downloadFile(apiUrl: string, fileId: string, fileName: string, otherOption?: any): void;
16
16
  export declare function downloadFileCallBack(apiUrl: string, fileId: string, fileName: string, otherOption?: IOtherOption): void;
17
17
  /**
18
18
  * 批量下载
@@ -8,13 +8,23 @@ import 'number-precision';
8
8
  * @author cyx
9
9
  * @description 文件操作相关
10
10
  */
11
- function downloadFile(apiUrl, fileId, fileName, authToken) {
11
+ function downloadFile(apiUrl, fileId, fileName, otherOption) {
12
12
  var xhr = new XMLHttpRequest();
13
- var token = getToken() || authToken;
13
+ var token = '';
14
+ var addWaterMark = 'true';
15
+ if (typeof otherOption === 'object') {
16
+ token = getToken() || (otherOption === null || otherOption === void 0 ? void 0 : otherOption.authToken);
17
+ addWaterMark = (otherOption === null || otherOption === void 0 ? void 0 : otherOption.addWaterMark)
18
+ ? otherOption === null || otherOption === void 0 ? void 0 : otherOption.addWaterMark
19
+ : 'true';
20
+ }
21
+ else {
22
+ token = getToken() || otherOption;
23
+ }
14
24
  var _apiUrl = apiUrl.endsWith('/')
15
25
  ? apiUrl.slice(0, apiUrl.length - 1)
16
26
  : apiUrl;
17
- xhr.open('GET', _apiUrl + "/api/zmdms-resource/oss/endpoint/download-file/" + fileId + "?Zmdms-Auth=bearer " + token + "&addWaterMark=true", true);
27
+ xhr.open('GET', _apiUrl + "/api/zmdms-resource/oss/endpoint/download-file/" + fileId + "?Zmdms-Auth=bearer " + token + "&addWaterMark=" + addWaterMark, true);
18
28
  xhr.responseType = 'blob';
19
29
  xhr.onload = function () {
20
30
  if (xhr.status === 200 || xhr.status === 201) {
@@ -33,13 +43,13 @@ function downloadFile(apiUrl, fileId, fileName, authToken) {
33
43
  xhr.send();
34
44
  }
35
45
  function downloadFileCallBack(apiUrl, fileId, fileName, otherOption) {
36
- var _a = otherOption || {}, authToken = _a.authToken, callbackAfter = _a.callbackAfter, callbackError = _a.callbackError;
46
+ var _a = otherOption || {}, authToken = _a.authToken, callbackAfter = _a.callbackAfter, callbackError = _a.callbackError, _b = _a.addWaterMark, addWaterMark = _b === void 0 ? true : _b;
37
47
  var xhr = new XMLHttpRequest();
38
48
  var token = getToken() || authToken;
39
49
  var _apiUrl = apiUrl.endsWith('/')
40
50
  ? apiUrl.slice(0, apiUrl.length - 1)
41
51
  : apiUrl;
42
- xhr.open('GET', _apiUrl + "/api/zmdms-resource/oss/endpoint/download-file/" + fileId + "?Zmdms-Auth=bearer " + token + "&addWaterMark=true", true);
52
+ xhr.open('GET', _apiUrl + "/api/zmdms-resource/oss/endpoint/download-file/" + fileId + "?Zmdms-Auth=bearer " + token + "&addWaterMark=" + addWaterMark, true);
43
53
  xhr.responseType = 'blob';
44
54
  xhr.onload = function () {
45
55
  if (xhr.status === 200 || xhr.status === 201) {
@@ -68,7 +78,7 @@ function downloadFileCallBack(apiUrl, fileId, fileName, otherOption) {
68
78
  * 批量下载
69
79
  */
70
80
  function batchDownloadFileCallBack(apiUrl, fileIds, fileNames, otherOption) {
71
- var _a = otherOption || {}, authToken = _a.authToken, zipName = _a.zipName, addWaterMark = _a.addWaterMark, callbackAfter = _a.callbackAfter, callbackError = _a.callbackError;
81
+ var _a = otherOption || {}, authToken = _a.authToken, zipName = _a.zipName, _b = _a.addWaterMark, addWaterMark = _b === void 0 ? true : _b, callbackAfter = _a.callbackAfter, callbackError = _a.callbackError;
72
82
  var xhr = new XMLHttpRequest();
73
83
  var token = getToken() || authToken;
74
84
  var _apiUrl = apiUrl.endsWith('/')
package/dist/print.d.ts CHANGED
@@ -42,7 +42,7 @@ export interface IPdfOption {
42
42
  /** 上下边距 */
43
43
  pageMarginY?: number;
44
44
  }
45
- export declare function htmlToPdfNoCanvas({ pageClassName, dom, isShowPage, fileBinary, pdfName, isDownload, pdfOption, isAddWater, waterBase64, imgWidth, imgHeight, }: {
45
+ export declare function htmlToPdfNoCanvas({ pageClassName, dom, isShowPage, fileBinary, pdfName, isDownload, pdfOption, isAddWater, waterBase64, imgWidth, imgHeight, isCompress, }: {
46
46
  pageClassName?: string;
47
47
  dom: HTMLElement;
48
48
  isShowPage?: boolean;
@@ -56,5 +56,6 @@ export declare function htmlToPdfNoCanvas({ pageClassName, dom, isShowPage, file
56
56
  waterBase64?: string;
57
57
  imgWidth?: number;
58
58
  imgHeight?: number;
59
+ isCompress?: boolean;
59
60
  }): Promise<unknown>;
60
61
  export {};
package/dist/print.js CHANGED
@@ -196,11 +196,11 @@ function htmlToPdf(_a) {
196
196
  }
197
197
  }
198
198
  function htmlToPdfNoCanvas(_a) {
199
- var _b, _c, _d;
200
- var pageClassName = _a.pageClassName, dom = _a.dom, isShowPage = _a.isShowPage, fileBinary = _a.fileBinary, pdfName = _a.pdfName, isDownload = _a.isDownload, pdfOption = _a.pdfOption, isAddWater = _a.isAddWater, waterBase64 = _a.waterBase64, imgWidth = _a.imgWidth, imgHeight = _a.imgHeight;
199
+ var _b, _c;
200
+ var pageClassName = _a.pageClassName, dom = _a.dom, isShowPage = _a.isShowPage, fileBinary = _a.fileBinary, pdfName = _a.pdfName, isDownload = _a.isDownload, pdfOption = _a.pdfOption, isAddWater = _a.isAddWater, waterBase64 = _a.waterBase64, imgWidth = _a.imgWidth, imgHeight = _a.imgHeight, isCompress = _a.isCompress;
201
201
  return __awaiter(this, void 0, void 0, function () {
202
202
  var allDom, pageFormat, pageOrient, pageMarginX, pageMarginY, pdfOptions, allDomArray_1, pdfBase64_1, pdfs_1, pdf_1, pageWidth_1;
203
- return __generator(this, function (_e) {
203
+ return __generator(this, function (_d) {
204
204
  allDom = dom.querySelectorAll(pageClassName ? pageClassName : '.html2canvas-container-page');
205
205
  pageFormat = (pdfOption === null || pdfOption === void 0 ? void 0 : pdfOption.pageFormat) ? pdfOption.pageFormat : 'a4';
206
206
  pageOrient = (pdfOption === null || pdfOption === void 0 ? void 0 : pdfOption.pageOrient) ? pdfOption.pageOrient : 'p';
@@ -208,7 +208,7 @@ function htmlToPdfNoCanvas(_a) {
208
208
  pageMarginY = (_c = pdfOption === null || pdfOption === void 0 ? void 0 : pdfOption.pageMarginY) !== null && _c !== void 0 ? _c : 10;
209
209
  pdfOptions = {
210
210
  // 是否压缩生成的PDF
211
- compress: (_d = pdfOption === null || pdfOption === void 0 ? void 0 : pdfOption.pageMarginY) !== null && _d !== void 0 ? _d : true,
211
+ compress: isCompress ? true : false,
212
212
  // 格式
213
213
  format: pageFormat,
214
214
  hotfixes: ['px_scaling'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkutils",
3
- "version": "2.10.12",
3
+ "version": "2.10.14",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",