ztxkutils 2.10.66-49 → 2.10.66-50

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.
@@ -43,6 +43,18 @@ export declare function createDownloadUrlNoBase(fileId: string, authToken?: stri
43
43
  * @param {string} fileId 文件id
44
44
  */
45
45
  export declare function createPublicDownloadUrl(apiUrl: string, fileId: string): string;
46
+ /**
47
+ * @description 生成文件预览路径,不需要权限
48
+ * @param {string} fileUrl 文件服务器ip端口
49
+ * @param {string} otherOption.fileId 文件id
50
+ * @param {string} otherOption.fileName 文件名
51
+ * @param {boolean} otherOption.encodeNum encode次数
52
+ */
53
+ export declare function createPublicPreviewUrl(fileUrl: string, { fileId, fileName, encodeNum, }: {
54
+ fileId: string;
55
+ fileName: string;
56
+ encodeNum?: number;
57
+ }): string;
46
58
  /**
47
59
  * @description 文件预览方法
48
60
  * @param {string} fileUrl 文件服务器ip端口
@@ -73,6 +85,14 @@ export declare function createOriginalUrl(fileUrl: string, fileId: string, other
73
85
  * @param {string} scale 缩略倍数
74
86
  */
75
87
  export declare function createThumbnailUrl(apiUrl: string, fileId: string, scale: number, otherOption?: any): string;
88
+ /**
89
+ * 附件id加密
90
+ */
91
+ export declare function encryptFileId(fileId: string): string;
92
+ /**
93
+ * 加密后的附件id encode次数
94
+ */
95
+ export declare function encodeEncryptedFileId(encryptedFileId: string, encodeNum?: number): string;
76
96
  /**
77
97
  * 附件预览的文件id加密
78
98
  * @param fileId
@@ -210,6 +210,31 @@ function createPublicDownloadUrl(apiUrl, fileId) {
210
210
  : apiUrl;
211
211
  return _apiUrl + "/api/zmdms-resource/oss/endpoint/public/download-file/" + fileId;
212
212
  }
213
+ /**
214
+ * @description 生成文件预览路径,不需要权限
215
+ * @param {string} fileUrl 文件服务器ip端口
216
+ * @param {string} otherOption.fileId 文件id
217
+ * @param {string} otherOption.fileName 文件名
218
+ * @param {boolean} otherOption.encodeNum encode次数
219
+ */
220
+ function createPublicPreviewUrl(fileUrl, _a) {
221
+ var fileId = _a.fileId, fileName = _a.fileName, _b = _a.encodeNum, encodeNum = _b === void 0 ? 0 : _b;
222
+ var preFileId = encryptFileId(fileId);
223
+ // 给附件id加密
224
+ preFileId = encodeEncryptedFileId(preFileId, encodeNum);
225
+ var titleName = dangerouslySetXss(fileName);
226
+ try {
227
+ titleName = titleName.replace(/[~!@#$%^&*{}|]/g, '');
228
+ }
229
+ catch (err) {
230
+ console.log(err);
231
+ }
232
+ titleName = encodeURIComponent(titleName);
233
+ var _fileUrl = fileUrl.endsWith('/')
234
+ ? fileUrl.slice(0, fileUrl.length - 1)
235
+ : fileUrl;
236
+ return _fileUrl + "/pubicAttchPreview?attachId=" + preFileId + "&titleName=" + titleName;
237
+ }
213
238
  /**
214
239
  * @description 文件预览方法
215
240
  * @param {string} fileUrl 文件服务器ip端口
@@ -332,6 +357,24 @@ function createThumbnailUrl(apiUrl, fileId, scale, otherOption) {
332
357
  var token = getToken() || (otherOption === null || otherOption === void 0 ? void 0 : otherOption.authTOken);
333
358
  return _apiUrl + "/api/zmdms-resource/oss/endpoint/thumbnail/" + fileId + "?scale=" + scale + "&Zmdms-Auth=bearer " + token;
334
359
  }
360
+ /**
361
+ * 附件id加密
362
+ */
363
+ function encryptFileId(fileId) {
364
+ return crypto.encrypt(fileId);
365
+ }
366
+ /**
367
+ * 加密后的附件id encode次数
368
+ */
369
+ function encodeEncryptedFileId(encryptedFileId, encodeNum) {
370
+ if (encodeNum === void 0) { encodeNum = 0; }
371
+ var resultFileId = encryptedFileId;
372
+ while (!!encodeNum) {
373
+ encodeNum--;
374
+ resultFileId = encodeURIComponent(resultFileId);
375
+ }
376
+ return resultFileId;
377
+ }
335
378
  /**
336
379
  * 附件预览的文件id加密
337
380
  * @param fileId
@@ -358,4 +401,4 @@ function encodeOneFileIdByDownload(fileId) {
358
401
  return encodeURIComponent(crypto.encrypt(fileId));
359
402
  }
360
403
 
361
- export { batchDownloadFileCallBack, batchPreviewFile, createDownloadUrl, createDownloadUrlNoBase, createOriginalUrl, createPublicDownloadUrl, createThumbnailUrl, downloadFile, downloadFileCallBack, downloadPublicFile, encodeFileIdByDownload, encodeFileIdByPreview, encodeOneFileIdByDownload, previewFile };
404
+ export { batchDownloadFileCallBack, batchPreviewFile, createDownloadUrl, createDownloadUrlNoBase, createOriginalUrl, createPublicDownloadUrl, createPublicPreviewUrl, createThumbnailUrl, downloadFile, downloadFileCallBack, downloadPublicFile, encodeEncryptedFileId, encodeFileIdByDownload, encodeFileIdByPreview, encodeOneFileIdByDownload, encryptFileId, previewFile };
package/dist/index.js CHANGED
@@ -2,8 +2,8 @@ export { d as authority } from './authority-7a91cb9f.js';
2
2
  export { d as dataModel } from './dataModel-f1ef06bc.js';
3
3
  export { t as tools } from './tools-38e8ca87.js';
4
4
  export { v as validate } from './validate-2138d94a.js';
5
- export { r as request } from './request-36ce2fed.js';
6
- export { r as reqUrl } from './reqUrl-ea7ef876.js';
5
+ export { r as request } from './request-6df00145.js';
6
+ export { r as reqUrl } from './reqUrl-e44a69ed.js';
7
7
  import './i18next.js';
8
8
  import './tslib.es6-35653116.js';
9
9
  import 'dayjs';
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @file 项目基本配置,包括各个环境的请求地址
3
+ */
4
+ // 环境变量
5
+ function getReqUrl(processObj) {
6
+ var ENV = processObj.REACT_APP_ENV;
7
+ // api服务器各个环境地址
8
+ var ZT_API_DEV = processObj.REACT_APP_ZT_API_DEV || window.location.origin; // 开发环境
9
+ var ZT_API_TEST = processObj.REACT_APP_ZT_API_TEST || window.location.origin; // 测试环境 https://192.168.0.135:8000
10
+ var ZT_API_STAGE = processObj.REACT_APP_ZT_API_STAGE || window.location.origin; // 阶段性环境 http://192.168.0.134:8000
11
+ var ZT_API_SIM = processObj.REACT_APP_ZT_API_SIM || window.location.origin; // 阶段性环境 http://192.168.0.134:8000
12
+ var ZT_API_PRODUCT = processObj.REACT_APP_ZT_API_PRODUCT || window.location.origin; // 生产环境 http://dz.zmd.com.cn
13
+ var ZT_API_PUBLIC_PRODUCT = processObj.REACT_APP_ZT_API_PUBLIC_PRODUCT ||
14
+ 'https://nportal.zmd.com.cn:18998'; // 生产环境外网api地址 https://m-portal.zmd.com.cn:18998 http://dz.zmd.com.cn:48000
15
+ // 文件服务器
16
+ var ZT_FILE_PREVIEW_DEV = processObj.REACT_APP_ZT_FILE_PREVIEW_DEV || 'http://172.28.105.84:8012'; // 开发环境
17
+ var ZT_FILE_PREVIEW_TEST = processObj.REACT_APP_ZT_FILE_PREVIEW_TEST ||
18
+ 'http://preview-test.zmdms.com.cn:30079'; // 测试环境 http://172.55.5.101:33013
19
+ var ZT_FILE_PREVIEW_STAGE = processObj.REACT_APP_ZT_FILE_PREVIEW_STAGE ||
20
+ 'http://preview-stage.zmdms.com.cn:30079'; // 阶段性环境 https://dzfile-prod.zmd.com.cn/
21
+ var ZT_FILE_PREVIEW_SIM = processObj.REACT_APP_ZT_FILE_PREVIEW_SIM ||
22
+ 'https://dzfile-data.zmd.com.cn/'; // 阶段性环境 http://192.168.0.134:8012
23
+ var ZT_FILE_PREVIEW_PRODUCT = processObj.REACT_APP_ZT_FILE_PREVIEW_PRODUCT ||
24
+ 'https://dzfile.zmd.com.cn:8012'; // 生产环境
25
+ // 字体文件附件id
26
+ var ZT_FONTFAMILY_DEV = '1551733945007517697';
27
+ var ZT_FONTFAMILY_TEST = '1551836774183047169';
28
+ var ZT_FONTFAMILY_STAGE = '1551837561144905730';
29
+ var ZT_FONTFAMILY_SIM = '1562010976138207234';
30
+ var ZT_FONTFAMILY_PRODUCT = '1552851055372992513';
31
+ // 实际api请求地址
32
+ var ZT_API_BASEURL = ZT_API_DEV;
33
+ var ZT_API_PUBLICURL = ZT_API_PUBLIC_PRODUCT;
34
+ var ZT_FILE_BASEURL = ZT_FILE_PREVIEW_DEV;
35
+ var ZT_FONTFAMILY_BASEURL = ZT_FONTFAMILY_DEV;
36
+ if (ENV) {
37
+ switch (ENV.toLowerCase()) {
38
+ case 'zt-dev':
39
+ ZT_API_BASEURL = ZT_API_DEV;
40
+ ZT_API_PUBLICURL = ZT_API_DEV;
41
+ ZT_FILE_BASEURL = ZT_FILE_PREVIEW_DEV;
42
+ ZT_FONTFAMILY_BASEURL = ZT_FONTFAMILY_DEV;
43
+ break;
44
+ case 'zt-test':
45
+ ZT_API_BASEURL = ZT_API_TEST;
46
+ ZT_API_PUBLICURL = ZT_API_TEST;
47
+ ZT_FILE_BASEURL = ZT_FILE_PREVIEW_TEST;
48
+ ZT_FONTFAMILY_BASEURL = ZT_FONTFAMILY_TEST;
49
+ break;
50
+ case 'zt-stage':
51
+ ZT_API_BASEURL = ZT_API_STAGE;
52
+ ZT_API_PUBLICURL = ZT_API_STAGE;
53
+ ZT_FILE_BASEURL = ZT_FILE_PREVIEW_STAGE;
54
+ ZT_FONTFAMILY_BASEURL = ZT_FONTFAMILY_STAGE;
55
+ break;
56
+ case 'zt-sim':
57
+ ZT_API_BASEURL = ZT_API_SIM;
58
+ ZT_API_PUBLICURL = ZT_API_SIM;
59
+ ZT_FILE_BASEURL = ZT_FILE_PREVIEW_SIM;
60
+ ZT_FONTFAMILY_BASEURL = ZT_FONTFAMILY_SIM;
61
+ break;
62
+ case 'zt-product':
63
+ ZT_API_BASEURL = ZT_API_PRODUCT;
64
+ ZT_API_PUBLICURL = ZT_API_PUBLIC_PRODUCT;
65
+ ZT_FILE_BASEURL = ZT_FILE_PREVIEW_PRODUCT;
66
+ ZT_FONTFAMILY_BASEURL = ZT_FONTFAMILY_PRODUCT;
67
+ break;
68
+ }
69
+ }
70
+ return {
71
+ ZT_API_BASEURL: ZT_API_BASEURL,
72
+ ZT_FILE_BASEURL: ZT_FILE_BASEURL,
73
+ ZT_API_PUBLICURL: ZT_API_PUBLICURL,
74
+ ZT_FONTFAMILY_BASEURL: ZT_FONTFAMILY_BASEURL,
75
+ };
76
+ }
77
+
78
+ var reqUrl = /*#__PURE__*/Object.freeze({
79
+ __proto__: null,
80
+ getReqUrl: getReqUrl
81
+ });
82
+
83
+ export { getReqUrl as g, reqUrl as r };
package/dist/reqUrl.js CHANGED
@@ -1 +1 @@
1
- export { g as getReqUrl } from './reqUrl-ea7ef876.js';
1
+ export { g as getReqUrl } from './reqUrl-e44a69ed.js';