zmdms-utils 0.0.10 → 0.0.12
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/es/file.d.ts +27 -1
- package/dist/es/file.js +37 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/file.ts +37 -2
- package/src/index.ts +2 -0
package/dist/es/file.d.ts
CHANGED
|
@@ -52,7 +52,33 @@ declare function createDownloadLink(fileId: string, options?: IDownloadLinkOptio
|
|
|
52
52
|
* @returns
|
|
53
53
|
*/
|
|
54
54
|
declare function createOriginalLink(fileId: string, fileName: string, options?: IOriginLinkOptions): string;
|
|
55
|
+
/**
|
|
56
|
+
* 生成缩略图路径
|
|
57
|
+
* @param fileId 附件id
|
|
58
|
+
* @param fileName 附件名称
|
|
59
|
+
* @param options
|
|
60
|
+
* @param options.API_BASEURL {string} 接口请求的前缀地址 非必传
|
|
61
|
+
* @param options.authToken {string} token 非必传
|
|
62
|
+
* @param options.scale {number} 缩略比
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
55
65
|
declare function createThumbnailLink(fileId: string, fileName: string, options: IThumbnailLinkOptions): string;
|
|
66
|
+
/**
|
|
67
|
+
* 生成图片上传地址
|
|
68
|
+
* @param options
|
|
69
|
+
* @param options.API_BASEURL {string} 接口请求的前缀地址 非必传
|
|
70
|
+
* @param options.authToken {string} token 非必传
|
|
71
|
+
* @returns
|
|
72
|
+
*/
|
|
73
|
+
declare function createUploadFileLink(options: IOptions): string;
|
|
74
|
+
/**
|
|
75
|
+
* 生成图片删除地址
|
|
76
|
+
* @param options
|
|
77
|
+
* @param options.API_BASEURL {string} 接口请求的前缀地址 非必传
|
|
78
|
+
* @param options.authToken {string} token 非必传
|
|
79
|
+
* @returns
|
|
80
|
+
*/
|
|
81
|
+
declare function createDeleteFileLink(options: IOptions): string;
|
|
56
82
|
interface IOptions {
|
|
57
83
|
API_BASEURL: string;
|
|
58
84
|
authToken?: string;
|
|
@@ -87,4 +113,4 @@ interface IThumbnailLinkOptions extends Partial<IOptions> {
|
|
|
87
113
|
scale?: number;
|
|
88
114
|
}
|
|
89
115
|
|
|
90
|
-
export { batchDownloadFiles, createDownloadLink, createOriginalLink, createThumbnailLink, downloadFile, previewFile };
|
|
116
|
+
export { batchDownloadFiles, createDeleteFileLink, createDownloadLink, createOriginalLink, createThumbnailLink, createUploadFileLink, downloadFile, previewFile };
|
package/dist/es/file.js
CHANGED
|
@@ -42,7 +42,7 @@ function downloadFile(fileId, fileName, options) {
|
|
|
42
42
|
resolve({ msg: "文件下载成功!" });
|
|
43
43
|
}
|
|
44
44
|
else {
|
|
45
|
-
reject();
|
|
45
|
+
reject(xhr.response);
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
xhr.onerror = function (err) {
|
|
@@ -84,7 +84,7 @@ function batchDownloadFiles(fileList, options) {
|
|
|
84
84
|
resolve({ msg: "文件下载成功!" });
|
|
85
85
|
}
|
|
86
86
|
else {
|
|
87
|
-
reject();
|
|
87
|
+
reject(xhr.response);
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
90
|
xhr.onerror = function (err) {
|
|
@@ -198,11 +198,45 @@ function createOriginalLink(fileId, fileName, options) {
|
|
|
198
198
|
? "&titleName=".concat(encodeURIComponent(previewFileName))
|
|
199
199
|
: "";
|
|
200
200
|
}
|
|
201
|
+
/**
|
|
202
|
+
* 生成缩略图路径
|
|
203
|
+
* @param fileId 附件id
|
|
204
|
+
* @param fileName 附件名称
|
|
205
|
+
* @param options
|
|
206
|
+
* @param options.API_BASEURL {string} 接口请求的前缀地址 非必传
|
|
207
|
+
* @param options.authToken {string} token 非必传
|
|
208
|
+
* @param options.scale {number} 缩略比
|
|
209
|
+
* @returns
|
|
210
|
+
*/
|
|
201
211
|
function createThumbnailLink(fileId, fileName, options) {
|
|
202
212
|
var API_BASEURL = options.API_BASEURL, authToken = options.authToken, _a = options.scale, scale = _a === void 0 ? 0.5 : _a;
|
|
203
213
|
var _b = getBasicInfo(API_BASEURL || "", authToken), token = _b.token, apiBaseURL = _b.apiBaseURL;
|
|
204
214
|
return "".concat(apiBaseURL, "/api/zmdms-resource/oss/endpoint/thumbnail/").concat(fileId, "?scale=").concat(scale, "&Zmdms-Auth=bearer ").concat(token);
|
|
205
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* 生成图片上传地址
|
|
218
|
+
* @param options
|
|
219
|
+
* @param options.API_BASEURL {string} 接口请求的前缀地址 非必传
|
|
220
|
+
* @param options.authToken {string} token 非必传
|
|
221
|
+
* @returns
|
|
222
|
+
*/
|
|
223
|
+
function createUploadFileLink(options) {
|
|
224
|
+
var API_BASEURL = options.API_BASEURL;
|
|
225
|
+
var apiBaseURL = getBasicInfo(API_BASEURL || "").apiBaseURL;
|
|
226
|
+
return "".concat(apiBaseURL, "/api/zmdms-resource/oss/endpoint/put-file-attach");
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* 生成图片删除地址
|
|
230
|
+
* @param options
|
|
231
|
+
* @param options.API_BASEURL {string} 接口请求的前缀地址 非必传
|
|
232
|
+
* @param options.authToken {string} token 非必传
|
|
233
|
+
* @returns
|
|
234
|
+
*/
|
|
235
|
+
function createDeleteFileLink(options) {
|
|
236
|
+
var API_BASEURL = options.API_BASEURL;
|
|
237
|
+
var apiBaseURL = getBasicInfo(API_BASEURL || "").apiBaseURL;
|
|
238
|
+
return "".concat(apiBaseURL, "/api/zmdms-resource/oss/endpoint/remove-file");
|
|
239
|
+
}
|
|
206
240
|
/**
|
|
207
241
|
* 获取基础数据
|
|
208
242
|
* @param baseURL 基础URL
|
|
@@ -219,4 +253,4 @@ function getBasicInfo(baseURL, token) {
|
|
|
219
253
|
};
|
|
220
254
|
}
|
|
221
255
|
|
|
222
|
-
export { batchDownloadFiles, createDownloadLink, createOriginalLink, createThumbnailLink, downloadFile, previewFile };
|
|
256
|
+
export { batchDownloadFiles, createDeleteFileLink, createDownloadLink, createOriginalLink, createThumbnailLink, createUploadFileLink, downloadFile, previewFile };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,4 +9,4 @@ export { addThousedSeparator, copyToClipboard, dangerouslyXss, delay, emitter, g
|
|
|
9
9
|
export { divide, exactRound, formatUnit, minus, plus, times } from './es/math.js';
|
|
10
10
|
export { validatePassword } from './es/passwordValidate.js';
|
|
11
11
|
export { emailValidate, idCardValidate, morePhoneValidate, phoneValidate, strLenValidate } from './es/validate.js';
|
|
12
|
-
export { batchDownloadFiles, createDownloadLink, createOriginalLink, createThumbnailLink, downloadFile, previewFile } from './es/file.js';
|
|
12
|
+
export { batchDownloadFiles, createDeleteFileLink, createDownloadLink, createOriginalLink, createThumbnailLink, createUploadFileLink, downloadFile, previewFile } from './es/file.js';
|
package/dist/index.js
CHANGED
|
@@ -9,4 +9,4 @@ export { addThousedSeparator, copyToClipboard, dangerouslyXss, delay, emitter, g
|
|
|
9
9
|
export { divide, exactRound, formatUnit, minus, plus, times } from './es/math.js';
|
|
10
10
|
export { validatePassword } from './es/passwordValidate.js';
|
|
11
11
|
export { emailValidate, idCardValidate, morePhoneValidate, phoneValidate, strLenValidate } from './es/validate.js';
|
|
12
|
-
export { batchDownloadFiles, createDownloadLink, createOriginalLink, createThumbnailLink, downloadFile, previewFile } from './es/file.js';
|
|
12
|
+
export { batchDownloadFiles, createDeleteFileLink, createDownloadLink, createOriginalLink, createThumbnailLink, createUploadFileLink, downloadFile, previewFile } from './es/file.js';
|
package/package.json
CHANGED
package/src/file.ts
CHANGED
|
@@ -62,7 +62,7 @@ export function downloadFile(
|
|
|
62
62
|
|
|
63
63
|
resolve({ msg: "文件下载成功!" });
|
|
64
64
|
} else {
|
|
65
|
-
reject();
|
|
65
|
+
reject(xhr.response);
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
xhr.onerror = function (err) {
|
|
@@ -119,7 +119,7 @@ export function batchDownloadFiles(
|
|
|
119
119
|
|
|
120
120
|
resolve({ msg: "文件下载成功!" });
|
|
121
121
|
} else {
|
|
122
|
-
reject();
|
|
122
|
+
reject(xhr.response);
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
125
|
xhr.onerror = function (err) {
|
|
@@ -251,6 +251,16 @@ export function createOriginalLink(
|
|
|
251
251
|
: "";
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
+
/**
|
|
255
|
+
* 生成缩略图路径
|
|
256
|
+
* @param fileId 附件id
|
|
257
|
+
* @param fileName 附件名称
|
|
258
|
+
* @param options
|
|
259
|
+
* @param options.API_BASEURL {string} 接口请求的前缀地址 非必传
|
|
260
|
+
* @param options.authToken {string} token 非必传
|
|
261
|
+
* @param options.scale {number} 缩略比
|
|
262
|
+
* @returns
|
|
263
|
+
*/
|
|
254
264
|
export function createThumbnailLink(
|
|
255
265
|
fileId: string,
|
|
256
266
|
fileName: string,
|
|
@@ -261,6 +271,31 @@ export function createThumbnailLink(
|
|
|
261
271
|
return `${apiBaseURL}/api/zmdms-resource/oss/endpoint/thumbnail/${fileId}?scale=${scale}&Zmdms-Auth=bearer ${token}`;
|
|
262
272
|
}
|
|
263
273
|
|
|
274
|
+
/**
|
|
275
|
+
* 生成图片上传地址
|
|
276
|
+
* @param options
|
|
277
|
+
* @param options.API_BASEURL {string} 接口请求的前缀地址 非必传
|
|
278
|
+
* @param options.authToken {string} token 非必传
|
|
279
|
+
* @returns
|
|
280
|
+
*/
|
|
281
|
+
export function createUploadFileLink(options: IOptions) {
|
|
282
|
+
const { API_BASEURL } = options;
|
|
283
|
+
const { apiBaseURL } = getBasicInfo(API_BASEURL || "");
|
|
284
|
+
return `${apiBaseURL}/api/zmdms-resource/oss/endpoint/put-file-attach`;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* 生成图片删除地址
|
|
288
|
+
* @param options
|
|
289
|
+
* @param options.API_BASEURL {string} 接口请求的前缀地址 非必传
|
|
290
|
+
* @param options.authToken {string} token 非必传
|
|
291
|
+
* @returns
|
|
292
|
+
*/
|
|
293
|
+
export function createDeleteFileLink(options: IOptions) {
|
|
294
|
+
const { API_BASEURL } = options;
|
|
295
|
+
const { apiBaseURL } = getBasicInfo(API_BASEURL || "");
|
|
296
|
+
return `${apiBaseURL}/api/zmdms-resource/oss/endpoint/remove-file`;
|
|
297
|
+
}
|
|
298
|
+
|
|
264
299
|
/**
|
|
265
300
|
* 获取基础数据
|
|
266
301
|
* @param baseURL 基础URL
|