ztxkutils 2.10.10 → 2.10.12

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.
@@ -9,9 +9,15 @@ interface IOtherOption {
9
9
  authToken?: string;
10
10
  callbackAfter?: () => void;
11
11
  callbackError?: () => void;
12
+ zipName?: string;
13
+ addWaterMark?: boolean;
12
14
  }
13
15
  export declare function downloadFile(apiUrl: string, fileId: string, fileName: string, authToken?: string): void;
14
16
  export declare function downloadFileCallBack(apiUrl: string, fileId: string, fileName: string, otherOption?: IOtherOption): void;
17
+ /**
18
+ * 批量下载
19
+ */
20
+ export declare function batchDownloadFileCallBack(apiUrl: string, fileIds: string, fileNames: string, otherOption?: IOtherOption): void;
15
21
  /**
16
22
  * @description 公共文件下载,并重命名
17
23
  * @param {string} apiUrl api服务器ip端口
@@ -64,6 +64,43 @@ function downloadFileCallBack(apiUrl, fileId, fileName, otherOption) {
64
64
  };
65
65
  xhr.send();
66
66
  }
67
+ /**
68
+ * 批量下载
69
+ */
70
+ 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;
72
+ var xhr = new XMLHttpRequest();
73
+ var token = getToken() || authToken;
74
+ var _apiUrl = apiUrl.endsWith('/')
75
+ ? apiUrl.slice(0, apiUrl.length - 1)
76
+ : apiUrl;
77
+ xhr.open('POST', _apiUrl + "/api/zmdms-resource/oss/endpoint/batch-download-file", true);
78
+ xhr.responseType = 'blob';
79
+ xhr.onload = function () {
80
+ if (xhr.status === 200 || xhr.status === 201) {
81
+ var link = document.createElement('a');
82
+ var body = document.querySelector('body');
83
+ link.href = window.URL.createObjectURL(xhr.response);
84
+ link.download = zipName;
85
+ // fix Firefox
86
+ link.style.display = 'none';
87
+ body.appendChild(link);
88
+ link.click();
89
+ body.removeChild(link);
90
+ window.URL.revokeObjectURL(link.href);
91
+ callbackAfter && callbackAfter();
92
+ }
93
+ else {
94
+ callbackError && callbackError();
95
+ }
96
+ };
97
+ xhr.onerror = function (err) {
98
+ callbackError && callbackError();
99
+ };
100
+ xhr.setRequestHeader('Zmdms-Auth', token || '');
101
+ xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
102
+ xhr.send("attachIds=" + fileIds + "&fileNames=" + fileNames + "&zipName=" + zipName + "&addWaterMark=" + addWaterMark);
103
+ }
67
104
  /**
68
105
  * @description 公共文件下载,并重命名
69
106
  * @param {string} apiUrl api服务器ip端口
@@ -204,4 +241,4 @@ function createThumbnailUrl(apiUrl, fileId, scale, otherOption) {
204
241
  return _apiUrl + "/api/zmdms-resource/oss/endpoint/thumbnail/" + fileId + "?scale=" + scale + "&Zmdms-Auth=bearer " + token;
205
242
  }
206
243
 
207
- export { createDownloadUrl, createDownloadUrlNoBase, createOriginalUrl, createPublicDownloadUrl, createThumbnailUrl, downloadFile, downloadFileCallBack, downloadPublicFile, previewFile };
244
+ export { batchDownloadFileCallBack, createDownloadUrl, createDownloadUrlNoBase, createOriginalUrl, createPublicDownloadUrl, createThumbnailUrl, downloadFile, downloadFileCallBack, downloadPublicFile, previewFile };
package/dist/print.js CHANGED
@@ -78,13 +78,13 @@ function createWaterHandle(obj) {
78
78
  }
79
79
  var _a = obj || {}, waterText = _a.waterText, opacity = _a.opacity, fontSize = _a.fontSize, cavansWidth = _a.cavansWidth, cavansHeight = _a.cavansHeight;
80
80
  var canvas = document.createElement('canvas');
81
- canvas.width = cavansWidth || 200;
82
- canvas.height = cavansHeight || 80;
81
+ canvas.width = cavansWidth || 240;
82
+ canvas.height = cavansHeight || 100;
83
83
  var ctx = canvas.getContext('2d');
84
84
  if (ctx) {
85
85
  ctx.rotate((-10 * Math.PI) / 180); // 水印旋转角度
86
86
  ctx.font = (fontSize || '18px') + " \u5FAE\u8F6F\u96C5\u9ED1";
87
- ctx.fillStyle = "rgba(0,0,0," + (opacity ? opacity : '0.2') + ")";
87
+ ctx.fillStyle = "rgba(0,0,0," + (opacity ? opacity : '0.07') + ")";
88
88
  ctx.textAlign = 'center';
89
89
  ctx.textBaseline = 'middle';
90
90
  ctx.fillText(waterText || defaultWaterText, canvas.width / 2, canvas.height); // 水印在画布的位置x,y轴
@@ -119,7 +119,7 @@ function createPdf(canvas, pdf, noWater, positionX) {
119
119
  pdf.addImage(pageData, 'JPEG', positionX || 20, 10, imgWidth, imgHeight);
120
120
  if (!noWater) {
121
121
  var waterBase64 = createWaterHandle({
122
- opacity: '0.2',
122
+ opacity: '0.07',
123
123
  fontSize: '14px',
124
124
  });
125
125
  addPdfWaterHandle(pdf, waterBase64);
@@ -130,7 +130,7 @@ function createPdf(canvas, pdf, noWater, positionX) {
130
130
  pdf.addImage(pageData, 'JPEG', positionX || 20, position, imgWidth, imgHeight);
131
131
  if (!noWater) {
132
132
  var waterBase64 = createWaterHandle({
133
- opacity: '0.2',
133
+ opacity: '0.07',
134
134
  fontSize: '14px',
135
135
  });
136
136
  addPdfWaterHandle(pdf, waterBase64);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkutils",
3
- "version": "2.10.10",
3
+ "version": "2.10.12",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",