ztxkutils 2.10.66-50 → 2.10.66-51

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.
@@ -63,6 +63,11 @@ export declare function createPublicPreviewUrl(fileUrl: string, { fileId, fileNa
63
63
  * @param {string} fileName 文件名
64
64
  */
65
65
  export declare function previewFile(fileUrl: string, fileId: string, otherOption?: any): void;
66
+ export declare function previewPublicFile(fileUrl: string, { fileId, fileName, encodeNum, }: {
67
+ fileId: string;
68
+ fileName: string;
69
+ encodeNum?: number;
70
+ }): void;
66
71
  /**
67
72
  * @description 批量文件预览方法,只针对图片类型
68
73
  * @param {string} fileUrl 文件服务器ip端口
@@ -276,6 +276,24 @@ function previewFile(fileUrl, fileId, otherOption) {
276
276
  window.open(fileUrl + "/attchPreview?attachId=" + fileId + "&Zmdms-Auth=bearer " + token + "&officePreviewType=pdf");
277
277
  }
278
278
  }
279
+ function previewPublicFile(fileUrl, _a) {
280
+ var fileId = _a.fileId, fileName = _a.fileName, _b = _a.encodeNum, encodeNum = _b === void 0 ? 0 : _b;
281
+ var preFileId = encryptFileId(fileId);
282
+ // 给附件id加密
283
+ preFileId = encodeEncryptedFileId(preFileId, encodeNum);
284
+ var titleName = dangerouslySetXss(fileName);
285
+ try {
286
+ titleName = titleName.replace(/[~!@#$%^&*{}|]/g, '');
287
+ }
288
+ catch (err) {
289
+ console.log(err);
290
+ }
291
+ titleName = encodeURIComponent(titleName);
292
+ var _fileUrl = fileUrl.endsWith('/')
293
+ ? fileUrl.slice(0, fileUrl.length - 1)
294
+ : fileUrl;
295
+ window.open(_fileUrl + "/pubicAttchPreview?attachId=" + preFileId + "&titleName=" + titleName);
296
+ }
279
297
  /**
280
298
  * @description 批量文件预览方法,只针对图片类型
281
299
  * @param {string} fileUrl 文件服务器ip端口
@@ -401,4 +419,4 @@ function encodeOneFileIdByDownload(fileId) {
401
419
  return encodeURIComponent(crypto.encrypt(fileId));
402
420
  }
403
421
 
404
- export { batchDownloadFileCallBack, batchPreviewFile, createDownloadUrl, createDownloadUrlNoBase, createOriginalUrl, createPublicDownloadUrl, createPublicPreviewUrl, createThumbnailUrl, downloadFile, downloadFileCallBack, downloadPublicFile, encodeEncryptedFileId, encodeFileIdByDownload, encodeFileIdByPreview, encodeOneFileIdByDownload, encryptFileId, previewFile };
422
+ export { batchDownloadFileCallBack, batchPreviewFile, createDownloadUrl, createDownloadUrlNoBase, createOriginalUrl, createPublicDownloadUrl, createPublicPreviewUrl, createThumbnailUrl, downloadFile, downloadFileCallBack, downloadPublicFile, encodeEncryptedFileId, encodeFileIdByDownload, encodeFileIdByPreview, encodeOneFileIdByDownload, encryptFileId, previewFile, previewPublicFile };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkutils",
3
- "version": "2.10.66-50",
3
+ "version": "2.10.66-51",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",