ztxkutils 2.10.11 → 2.10.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.
@@ -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.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.11",
3
+ "version": "2.10.13",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",