ztxkutils 2.10.66-4 → 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.
- package/dist/fileOperation.d.ts +12 -0
- package/dist/fileOperation.js +25 -9
- package/package.json +1 -1
package/dist/fileOperation.d.ts
CHANGED
@@ -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 {};
|
package/dist/fileOperation.js
CHANGED
@@ -11,7 +11,7 @@ import 'crypto';
|
|
11
11
|
*/
|
12
12
|
function downloadFile(apiUrl, fileId, fileName, otherOption) {
|
13
13
|
// 给附件id加密
|
14
|
-
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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,22 @@ 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)));
|
321
337
|
}
|
322
338
|
|
323
|
-
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 };
|