ztxkutils 2.10.66-4 → 2.10.66-6

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.
@@ -73,4 +73,23 @@ export declare function createOriginalUrl(fileUrl: string, fileId: string, other
73
73
  * @param {string} scale 缩略倍数
74
74
  */
75
75
  export declare function createThumbnailUrl(apiUrl: string, fileId: string, scale: number, otherOption?: any): string;
76
+ /**
77
+ * 附件预览的文件id加密
78
+ * @param fileId
79
+ * @returns
80
+ */
81
+ export declare function encodeFileIdByPreview(fileId: string): string;
82
+ /**
83
+ * 附件预览的文件id加密
84
+ * @param fileId
85
+ * @returns
86
+ */
87
+ export declare function encodeFileIdByDownload(fileId: string): string;
88
+ /**
89
+ * 附件预览的文件id加密。加密后只encode一次
90
+ * 用在那些通过body传参的业务里
91
+ * @param fileId
92
+ * @returns
93
+ */
94
+ export declare function encodeOneFileIdByDownload(fileId: string): string;
76
95
  export {};
@@ -11,7 +11,7 @@ import 'crypto';
11
11
  */
12
12
  function downloadFile(apiUrl, fileId, fileName, otherOption) {
13
13
  // 给附件id加密
14
- fileId = encodeURIComponent(encodeURIComponent(crypto.encrypt(fileId)));
14
+ fileId = encodeFileIdByDownload(fileId);
15
15
  var xhr = new XMLHttpRequest();
16
16
  var token = '';
17
17
  var addWaterMark = 'true';
@@ -47,7 +47,7 @@ function downloadFile(apiUrl, fileId, fileName, otherOption) {
47
47
  }
48
48
  function downloadFileCallBack(apiUrl, fileId, fileName, otherOption) {
49
49
  // 给附件id加密
50
- fileId = encodeURIComponent(encodeURIComponent(crypto.encrypt(fileId)));
50
+ fileId = encodeFileIdByDownload(fileId);
51
51
  var _a = otherOption || {}, authToken = _a.authToken, callbackAfter = _a.callbackAfter, callbackError = _a.callbackError, _b = _a.addWaterMark, addWaterMark = _b === void 0 ? true : _b;
52
52
  var xhr = new XMLHttpRequest();
53
53
  var token = getToken() || authToken;
@@ -84,7 +84,7 @@ function downloadFileCallBack(apiUrl, fileId, fileName, otherOption) {
84
84
  */
85
85
  function batchDownloadFileCallBack(apiUrl, fileIds, fileNames, otherOption) {
86
86
  // 给附件id加密
87
- fileIds = encodeURIComponent(encodeURIComponent(crypto.encrypt(fileIds)));
87
+ fileIds = encodeFileIdByDownload(fileIds);
88
88
  var _a = otherOption || {}, authToken = _a.authToken, zipName = _a.zipName, _b = _a.addWaterMark, addWaterMark = _b === void 0 ? true : _b, callbackAfter = _a.callbackAfter, callbackError = _a.callbackError;
89
89
  var xhr = new XMLHttpRequest();
90
90
  var token = getToken() || authToken;
@@ -165,7 +165,7 @@ function downloadPublicFile(apiUrl, fileId, fileName, otherOption) {
165
165
  function createDownloadUrl(apiUrl, fileId, authToken) {
166
166
  // 给附件id加密
167
167
  // fileId = encodeURIComponent(crypto.encrypt(fileId));
168
- fileId = encodeURIComponent(encodeURIComponent(crypto.encrypt(fileId)));
168
+ fileId = encodeFileIdByDownload(fileId);
169
169
  var token = getToken() || authToken;
170
170
  var _apiUrl = apiUrl.endsWith('/')
171
171
  ? apiUrl.slice(0, apiUrl.length - 1)
@@ -180,7 +180,7 @@ function createDownloadUrl(apiUrl, fileId, authToken) {
180
180
  function createDownloadUrlNoBase(fileId, authToken) {
181
181
  // 给附件id加密
182
182
  // fileId = encodeURIComponent(crypto.encrypt(fileId));
183
- fileId = encodeURIComponent(encodeURIComponent(crypto.encrypt(fileId)));
183
+ fileId = encodeFileIdByDownload(fileId);
184
184
  var token = getToken() || authToken;
185
185
  return "/api/zmdms-resource/oss/endpoint/download-file/" + fileId + "?Zmdms-Auth=bearer " + token;
186
186
  }
@@ -207,7 +207,7 @@ function createPublicDownloadUrl(apiUrl, fileId) {
207
207
  function previewFile(fileUrl, fileId, otherOption) {
208
208
  var preFileId = fileId;
209
209
  // 给附件id加密
210
- fileId = encodeURIComponent(crypto.encrypt(fileId));
210
+ fileId = encodeFileIdByPreview(fileId);
211
211
  var token = '';
212
212
  if (typeof otherOption === 'object') {
213
213
  token = getToken() || (otherOption === null || otherOption === void 0 ? void 0 : otherOption.authToken);
@@ -247,7 +247,7 @@ function previewFile(fileUrl, fileId, otherOption) {
247
247
  */
248
248
  function batchPreviewFile(fileUrl, fileId, otherOption) {
249
249
  // 给附件id加密
250
- fileId = encodeURIComponent(crypto.encrypt(fileId));
250
+ fileId = encodeFileIdByPreview(fileId);
251
251
  var token = '';
252
252
  if (typeof otherOption === 'object') {
253
253
  token = getToken() || (otherOption === null || otherOption === void 0 ? void 0 : otherOption.authToken);
@@ -281,7 +281,7 @@ function batchPreviewFile(fileUrl, fileId, otherOption) {
281
281
  function createOriginalUrl(fileUrl, fileId, otherOption) {
282
282
  var preFileId = fileId;
283
283
  // 给附件id加密
284
- fileId = encodeURIComponent(crypto.encrypt(fileId));
284
+ fileId = encodeFileIdByPreview(fileId);
285
285
  var token = getToken() || (otherOption === null || otherOption === void 0 ? void 0 : otherOption.authTOken);
286
286
  var titleName = dangerouslySetXss(otherOption === null || otherOption === void 0 ? void 0 : otherOption.titleName);
287
287
  try {
@@ -318,6 +318,31 @@ function createThumbnailUrl(apiUrl, fileId, scale, otherOption) {
318
318
  : apiUrl;
319
319
  var token = getToken() || (otherOption === null || otherOption === void 0 ? void 0 : otherOption.authTOken);
320
320
  return _apiUrl + "/api/zmdms-resource/oss/endpoint/thumbnail/" + fileId + "?scale=" + scale + "&Zmdms-Auth=bearer " + token;
321
+ }
322
+ /**
323
+ * 附件预览的文件id加密
324
+ * @param fileId
325
+ * @returns
326
+ */
327
+ function encodeFileIdByPreview(fileId) {
328
+ return encodeURIComponent(crypto.encrypt(fileId));
329
+ }
330
+ /**
331
+ * 附件预览的文件id加密
332
+ * @param fileId
333
+ * @returns
334
+ */
335
+ function encodeFileIdByDownload(fileId) {
336
+ return encodeURIComponent(encodeURIComponent(crypto.encrypt(fileId)));
337
+ }
338
+ /**
339
+ * 附件预览的文件id加密。加密后只encode一次
340
+ * 用在那些通过body传参的业务里
341
+ * @param fileId
342
+ * @returns
343
+ */
344
+ function encodeOneFileIdByDownload(fileId) {
345
+ return encodeURIComponent(crypto.encrypt(fileId));
321
346
  }
322
347
 
323
- export { batchDownloadFileCallBack, batchPreviewFile, createDownloadUrl, createDownloadUrlNoBase, createOriginalUrl, createPublicDownloadUrl, createThumbnailUrl, downloadFile, downloadFileCallBack, downloadPublicFile, previewFile };
348
+ export { batchDownloadFileCallBack, batchPreviewFile, createDownloadUrl, createDownloadUrlNoBase, createOriginalUrl, createPublicDownloadUrl, createThumbnailUrl, downloadFile, downloadFileCallBack, downloadPublicFile, encodeFileIdByDownload, encodeFileIdByPreview, encodeOneFileIdByDownload, previewFile };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkutils",
3
- "version": "2.10.66-4",
3
+ "version": "2.10.66-6",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",