ztxkutils 2.10.12 → 2.10.13
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 +1 -1
- package/dist/fileOperation.js +16 -6
- package/package.json +1 -1
package/dist/fileOperation.d.ts
CHANGED
@@ -12,7 +12,7 @@ interface IOtherOption {
|
|
12
12
|
zipName?: string;
|
13
13
|
addWaterMark?: boolean;
|
14
14
|
}
|
15
|
-
export declare function downloadFile(apiUrl: string, fileId: string, fileName: string,
|
15
|
+
export declare function downloadFile(apiUrl: string, fileId: string, fileName: string, otherOption?: any): void;
|
16
16
|
export declare function downloadFileCallBack(apiUrl: string, fileId: string, fileName: string, otherOption?: IOtherOption): void;
|
17
17
|
/**
|
18
18
|
* 批量下载
|
package/dist/fileOperation.js
CHANGED
@@ -8,13 +8,23 @@ import 'number-precision';
|
|
8
8
|
* @author cyx
|
9
9
|
* @description 文件操作相关
|
10
10
|
*/
|
11
|
-
function downloadFile(apiUrl, fileId, fileName,
|
11
|
+
function downloadFile(apiUrl, fileId, fileName, otherOption) {
|
12
12
|
var xhr = new XMLHttpRequest();
|
13
|
-
var token =
|
13
|
+
var token = '';
|
14
|
+
var addWaterMark = 'true';
|
15
|
+
if (typeof otherOption === 'object') {
|
16
|
+
token = getToken() || (otherOption === null || otherOption === void 0 ? void 0 : otherOption.authToken);
|
17
|
+
addWaterMark = (otherOption === null || otherOption === void 0 ? void 0 : otherOption.addWaterMark)
|
18
|
+
? otherOption === null || otherOption === void 0 ? void 0 : otherOption.addWaterMark
|
19
|
+
: 'true';
|
20
|
+
}
|
21
|
+
else {
|
22
|
+
token = getToken() || otherOption;
|
23
|
+
}
|
14
24
|
var _apiUrl = apiUrl.endsWith('/')
|
15
25
|
? apiUrl.slice(0, apiUrl.length - 1)
|
16
26
|
: apiUrl;
|
17
|
-
xhr.open('GET', _apiUrl + "/api/zmdms-resource/oss/endpoint/download-file/" + fileId + "?Zmdms-Auth=bearer " + token + "&addWaterMark=
|
27
|
+
xhr.open('GET', _apiUrl + "/api/zmdms-resource/oss/endpoint/download-file/" + fileId + "?Zmdms-Auth=bearer " + token + "&addWaterMark=" + addWaterMark, true);
|
18
28
|
xhr.responseType = 'blob';
|
19
29
|
xhr.onload = function () {
|
20
30
|
if (xhr.status === 200 || xhr.status === 201) {
|
@@ -33,13 +43,13 @@ function downloadFile(apiUrl, fileId, fileName, authToken) {
|
|
33
43
|
xhr.send();
|
34
44
|
}
|
35
45
|
function downloadFileCallBack(apiUrl, fileId, fileName, otherOption) {
|
36
|
-
var _a = otherOption || {}, authToken = _a.authToken, callbackAfter = _a.callbackAfter, callbackError = _a.callbackError;
|
46
|
+
var _a = otherOption || {}, authToken = _a.authToken, callbackAfter = _a.callbackAfter, callbackError = _a.callbackError, _b = _a.addWaterMark, addWaterMark = _b === void 0 ? true : _b;
|
37
47
|
var xhr = new XMLHttpRequest();
|
38
48
|
var token = getToken() || authToken;
|
39
49
|
var _apiUrl = apiUrl.endsWith('/')
|
40
50
|
? apiUrl.slice(0, apiUrl.length - 1)
|
41
51
|
: apiUrl;
|
42
|
-
xhr.open('GET', _apiUrl + "/api/zmdms-resource/oss/endpoint/download-file/" + fileId + "?Zmdms-Auth=bearer " + token + "&addWaterMark=
|
52
|
+
xhr.open('GET', _apiUrl + "/api/zmdms-resource/oss/endpoint/download-file/" + fileId + "?Zmdms-Auth=bearer " + token + "&addWaterMark=" + addWaterMark, true);
|
43
53
|
xhr.responseType = 'blob';
|
44
54
|
xhr.onload = function () {
|
45
55
|
if (xhr.status === 200 || xhr.status === 201) {
|
@@ -68,7 +78,7 @@ function downloadFileCallBack(apiUrl, fileId, fileName, otherOption) {
|
|
68
78
|
* 批量下载
|
69
79
|
*/
|
70
80
|
function batchDownloadFileCallBack(apiUrl, fileIds, fileNames, otherOption) {
|
71
|
-
var _a = otherOption || {}, authToken = _a.authToken, zipName = _a.zipName,
|
81
|
+
var _a = otherOption || {}, authToken = _a.authToken, zipName = _a.zipName, _b = _a.addWaterMark, addWaterMark = _b === void 0 ? true : _b, callbackAfter = _a.callbackAfter, callbackError = _a.callbackError;
|
72
82
|
var xhr = new XMLHttpRequest();
|
73
83
|
var token = getToken() || authToken;
|
74
84
|
var _apiUrl = apiUrl.endsWith('/')
|