ztxkutils 2.9.0 → 2.9.1
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 -0
- package/dist/fileOperation.js +8 -2
- package/package.json +1 -1
package/dist/fileOperation.d.ts
CHANGED
@@ -8,6 +8,7 @@
|
|
8
8
|
interface IOtherOption {
|
9
9
|
authToken?: string;
|
10
10
|
callbackAfter?: () => void;
|
11
|
+
callbackError?: () => void;
|
11
12
|
}
|
12
13
|
export declare function downloadFile(apiUrl: string, fileId: string, fileName: string, authToken?: string): void;
|
13
14
|
export declare function downloadFileCallBack(apiUrl: string, fileId: string, fileName: string, otherOption?: IOtherOption): void;
|
package/dist/fileOperation.js
CHANGED
@@ -33,7 +33,7 @@ function downloadFile(apiUrl, fileId, fileName, authToken) {
|
|
33
33
|
xhr.send();
|
34
34
|
}
|
35
35
|
function downloadFileCallBack(apiUrl, fileId, fileName, otherOption) {
|
36
|
-
var _a = otherOption || {}, authToken = _a.authToken, callbackAfter = _a.callbackAfter;
|
36
|
+
var _a = otherOption || {}, authToken = _a.authToken, callbackAfter = _a.callbackAfter, callbackError = _a.callbackError;
|
37
37
|
var xhr = new XMLHttpRequest();
|
38
38
|
var token = getToken() || authToken;
|
39
39
|
var _apiUrl = apiUrl.endsWith('/')
|
@@ -55,6 +55,9 @@ function downloadFileCallBack(apiUrl, fileId, fileName, otherOption) {
|
|
55
55
|
window.URL.revokeObjectURL(link.href);
|
56
56
|
callbackAfter && callbackAfter();
|
57
57
|
}
|
58
|
+
else {
|
59
|
+
callbackError && callbackError();
|
60
|
+
}
|
58
61
|
};
|
59
62
|
xhr.send();
|
60
63
|
}
|
@@ -65,7 +68,7 @@ function downloadFileCallBack(apiUrl, fileId, fileName, otherOption) {
|
|
65
68
|
* @param {string} fileName 文件名
|
66
69
|
*/
|
67
70
|
function downloadPublicFile(apiUrl, fileId, fileName, otherOption) {
|
68
|
-
var
|
71
|
+
var _a = otherOption || {}, callbackAfter = _a.callbackAfter, callbackError = _a.callbackError;
|
69
72
|
var xhr = new XMLHttpRequest();
|
70
73
|
var _apiUrl = apiUrl.endsWith('/')
|
71
74
|
? apiUrl.slice(0, apiUrl.length - 1)
|
@@ -86,6 +89,9 @@ function downloadPublicFile(apiUrl, fileId, fileName, otherOption) {
|
|
86
89
|
window.URL.revokeObjectURL(link.href);
|
87
90
|
callbackAfter && callbackAfter();
|
88
91
|
}
|
92
|
+
else {
|
93
|
+
callbackError && callbackError();
|
94
|
+
}
|
89
95
|
};
|
90
96
|
xhr.send();
|
91
97
|
}
|