@pisell/materials 1.0.626 → 1.0.628

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.
Files changed (42) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +1 -1
  6. package/build/lowcode/preview.js +20 -12
  7. package/build/lowcode/render/default/view.js +48 -28
  8. package/build/lowcode/view.js +46 -26
  9. package/es/components/dataSourceComponents/fields/DatePicker/ReadPretty.d.ts +2 -3
  10. package/es/components/dataSourceComponents/fields/DatePicker/ReadPretty.js +11 -7
  11. package/es/components/dataSourceComponents/fields/DatePicker/type.d.ts +1 -0
  12. package/es/components/dataSourceComponents/fields/Input.Mobile/serve.js +31 -3
  13. package/es/components/dataSourceComponents/fields/Input.Phone/serve.js +31 -3
  14. package/es/components/dataSourceComponents/fields/Upload/BaseUpload.js +106 -172
  15. package/es/components/dataSourceComponents/fields/Upload/WithMode.js +6 -3
  16. package/es/components/dataSourceComponents/fields/Upload/serve.js +13 -3
  17. package/es/components/dataSourceComponents/fields/Upload/shopUploadServe.d.ts +56 -0
  18. package/es/components/dataSourceComponents/fields/Upload/shopUploadServe.js +396 -0
  19. package/es/components/dataSourceComponents/fields/Upload/type.d.ts +1 -0
  20. package/es/components/dataSourceComponents/fields/Upload/utils.d.ts +1 -0
  21. package/es/components/dataSourceComponents/fields/Upload/utils.js +17 -2
  22. package/es/components/dataSourceComponents/hooks/usePlatform.d.ts +3 -0
  23. package/es/components/dataSourceComponents/hooks/usePlatform.js +12 -0
  24. package/lib/components/dataSourceComponents/fields/DatePicker/ReadPretty.d.ts +2 -3
  25. package/lib/components/dataSourceComponents/fields/DatePicker/ReadPretty.js +11 -5
  26. package/lib/components/dataSourceComponents/fields/DatePicker/type.d.ts +1 -0
  27. package/lib/components/dataSourceComponents/fields/Input.Mobile/serve.js +37 -3
  28. package/lib/components/dataSourceComponents/fields/Input.Phone/serve.js +37 -3
  29. package/lib/components/dataSourceComponents/fields/Upload/BaseUpload.js +48 -98
  30. package/lib/components/dataSourceComponents/fields/Upload/WithMode.js +11 -9
  31. package/lib/components/dataSourceComponents/fields/Upload/serve.js +11 -2
  32. package/lib/components/dataSourceComponents/fields/Upload/shopUploadServe.d.ts +56 -0
  33. package/lib/components/dataSourceComponents/fields/Upload/shopUploadServe.js +248 -0
  34. package/lib/components/dataSourceComponents/fields/Upload/type.d.ts +1 -0
  35. package/lib/components/dataSourceComponents/fields/Upload/utils.d.ts +1 -0
  36. package/lib/components/dataSourceComponents/fields/Upload/utils.js +19 -2
  37. package/lib/components/dataSourceComponents/hooks/usePlatform.d.ts +3 -0
  38. package/lib/components/dataSourceComponents/hooks/usePlatform.js +51 -0
  39. package/lowcode/form-item-upload/meta.ts +11 -0
  40. package/package.json +4 -3
  41. package/es/components/dataSourceComponents/fields/DatePicker/ReadPretty.d.ts.map +0 -1
  42. package/lib/components/dataSourceComponents/fields/DatePicker/ReadPretty.d.ts.map +0 -1
@@ -1,19 +1,22 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
  import React, { useMemo } from 'react';
3
+ import { isNumber } from '@pisell/utils';
3
4
  import { withMode } from "../../dataSourceForm/utils";
4
5
  import ReadPretty from "./ReadPretty";
5
6
  import BaseUpload from "./BaseUpload";
6
7
  import { useMediaTypes, useMediaConfig } from "./serve";
