@qn-pandora/pandora-component 4.0.11 → 4.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/CHANGELOG.json CHANGED
@@ -1,6 +1,26 @@
1
1
  {
2
2
  "name": "@qn-pandora/pandora-component",
3
3
  "entries": [
4
+ {
5
+ "version": "4.0.12",
6
+ "tag": "@qn-pandora/pandora-component_v4.0.12",
7
+ "date": "Mon, 29 May 2023 10:29:42 GMT",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "comment": "2023.05.29发包"
12
+ }
13
+ ],
14
+ "dependency": [
15
+ {
16
+ "comment": "Updating dependency \"@qn-pandora/pandora-component-icons\" from `^3.0.14` to `^3.0.15`"
17
+ },
18
+ {
19
+ "comment": "Updating dependency \"@qn-pandora/app-sdk\" from `^3.0.15` to `^3.0.16`"
20
+ }
21
+ ]
22
+ }
23
+ },
4
24
  {
5
25
  "version": "4.0.11",
6
26
  "tag": "@qn-pandora/pandora-component_v4.0.11",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Change Log - @qn-pandora/pandora-component
2
2
 
3
- This log was last generated on Wed, 24 May 2023 07:19:25 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 29 May 2023 10:29:42 GMT and should not be manually modified.
4
+
5
+ ## 4.0.12
6
+
7
+ Mon, 29 May 2023 10:29:42 GMT
8
+
9
+ ### Patches
10
+
11
+ - 2023.05.29 发包
4
12
 
5
13
  ## 4.0.11
6
14
 
@@ -74,12 +74,14 @@ var __read = (this && this.__read) || function (o, n) {
74
74
  };
75
75
  import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
76
76
  import Resumablejs from 'resumablejs';
77
+ import uuid from 'uuid';
78
+ import md5 from 'crypto-js/md5';
77
79
  import { Progress, Tooltip, Upload } from 'antd';
78
80
  import { ConfigContext } from 'antd/es/config-provider';
79
81
  import classnames from 'classnames';
80
82
  import { get } from 'lodash';
81
83
  import { CaretRightOutlined, Upload as UploadIcon, StopFill, Pause, PlusOutlined } from '@qn-pandora/pandora-component-icons';
82
- import { appEnv } from '@qn-pandora/app-sdk';
84
+ import { appEnv, fileIsExit } from '@qn-pandora/app-sdk';
83
85
  import { formatString } from '../../utils/language';
84
86
  import { UploadLocale } from '../../constants/language/upload/type';
85
87
  import { SDK_PREFIX } from '../../constants/style';
@@ -223,12 +225,6 @@ export default function FileResumable(props) {
223
225
  mode,
224
226
  handleReadeImageFile
225
227
  ]);
226
- var handleStart = useCallback(function () {
227
- var _a, _b;
228
- (_a = resumable.current) === null || _a === void 0 ? void 0 : _a.updateQuery(query);
229
- (_b = resumable.current) === null || _b === void 0 ? void 0 : _b.upload();
230
- setShowTool(true);
231
- }, [query, setShowTool]);
232
228
  var handleFileSuccess = useCallback(function (message) {
233
229
  var _a;
234
230
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(message);
@@ -245,11 +241,6 @@ export default function FileResumable(props) {
245
241
  setShowTool,
246
242
  setPercent
247
243
  ]);
248
- var handleUploadStart = useCallback(function () {
249
- setIsPlayDisabled(true);
250
- setIsPauseDisabled(false);
251
- setIsStopDisabled(false);
252
- }, [setIsPlayDisabled, setIsPauseDisabled, setIsStopDisabled]);
253
244
  var handleError = useCallback(function (error) {
254
245
  var _a;
255
246
  (_a = resumable.current) === null || _a === void 0 ? void 0 : _a.cancel();
@@ -269,6 +260,73 @@ export default function FileResumable(props) {
269
260
  setShowTool,
270
261
  onError
271
262
  ]);
263
+ var handleStart = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
264
+ var params, realFile_1, reader;
265
+ var _this = this;
266
+ return __generator(this, function (_a) {
267
+ params = __assign({}, query);
268
+ if (fileList.length === 1) {
269
+ realFile_1 = fileList[0];
270
+ reader = new FileReader();
271
+ reader.readAsText(realFile_1.size > 50 * 1024 * 1024
272
+ ? realFile_1.slice(0, 2 * 1024 * 1024)
273
+ : realFile_1);
274
+ reader.onloadend = function (e) { return __awaiter(_this, void 0, void 0, function () {
275
+ var md5Str, id, fileId, error_1;
276
+ var _a, _b, _c;
277
+ return __generator(this, function (_d) {
278
+ switch (_d.label) {
279
+ case 0:
280
+ if (!(e.target.readyState === FileReader.DONE)) return [3 /*break*/, 5];
281
+ md5Str = md5(e.target.result).toString();
282
+ id = '';
283
+ _d.label = 1;
284
+ case 1:
285
+ _d.trys.push([1, 3, , 4]);
286
+ return [4 /*yield*/, fileIsExit({
287
+ resumableModifyTime: realFile_1.lastModified,
288
+ resumableFilename: realFile_1.name,
289
+ resumableType: realFile_1.type,
290
+ resumableFileMd5: md5Str,
291
+ resumableTotalSize: realFile_1.size
292
+ })];
293
+ case 2:
294
+ fileId = (_d.sent()).fileId;
295
+ id = fileId;
296
+ return [3 /*break*/, 4];
297
+ case 3:
298
+ error_1 = _d.sent();
299
+ handleError(get(error_1, 'message'));
300
+ return [3 /*break*/, 4];
301
+ case 4:
302
+ if (!id) {
303
+ params.resumableFileMd5 = md5Str;
304
+ params.resumableModifyTime = realFile_1.lastModified;
305
+ params.resumableIdentifier = uuid();
306
+ (_a = resumable.current) === null || _a === void 0 ? void 0 : _a.updateQuery(params);
307
+ (_b = resumable.current) === null || _b === void 0 ? void 0 : _b.upload();
308
+ }
309
+ else {
310
+ handleFileSuccess(JSON.stringify({
311
+ fileId: id
312
+ }));
313
+ (_c = resumable.current) === null || _c === void 0 ? void 0 : _c.cancel();
314
+ }
315
+ _d.label = 5;
316
+ case 5: return [2 /*return*/];
317
+ }
318
+ });
319
+ }); };
320
+ }
321
+ setShowTool(true);
322
+ return [2 /*return*/];
323
+ });
324
+ }); }, [query, setShowTool, fileList, handleError, handleFileSuccess]);
325
+ var handleUploadStart = useCallback(function () {
326
+ setIsPlayDisabled(true);
327
+ setIsPauseDisabled(false);
328
+ setIsStopDisabled(false);
329
+ }, [setIsPlayDisabled, setIsPauseDisabled, setIsStopDisabled]);
272
330
  var init = useCallback(function () {
273
331
  var ResumableField = new Resumablejs(__assign(__assign({ permanentErrors: [400, 404, 415, 500, 501, 409] }, others), { target: others.target || appEnv.getApiPrefix() + "/upload/file" }));
274
332
  ResumableField.on('fileSuccess', function (_file, message) {