ztxkutils 2.10.66-3 → 2.10.66-5

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,16 @@ 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;
76
88
  export {};
@@ -11,7 +11,7 @@ import 'crypto';
11
11
  */
12
12
  function downloadFile(apiUrl, fileId, fileName, otherOption) {
13
13
  // 给附件id加密
14
- fileId = 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(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(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;
@@ -164,7 +164,8 @@ function downloadPublicFile(apiUrl, fileId, fileName, otherOption) {
164
164
  */
165
165
  function createDownloadUrl(apiUrl, fileId, authToken) {
166
166
  // 给附件id加密
167
- fileId = encodeURIComponent(crypto.encrypt(fileId));
167
+ // fileId = encodeURIComponent(crypto.encrypt(fileId));
168
+ fileId = encodeFileIdByDownload(fileId);
168
169
  var token = getToken() || authToken;
169
170
  var _apiUrl = apiUrl.endsWith('/')
170
171
  ? apiUrl.slice(0, apiUrl.length - 1)
@@ -178,7 +179,8 @@ function createDownloadUrl(apiUrl, fileId, authToken) {
178
179
  */
179
180
  function createDownloadUrlNoBase(fileId, authToken) {
180
181
  // 给附件id加密
181
- fileId = encodeURIComponent(crypto.encrypt(fileId));
182
+ // fileId = encodeURIComponent(crypto.encrypt(fileId));
183
+ fileId = encodeFileIdByDownload(fileId);
182
184
  var token = getToken() || authToken;
183
185
  return "/api/zmdms-resource/oss/endpoint/download-file/" + fileId + "?Zmdms-Auth=bearer " + token;
184
186
  }
@@ -203,8 +205,9 @@ function createPublicDownloadUrl(apiUrl, fileId) {
203
205
  * @param {string} fileName 文件名
204
206
  */
205
207
  function previewFile(fileUrl, fileId, otherOption) {
208
+ var preFileId = fileId;
206
209
  // 给附件id加密
207
- fileId = encodeURIComponent(crypto.encrypt(fileId));
210
+ fileId = encodeFileIdByPreview(fileId);
208
211
  var token = '';
209
212
  if (typeof otherOption === 'object') {
210
213
  token = getToken() || (otherOption === null || otherOption === void 0 ? void 0 : otherOption.authToken);
@@ -224,7 +227,7 @@ function previewFile(fileUrl, fileId, otherOption) {
224
227
  : fileUrl;
225
228
  if (titleName) {
226
229
  var lastPointIndex = titleName.lastIndexOf('.');
227
- var preTitleName = titleName.substring(0, lastPointIndex) + ("-" + fileId);
230
+ var preTitleName = titleName.substring(0, lastPointIndex) + ("-" + preFileId);
228
231
  var suffixTitleName = titleName.substring(lastPointIndex + 1);
229
232
  titleName = suffixTitleName
230
233
  ? preTitleName + "." + suffixTitleName
@@ -244,7 +247,7 @@ function previewFile(fileUrl, fileId, otherOption) {
244
247
  */
245
248
  function batchPreviewFile(fileUrl, fileId, otherOption) {
246
249
  // 给附件id加密
247
- fileId = encodeURIComponent(crypto.encrypt(fileId));
250
+ fileId = encodeFileIdByPreview(fileId);
248
251
  var token = '';
249
252
  if (typeof otherOption === 'object') {
250
253
  token = getToken() || (otherOption === null || otherOption === void 0 ? void 0 : otherOption.authToken);
@@ -276,8 +279,9 @@ function batchPreviewFile(fileUrl, fileId, otherOption) {
276
279
  * @param {string} fileType 文件类型
277
280
  */
278
281
  function createOriginalUrl(fileUrl, fileId, otherOption) {
282
+ var preFileId = fileId;
279
283
  // 给附件id加密
280
- fileId = encodeURIComponent(crypto.encrypt(fileId));
284
+ fileId = encodeFileIdByPreview(fileId);
281
285
  var token = getToken() || (otherOption === null || otherOption === void 0 ? void 0 : otherOption.authTOken);
282
286
  var titleName = dangerouslySetXss(otherOption === null || otherOption === void 0 ? void 0 : otherOption.titleName);
283
287
  try {
@@ -291,7 +295,7 @@ function createOriginalUrl(fileUrl, fileId, otherOption) {
291
295
  : fileUrl;
292
296
  if (titleName) {
293
297
  var lastPointIndex = titleName.lastIndexOf('.');
294
- var preTitleName = titleName.substring(0, lastPointIndex) + ("-" + fileId);
298
+ var preTitleName = titleName.substring(0, lastPointIndex) + ("-" + preFileId);
295
299
  var suffixTitleName = titleName.substring(lastPointIndex + 1);
296
300
  titleName = suffixTitleName
297
301
  ? preTitleName + "." + suffixTitleName
@@ -314,6 +318,22 @@ function createThumbnailUrl(apiUrl, fileId, scale, otherOption) {
314
318
  : apiUrl;
315
319
  var token = getToken() || (otherOption === null || otherOption === void 0 ? void 0 : otherOption.authTOken);
316
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)));
317
337
  }
318
338
 
319
- export { batchDownloadFileCallBack, batchPreviewFile, createDownloadUrl, createDownloadUrlNoBase, createOriginalUrl, createPublicDownloadUrl, createThumbnailUrl, downloadFile, downloadFileCallBack, downloadPublicFile, previewFile };
339
+ export { batchDownloadFileCallBack, batchPreviewFile, createDownloadUrl, createDownloadUrlNoBase, createOriginalUrl, createPublicDownloadUrl, createThumbnailUrl, downloadFile, downloadFileCallBack, downloadPublicFile, encodeFileIdByDownload, encodeFileIdByPreview, previewFile };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkutils",
3
- "version": "2.10.66-3",
3
+ "version": "2.10.66-5",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",