7
- import { isNumber } from '@pisell/utils';
8
+ import { useIsShop } from "../../hooks/usePlatform";
8
9
  var Upload = function Upload(props) {
10
+ var isShop = useIsShop();
9
11
  var presetType = props.presetType,
10
- propsMediaConfig = props.mediaConfig;
12
+ propsMediaConfig = props.mediaConfig,
13
+ propsPresetTypeString = props.presetTypeString;
11
14
  var _useMediaTypes = useMediaTypes(),
12
15
  getExtensionsByIds = _useMediaTypes.getExtensionsByIds,
13
16
  getMaxSizeByIds = _useMediaTypes.getMaxSizeByIds;
14
17
  var _useMediaConfig = useMediaConfig(propsMediaConfig),
15
18
  mediaConfig = _useMediaConfig.data;
16
- var presetTypeString = getExtensionsByIds(presetType || []);
19
+ var presetTypeString = isShop ? propsPresetTypeString : getExtensionsByIds(presetType || []);
17
20
  var maxSizeMap = getMaxSizeByIds(presetType || []);
18
21
  var maxCount = useMemo(function () {
19
22
  var minArr = [];
@@ -8,11 +8,12 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
8
8
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
9
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
10
10
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
11
+ import { useEffect } from 'react';
11
12
  import { useRequest } from 'ahooks';
12
13
  import { getPointSuffix } from "./utils";
13
14
  import { request } from "../../../table/utils";
14
15
  import useEngineContext from "../../../../hooks/useEngineContext";
15
-
16
+ import { useIsShop } from "../../hooks/usePlatform";
16
17
  /**
17
18
  * 获取nocobase媒体数据列表
18
19
  */
@@ -56,13 +57,22 @@ export var useMediaConfig = function useMediaConfig(mediaConfig) {
56
57
  };
57
58
  };
58
59
  export var useMediaTypes = function useMediaTypes() {
60
+ var isShop = useIsShop();
59
61
  var _useRequest = useRequest(getMediaTypeList, {
60
62
  cacheKey: 'media-type',
61
63
  staleTime: 1000 * 60 * 5,
62
64
  // 5分钟后数据过期
63
- cacheTime: 1000 * 60 * 60 // 1小时后清除缓存
65
+ cacheTime: 1000 * 60 * 60,
66
+ // 1小时后清除缓存
67
+ manual: true
64
68
  }),
65
- data = _useRequest.data;
69
+ data = _useRequest.data,
70
+ run = _useRequest.run;
71
+ useEffect(function () {
72
+ if (!isShop) {
73
+ run();
74
+ }
75
+ }, [isShop]);
66
76
  var getExtensionsByIds = function getExtensionsByIds(ids) {
67
77
  var extensions = [];
68
78
  (data || []).forEach(function (item) {
@@ -0,0 +1,56 @@
1
+ import { RcFile } from 'antd/es/upload';
2
+ export declare const filetypes: Record<string, any>;
3
+ /**
4
+ * @Title: 获取 阿里云 Signature
5
+ * @Describe:
6
+ * @Author: Wzw
7
+ */
8
+ export declare const getPolicy: () => Promise<any>;
9
+ export declare const getPolicyFile: () => Promise<any>;
10
+ /**
11
+ * @Title: 获取图片尺寸
12
+ * @Describe:
13
+ * @Author: Wzw
14
+ * @param {*} async
15
+ */
16
+ export declare const getImageWidth: (file: any) => Promise<{
17
+ width: number;
18
+ height: number;
19
+ }>;
20
+ /**
21
+ * @Title: 重新生成文件名
22
+ * @Describe:
23
+ * @Author: Wzw
24
+ * @param {string} file
25
+ */
26
+ export declare const formatFileName: (file?: any) => Promise<string>;
27
+ export declare const uploadFileAli: (file: any) => Promise<any>;
28
+ /**
29
+ * @Title: base64转file
30
+ * @Describe:
31
+ * @Author: Wzw
32
+ * @param {any} dataurl
33
+ * @param {string} filename
34
+ */
35
+ export declare const dataURLtoFile: (dataurl: any, filename: string) => File;
36
+ /**
37
+ * @Title: 获取视频封面
38
+ * @Describe:
39
+ * @Author: Wzw
40
+ * @param {any} file
41
+ */
42
+ export declare const getVideoCover: (file: any) => Promise<unknown>;
43
+ /**
44
+ * @Title: 获取腾讯云 Signature
45
+ * @Describe:
46
+ * @Author: Wzw
47
+ */
48
+ export declare const getSignature: () => Promise<any>;
49
+ /**
50
+ * @Title: 上传到腾讯云
51
+ * @Describe:
52
+ * @Author: Wzw
53
+ * @param {any} file
54
+ */
55
+ export declare const uploadFileTencent: (file: any) => Promise<unknown>;
56
+ export declare const uploadFile: (file: RcFile) => Promise<any>;
@@ -0,0 +1,396 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
8
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
9
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
10
+ import dayjs from 'dayjs';
11
+ import { getUniqueId } from '@pisell/utils';
12
+ import TcVod from 'vod-js-sdk-v6';
13
+ import { request } from "../../../table/utils";
14
+ export var filetypes = {
15
+ 'vnd.openxmlformats-officedocument.wordprocessingml.document': {
16
+ icon: 'iconword',
17
+ type: 'applicatio',
18
+ format: 'docx'
19
+ },
20
+ 'vnd.openxmlformats-officedocument.spreadsheetml.sheet': {
21
+ icon: 'iconxlsx',
22
+ type: 'applicatio',
23
+ format: 'xlsx'
24
+ },
25
+ csv: {
26
+ icon: 'icontxt',
27
+ type: 'text',
28
+ format: 'csv'
29
+ },
30
+ 'vnd.ms-excel': {
31
+ icon: 'iconxlsx',
32
+ type: 'applicatio',
33
+ format: 'xls'
34
+ },
35
+ msword: {
36
+ icon: 'iconword',
37
+ type: 'applicatio',
38
+ format: 'doc'
39
+ },
40
+ pdf: {
41
+ icon: 'iconpdf',
42
+ type: 'applicatio',
43
+ format: 'pdf'
44
+ }
45
+ };
46
+
47
+ /**
48
+ * @Title: 获取 阿里云 Signature
49
+ * @Describe:
50
+ * @Author: Wzw
51
+ */
52
+ export var getPolicy = function getPolicy() {
53
+ return request.getRequest().get('/shop/ali-upload/policy', {
54
+ type: 'image'
55
+ });
56
+ };
57
+ export var getPolicyFile = function getPolicyFile() {
58
+ return request.getRequest().get('/shop/ali-upload/policy', {
59
+ type: 'file'
60
+ });
61
+ };
62
+
63
+ /**
64
+ * @Title: 获取图片尺寸
65
+ * @Describe:
66
+ * @Author: Wzw
67
+ * @param {*} async
68
+ */
69
+ export var getImageWidth = /*#__PURE__*/function () {
70
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(file) {
71
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
72
+ while (1) switch (_context.prev = _context.next) {
73
+ case 0:
74
+ return _context.abrupt("return", new Promise(function (resolve, reject) {
75
+ try {
76
+ var url = window.URL || window.webkitURL;
77
+ var img = new Image();
78
+ img.src = url.createObjectURL(file);
79
+ img.onload = function () {
80
+ resolve({
81
+ width: img.width,
82
+ height: img.height
83
+ });
84
+ };
85
+ img.onerror = function () {
86
+ resolve({
87
+ width: 0,
88
+ height: 0
89
+ });
90
+ };
91
+ } catch (err) {
92
+ resolve({
93
+ width: 0,
94
+ height: 0
95
+ });
96
+ }
97
+ }));
98
+ case 1:
99
+ case "end":
100
+ return _context.stop();
101
+ }
102
+ }, _callee);
103
+ }));
104
+ return function getImageWidth(_x) {
105
+ return _ref.apply(this, arguments);
106
+ };
107
+ }();
108
+
109
+ /**
110
+ * @Title: 重新生成文件名
111
+ * @Describe:
112
+ * @Author: Wzw
113
+ * @param {string} file
114
+ */
115
+ export var formatFileName = /*#__PURE__*/function () {
116
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(file) {
117
+ var _filetypes$_suffix;
118
+ var imgSize, _suffix, fileType;
119
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
120
+ while (1) switch (_context2.prev = _context2.next) {
121
+ case 0:
122
+ _context2.next = 2;
123
+ return getImageWidth(file);
124
+ case 2:
125
+ imgSize = _context2.sent;
126
+ _suffix = ((file === null || file === void 0 ? void 0 : file.type) || 'image/png').split('/')[1];
127
+ fileType = (_filetypes$_suffix = filetypes[_suffix]) === null || _filetypes$_suffix === void 0 ? void 0 : _filetypes$_suffix.format;
128
+ if (fileType) {
129
+ _suffix = fileType;
130
+ }
131
+ return _context2.abrupt("return", dayjs().format('YYYY_MM_DD_HH_mm_ss_SSS') + '_' + getUniqueId() + '__' + imgSize.width + '_' + imgSize.height + '__' + '.' + _suffix);
132
+ case 7:
133
+ case "end":
134
+ return _context2.stop();
135
+ }
136
+ }, _callee2);
137
+ }));
138
+ return function formatFileName(_x2) {
139
+ return _ref2.apply(this, arguments);
140
+ };
141
+ }();
142
+ export var uploadFileAli = /*#__PURE__*/function () {
143
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(file) {
144
+ var policyData, _name, formData;
145
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
146
+ while (1) switch (_context3.prev = _context3.next) {
147
+ case 0:
148
+ _context3.next = 2;
149
+ return getPolicy();
150
+ case 2:
151
+ policyData = _context3.sent;
152
+ _context3.next = 5;
153
+ return formatFileName(file);
154
+ case 5:
155
+ _name = _context3.sent;
156
+ formData = new FormData();
157
+ formData.append('Content-Type', 'multipart/form-data');
158
+ formData.append('OSSAccessKeyId', policyData.data.access_key_id);
159
+ formData.append('policy', policyData.data.policy);
160
+ formData.append('Signature', policyData.data.signature);
161
+ formData.append('key', policyData.data.dir + _name);
162
+ formData.append('success_action_status', '200');
163
+ formData.append('callback', policyData.data.callback);
164
+ formData.append('file', file);
165
+ return _context3.abrupt("return", request.getRequest().post(policyData.data.cdn_domain, formData));
166
+ case 16:
167
+ case "end":
168
+ return _context3.stop();
169
+ }
170
+ }, _callee3);
171
+ }));
172
+ return function uploadFileAli(_x3) {
173
+ return _ref3.apply(this, arguments);
174
+ };
175
+ }();
176
+ var uploadAli = /*#__PURE__*/function () {
177
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(file) {
178
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
179
+ while (1) switch (_context4.prev = _context4.next) {
180
+ case 0:
181
+ return _context4.abrupt("return", uploadFileAli(file));
182
+ case 1:
183
+ case "end":
184
+ return _context4.stop();
185
+ }
186
+ }, _callee4);
187
+ }));
188
+ return function uploadAli(_x4) {
189
+ return _ref4.apply(this, arguments);
190
+ };
191
+ }();
192
+
193
+ //建立一个可存取到该file的url
194
+ var getObjectURL = function getObjectURL(file) {
195
+ var url = null;
196
+ //@ts-ignore
197
+ if (window.createObjectURL != undefined) {
198
+ //@ts-ignore
199
+ url = window.createObjectURL(file);
200
+ } else if (window.URL != undefined) {
201
+ // mozilla(firefox)
202
+ url = window.URL.createObjectURL(file);
203
+ } else if (window.webkitURL != undefined) {
204
+ // webkit or chrome
205
+ url = window.webkitURL.createObjectURL(file);
206
+ }
207
+ return url;
208
+ };
209
+
210
+ /**
211
+ * @Title: base64转file
212
+ * @Describe:
213
+ * @Author: Wzw
214
+ * @param {any} dataurl
215
+ * @param {string} filename
216
+ */
217
+ export var dataURLtoFile = function dataURLtoFile(dataurl, filename) {
218
+ var arr = dataurl.split(','),
219
+ mime = arr[0].match(/:(.*?);/)[1],
220
+ bstr = atob(arr[1]),
221
+ n = bstr.length,
222
+ u8arr = new Uint8Array(n);
223
+ while (n--) {
224
+ u8arr[n] = bstr.charCodeAt(n);
225
+ }
226
+ return new File([u8arr], filename, {
227
+ type: mime
228
+ });
229
+ };
230
+
231
+ /**
232
+ * @Title: 获取视频封面
233
+ * @Describe:
234
+ * @Author: Wzw
235
+ * @param {any} file
236
+ */
237
+ export var getVideoCover = function getVideoCover(file) {
238
+ var url = getObjectURL(file);
239
+ return new Promise(function (resolve, reject) {
240
+ try {
241
+ var _video = document.createElement('video');
242
+ _video.setAttribute('crossOrigin', 'anonymous'); //处理跨域
243
+ _video.setAttribute('preload', 'auto');
244
+ _video.muted = true;
245
+ _video.setAttribute('autoplay', 'autoplay');
246
+ _video.src = url;
247
+ _video.addEventListener('loadeddata', function () {
248
+ this.currentTime = 1;
249
+ });
250
+ _video.addEventListener('seeked', function () {
251
+ this.width = this.videoWidth;
252
+ this.height = this.videoHeight;
253
+ if (this.width === 0 || this.height === 0) {
254
+ return resolve('');
255
+ }
256
+ var canvas = document.createElement('canvas');
257
+ var ctx = canvas.getContext('2d');
258
+ canvas.width = this.width;
259
+ canvas.height = this.height;
260
+ if (ctx === null) return;
261
+ ctx.drawImage(this, 0, 0, canvas.width, canvas.height);
262
+ var _cover = canvas.toDataURL('image/jpeg', 1);
263
+ var _cover_name = file.name.split('.')[0] + '_cover.jpeg';
264
+ resolve(dataURLtoFile(_cover, _cover_name));
265
+ });
266
+ } catch (err) {
267
+ reject();
268
+ }
269
+ });
270
+ };
271
+
272
+ /**
273
+ * @Title: 获取腾讯云 Signature
274
+ * @Describe:
275
+ * @Author: Wzw
276
+ */
277
+ export var getSignature = function getSignature() {
278
+ return request.getRequest().get('/shop/core/tx-video-sign').then(function (res) {
279
+ var _res$data;
280
+ return res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.sign;
281
+ });
282
+ };
283
+
284
+ /**
285
+ * @Title: 上传到腾讯云
286
+ * @Describe:
287
+ * @Author: Wzw
288
+ * @param {any} file
289
+ */
290
+ export var uploadFileTencent = /*#__PURE__*/function () {
291
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(file) {
292
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
293
+ while (1) switch (_context6.prev = _context6.next) {
294
+ case 0:
295
+ return _context6.abrupt("return", new Promise( /*#__PURE__*/function () {
296
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(resolve, reject) {
297
+ var coverFile, coverData, tcVod, uploader;
298
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
299
+ while (1) switch (_context5.prev = _context5.next) {
300
+ case 0:
301
+ _context5.prev = 0;
302
+ _context5.next = 3;
303
+ return getVideoCover(file);
304
+ case 3:
305
+ coverFile = _context5.sent;
306
+ console.log(coverFile);
307
+ _context5.next = 7;
308
+ return uploadFileAli(coverFile);
309
+ case 7:
310
+ coverData = _context5.sent;
311
+ tcVod = new TcVod({
312
+ // 传入鉴权函数
313
+ getSignature: getSignature
314
+ });
315
+ uploader = tcVod.upload({
316
+ mediaFile: file,
317
+ mediaName: file.name
318
+ });
319
+ uploader.on('media_upload', function (info) {});
320
+ uploader.done().then(function (doneResult) {
321
+ var _coverData$data, _doneResult$video;
322
+ var res = {
323
+ status: true,
324
+ data: _objectSpread(_objectSpread({}, doneResult), {}, {
325
+ cover: _objectSpread(_objectSpread({}, doneResult === null || doneResult === void 0 ? void 0 : doneResult.cover), {}, {
326
+ url: coverData === null || coverData === void 0 ? void 0 : (_coverData$data = coverData.data) === null || _coverData$data === void 0 ? void 0 : _coverData$data.url
327
+ }),
328
+ url: doneResult === null || doneResult === void 0 ? void 0 : (_doneResult$video = doneResult.video) === null || _doneResult$video === void 0 ? void 0 : _doneResult$video.url
329
+ })
330
+ };
331
+ return resolve(res);
332
+ }).catch(function (err) {
333
+ return reject(err);
334
+ });
335
+ _context5.next = 17;
336
+ break;
337
+ case 14:
338
+ _context5.prev = 14;
339
+ _context5.t0 = _context5["catch"](0);
340
+ return _context5.abrupt("return", reject(_context5.t0));
341
+ case 17:
342
+ case "end":
343
+ return _context5.stop();
344
+ }
345
+ }, _callee5, null, [[0, 14]]);
346
+ }));
347
+ return function (_x6, _x7) {
348
+ return _ref6.apply(this, arguments);
349
+ };
350
+ }()));
351
+ case 1:
352
+ case "end":
353
+ return _context6.stop();
354
+ }
355
+ }, _callee6);
356
+ }));
357
+ return function uploadFileTencent(_x5) {
358
+ return _ref5.apply(this, arguments);
359
+ };
360
+ }();
361
+ /**
362
+ * @Title: 上传至腾讯云
363
+ * @Describe:
364
+ * @Author: Wzw
365
+ * @param {*} async
366
+ */
367
+ var uploadTencent = /*#__PURE__*/function () {
368
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(file) {
369
+ var res;
370
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
371
+ while (1) switch (_context7.prev = _context7.next) {
372
+ case 0:
373
+ _context7.next = 2;
374
+ return uploadFileTencent(file);
375
+ case 2:
376
+ res = _context7.sent;
377
+ return _context7.abrupt("return", res);
378
+ case 4:
379
+ case "end":
380
+ return _context7.stop();
381
+ }
382
+ }, _callee7);
383
+ }));
384
+ return function uploadTencent(_x8) {
385
+ return _ref7.apply(this, arguments);
386
+ };
387
+ }();
388
+ export var uploadFile = function uploadFile(file) {
389
+ if (file.type.startsWith('image')) {
390
+ return uploadAli(file);
391
+ } else if (file.type.startsWith('video')) {
392
+ return uploadTencent(file);
393
+ } else {
394
+ return uploadAli(file);
395
+ }
396
+ };
@@ -15,6 +15,7 @@ export interface UploadProps {
15
15
  maxCount?: number;
16
16
  multiple?: boolean;
17
17
  presetType?: string[];
18
+ presetTypeString?: string[];
18
19
  customType?: string[];
19
20
  enablePresetType?: boolean;
20
21
  enableCustomType?: boolean;
@@ -15,3 +15,4 @@ export declare const getFileMetadataParams: (file: RcFile & {
15
15
  metadata?: MediaMetadata;
16
16
  }) => Record<string, any>;
17
17
  export declare const isValueEqual: (value: any, fileListValue: any) => boolean;
18
+ export declare const getBaseTime: (size: number) => 1000 | 2000 | 4000 | 8000;
@@ -52,14 +52,19 @@ var createVideoMetadata = /*#__PURE__*/function () {
52
52
  return _regeneratorRuntime().wrap(function _callee$(_context) {
53
53
  while (1) switch (_context.prev = _context.next) {
54
54
  case 0:
55
- return _context.abrupt("return", new Promise(function (resolve) {
55
+ return _context.abrupt("return", new Promise(function (resolve, reject) {
56
56
  var video = document.createElement('video');
57
57
  var canvas = document.createElement('canvas');
58
58
  video.preload = 'metadata';
59
59
  var hasMetadata = false;
60
60
  var hasSeeked = false;
61
61
  var tryResolve = function tryResolve() {
62
- if (!hasMetadata || !hasSeeked) return;
62
+ if (!hasMetadata || !hasSeeked) {
63
+ reject();
64
+ console.log('没有元数据或没有seeked');
65
+ return;
66
+ }
67
+ ;
63
68
  canvas.width = video.videoWidth;
64
69
  canvas.height = video.videoHeight;
65
70
  var ctx = canvas.getContext('2d');
@@ -283,4 +288,14 @@ export var isValueEqual = function isValueEqual(value, fileListValue) {
283
288
 
284
289
  // 字符串情况(单文件)
285
290
  return value === fileListValue;
291
+ };
292
+
293
+ // 根据文件大小计算上传时间基数(单位:ms)
294
+ export var getBaseTime = function getBaseTime(size) {
295
+ var KB = 1024;
296
+ var MB = KB * 1024;
297
+ if (size < MB) return 1000; // 1MB以下文件基准时间1秒
298
+ if (size < 5 * MB) return 2000; // 1-5MB文件基准时间2秒
299
+ if (size < 20 * MB) return 4000; // 5-20MB文件基准时间4秒
300
+ return 8000; // 大文件基准时间8秒
286
301
  };
@@ -0,0 +1,3 @@
1
+ declare const usePlatform: () => any;
2
+ declare const useIsShop: () => boolean;
3
+ export { usePlatform, useIsShop };
@@ -0,0 +1,12 @@
1
+ import useEngineContext from "../../../hooks/useEngineContext";
2
+ var usePlatform = function usePlatform() {
3
+ var _context$appHelper, _context$appHelper$co;
4
+ var context = useEngineContext();
5
+ var platform = (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : (_context$appHelper$co = _context$appHelper.constants) === null || _context$appHelper$co === void 0 ? void 0 : _context$appHelper$co.platform;
6
+ return platform;
7
+ };
8
+ var useIsShop = function useIsShop() {
9
+ var platform = usePlatform();
10
+ return platform === 'shop';
11
+ };
12
+ export { usePlatform, useIsShop };
@@ -1,6 +1,5 @@
1
- import React from 'react';
1
+ import type { FC } from 'react';
2
2
  import { DatePickerProps } from './type';
3
3
  import './ReadPretty.less';
4
- declare const DatePickerReadPretty: React.FC<DatePickerProps>;
4
+ declare const DatePickerReadPretty: FC<DatePickerProps>;
5
5
  export default DatePickerReadPretty;
6
- //# sourceMappingURL=ReadPretty.d.ts.map