@pisell/materials 6.0.18 → 6.0.20
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +7 -7
- package/build/lowcode/preview.js +146 -146
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +51 -20
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +51 -20
- package/es/components/badge/index.d.ts +7 -0
- package/es/components/badge/index.js +44 -0
- package/es/components/badge/index.less +2 -0
- package/es/components/buttonGroupEdit/index.d.ts +8 -0
- package/es/components/buttonGroupEdit/index.js +408 -0
- package/es/components/buttonGroupPreview/index.d.ts +19 -0
- package/es/components/buttonGroupPreview/index.js +74 -0
- package/es/components/cardMetricItem/index.d.ts +12 -0
- package/es/components/cardMetricItem/index.js +39 -0
- package/es/components/cardMetricItem/index.less +39 -0
- package/es/components/cardPro/index.d.ts +3 -0
- package/es/components/cardPro/index.js +66 -0
- package/es/components/cardPro/index.less +55 -0
- package/es/components/cropPhoto/index.d.ts +3 -0
- package/es/components/cropPhoto/index.js +72 -0
- package/es/components/cropPhoto/index.less +15 -0
- package/es/components/dataSourceComponents/dataSourceMenu/Basic.d.ts +8 -2
- package/es/components/dataSourceComponents/dataSourceMenu/Basic.js +13 -3
- package/es/components/dataSourceComponents/dataSourceMenu/index.d.ts +8 -2
- package/es/components/dataSourceComponents/fields/Input/WithMode.js +24 -1
- package/es/components/dataSourceComponents/fields/Input.Mobile/serve.js +31 -3
- package/es/components/dataSourceComponents/fields/Input.Phone/serve.js +31 -3
- package/es/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +1 -1
- package/es/components/dataSourceComponents/fields/Input.Url/ReadPretty.less +2 -0
- package/es/components/dataSourceComponents/fields/Upload/BaseUpload.js +102 -141
- package/es/components/dataSourceComponents/fields/Upload/WithMode.js +6 -3
- package/es/components/dataSourceComponents/fields/Upload/serve.js +13 -3
- package/es/components/dataSourceComponents/fields/Upload/shopUploadServe.d.ts +56 -0
- package/es/components/dataSourceComponents/fields/Upload/shopUploadServe.js +396 -0
- package/es/components/dataSourceComponents/fields/Upload/type.d.ts +1 -0
- package/es/components/dataSourceComponents/fields/Upload/utils.d.ts +1 -0
- package/es/components/dataSourceComponents/fields/Upload/utils.js +17 -2
- package/es/components/dataSourceComponents/fields/index.d.ts +8 -8
- package/es/components/dataSourceComponents/hooks/usePlatform.d.ts +3 -0
- package/es/components/dataSourceComponents/hooks/usePlatform.js +12 -0
- package/es/components/login-and-register/index.js +23 -21
- package/es/components/login-and-register/index.less +7 -7
- package/es/components/page/index.js +23 -57
- package/es/components/pisellAnchor/index.d.ts +23 -0
- package/es/components/pisellAnchor/index.js +303 -0
- package/es/components/pisellAnchor/index.less +197 -0
- package/es/components/pisellNavigationMenu/PisellNavigationMenu.js +18 -2
- package/es/components/pisellQrcode/index.d.ts +10 -0
- package/es/components/pisellQrcode/index.js +70 -0
- package/es/components/pisellQrcode/index.less +41 -0
- package/es/components/pisellStatisticList/index.d.ts +3 -0
- package/es/components/pisellStatisticList/index.js +17 -5
- package/es/components/pisellStatisticList/index.less +1 -1
- package/es/components/pisellText/components/Amount/index.d.ts +2 -0
- package/es/components/pisellText/components/Amount/index.js +3 -2
- package/es/components/pisellWalletPassCard/index.d.ts +4 -4
- package/es/components/pisellWalletPassCard/index.js +28 -12
- package/es/components/pisellWalletPassCard/index.less +26 -4
- package/es/components/record-view/index.d.ts +13 -5
- package/es/components/record-view/index.js +81 -30
- package/es/components/record-view/index.less +37 -2
- package/es/components/table/Table/utils.d.ts +1 -1
- package/es/components/tabs/index.d.ts +1 -0
- package/es/components/tabs/index.js +25 -7
- package/es/components/tabs/index.less +5 -5
- package/es/components/walletCard/Guest/index.d.ts +3 -0
- package/es/components/walletCard/Guest/index.js +83 -0
- package/es/components/walletCard/Guest/index.less +71 -0
- package/es/components/walletCard/index.d.ts +65 -0
- package/es/components/walletCard/index.js +402 -0
- package/es/components/walletCard/index.less +267 -0
- package/es/index.d.ts +10 -1
- package/es/index.js +10 -1
- package/es/locales/en-US.d.ts +38 -2
- package/es/locales/en-US.js +55 -10
- package/es/locales/index.js +4 -2
- package/es/locales/zh-CN.d.ts +36 -0
- package/es/locales/zh-CN.js +41 -1
- package/es/locales/zh-TW.d.ts +36 -0
- package/es/locales/zh-TW.js +41 -1
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +3 -0
- package/es/utils/platform.d.ts +1 -1
- package/lib/components/badge/index.d.ts +7 -0
- package/lib/components/badge/index.js +70 -0
- package/lib/components/badge/index.less +2 -0
- package/lib/components/buttonGroupEdit/index.d.ts +8 -0
- package/lib/components/buttonGroupEdit/index.js +317 -0
- package/lib/components/buttonGroupPreview/index.d.ts +19 -0
- package/lib/components/buttonGroupPreview/index.js +79 -0
- package/lib/components/cardMetricItem/index.d.ts +12 -0
- package/lib/components/cardMetricItem/index.js +75 -0
- package/lib/components/cardMetricItem/index.less +39 -0
- package/lib/components/cardPro/index.d.ts +3 -0
- package/lib/components/cardPro/index.js +98 -0
- package/lib/components/cardPro/index.less +55 -0
- package/lib/components/cropPhoto/index.d.ts +3 -0
- package/lib/components/cropPhoto/index.js +70 -0
- package/lib/components/cropPhoto/index.less +15 -0
- package/lib/components/dataSourceComponents/dataSourceMenu/Basic.d.ts +8 -2
- package/lib/components/dataSourceComponents/dataSourceMenu/Basic.js +12 -3
- package/lib/components/dataSourceComponents/dataSourceMenu/index.d.ts +8 -2
- package/lib/components/dataSourceComponents/fields/Input/WithMode.js +21 -0
- package/lib/components/dataSourceComponents/fields/Input.Mobile/serve.js +37 -3
- package/lib/components/dataSourceComponents/fields/Input.Phone/serve.js +37 -3
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +1 -1
- package/lib/components/dataSourceComponents/fields/Input.Url/ReadPretty.less +2 -0
- package/lib/components/dataSourceComponents/fields/Upload/BaseUpload.js +47 -72
- package/lib/components/dataSourceComponents/fields/Upload/WithMode.js +11 -9
- package/lib/components/dataSourceComponents/fields/Upload/serve.js +11 -2
- package/lib/components/dataSourceComponents/fields/Upload/shopUploadServe.d.ts +56 -0
- package/lib/components/dataSourceComponents/fields/Upload/shopUploadServe.js +247 -0
- package/lib/components/dataSourceComponents/fields/Upload/type.d.ts +1 -0
- package/lib/components/dataSourceComponents/fields/Upload/utils.d.ts +1 -0
- package/lib/components/dataSourceComponents/fields/Upload/utils.js +17 -2
- package/lib/components/dataSourceComponents/fields/index.d.ts +8 -8
- package/lib/components/dataSourceComponents/hooks/usePlatform.d.ts +3 -0
- package/lib/components/dataSourceComponents/hooks/usePlatform.js +51 -0
- package/lib/components/login-and-register/index.js +23 -21
- package/lib/components/login-and-register/index.less +7 -7
- package/lib/components/page/index.js +37 -65
- package/lib/components/pisellAnchor/index.d.ts +23 -0
- package/lib/components/pisellAnchor/index.js +251 -0
- package/lib/components/pisellAnchor/index.less +197 -0
- package/lib/components/pisellNavigationMenu/PisellNavigationMenu.js +24 -3
- package/lib/components/pisellQrcode/index.d.ts +10 -0
- package/lib/components/pisellQrcode/index.js +82 -0
- package/lib/components/pisellQrcode/index.less +41 -0
- package/lib/components/pisellStatisticList/index.d.ts +3 -0
- package/lib/components/pisellStatisticList/index.js +35 -15
- package/lib/components/pisellStatisticList/index.less +1 -1
- package/lib/components/pisellText/components/Amount/index.d.ts +2 -0
- package/lib/components/pisellText/components/Amount/index.js +2 -1
- package/lib/components/pisellWalletPassCard/index.d.ts +4 -4
- package/lib/components/pisellWalletPassCard/index.js +17 -9
- package/lib/components/pisellWalletPassCard/index.less +26 -4
- package/lib/components/record-view/index.d.ts +13 -5
- package/lib/components/record-view/index.js +63 -11
- package/lib/components/record-view/index.less +37 -2
- package/lib/components/table/Table/utils.d.ts +1 -1
- package/lib/components/tabs/index.d.ts +1 -0
- package/lib/components/tabs/index.js +12 -1
- package/lib/components/tabs/index.less +5 -5
- package/lib/components/walletCard/Guest/index.d.ts +3 -0
- package/lib/components/walletCard/Guest/index.js +138 -0
- package/lib/components/walletCard/Guest/index.less +71 -0
- package/lib/components/walletCard/index.d.ts +65 -0
- package/lib/components/walletCard/index.js +374 -0
- package/lib/components/walletCard/index.less +267 -0
- package/lib/index.d.ts +10 -1
- package/lib/index.js +26 -1
- package/lib/locales/en-US.d.ts +38 -2
- package/lib/locales/en-US.js +41 -3
- package/lib/locales/index.js +4 -2
- package/lib/locales/zh-CN.d.ts +36 -0
- package/lib/locales/zh-CN.js +41 -1
- package/lib/locales/zh-TW.d.ts +36 -0
- package/lib/locales/zh-TW.js +41 -1
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +6 -1
- package/lib/utils/platform.d.ts +1 -1
- package/lowcode/badge/meta.ts +20 -11
- package/lowcode/badge/snippets.ts +2 -0
- package/lowcode/button/meta.ts +2 -6
- package/lowcode/button-group/meta.ts +198 -0
- package/lowcode/button-group/snippets.ts +68 -0
- package/lowcode/button-group-edit/meta.ts +32 -0
- package/lowcode/button-group-edit/snippets.ts +98 -0
- package/lowcode/button-group-preview/meta.ts +55 -0
- package/lowcode/button-group-preview/snippets.ts +57 -0
- package/lowcode/card/snippets.ts +55 -55
- package/lowcode/card-metric-item/meta.ts +83 -0
- package/lowcode/card-metric-item/snippets.ts +13 -0
- package/lowcode/card-pro/meta.ts +338 -0
- package/lowcode/card-pro/snippe.ts +39 -0
- package/lowcode/crop-photo/meta.ts +77 -0
- package/lowcode/crop-photo/snippe.ts +12 -0
- package/lowcode/form-item-input/snippets.ts +1 -1
- package/lowcode/form-item-upload/meta.ts +11 -0
- package/lowcode/pisell-anchor/meta.ts +118 -0
- package/lowcode/pisell-anchor/snippets.ts +26 -0
- package/lowcode/pisell-card/meta.ts +63 -27
- package/lowcode/pisell-card/snippets.ts +6 -0
- package/lowcode/pisell-modal.information/meta.ts +8 -0
- package/lowcode/pisell-qrcode/__screenshots__/upload-1.png +0 -0
- package/lowcode/pisell-qrcode/meta.ts +46 -0
- package/lowcode/pisell-qrcode/snippets.ts +13 -0
- package/lowcode/pisell-tooltip/meta.ts +1 -1
- package/lowcode/record-view/meta.ts +20 -0
- package/lowcode/section-footers/meta.ts +66 -0
- package/lowcode/section-footers/snippe.ts +21 -0
- package/lowcode/spin/meta.ts +9 -0
- package/lowcode/tag/meta.ts +6 -0
- package/lowcode/timeline/meta.ts +32 -9
- package/lowcode/timeline/snippets.ts +12 -2
- package/lowcode/timeline.item/meta.ts +1 -1
- package/lowcode/wallet-card/meta.ts +283 -0
- package/lowcode/wallet-card/snippets.ts +44 -0
- package/package.json +5 -1
|
@@ -2,10 +2,6 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
2
2
|
var _excluded = ["renderMode", "maxSize", "minCount", "maxCount", "multiple", "presetType", "customType", "enablePresetType", "enableCustomType", "allowPreview", "value", "typeMaxSizeMap", "enableMultilingual", "onChange", "mediaUploadUrl", "getHeaders"],
|
|
3
3
|
_excluded2 = ["cover"];
|
|
4
4
|
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); }
|
|
5
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
9
5
|
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
10
6
|
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); } }
|
|
11
7
|
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); }); }; }
|
|
@@ -14,6 +10,10 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
14
10
|
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; }
|
|
15
11
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
16
12
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
14
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
16
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
17
17
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
18
18
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
19
19
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -34,7 +34,9 @@ import PisellUpload from "../../../pisellUpload";
|
|
|
34
34
|
import useEngineContext from "../../../../hooks/useEngineContext";
|
|
35
35
|
import { getText } from "../../../../locales";
|
|
36
36
|
import { DEFAULT_MAX_COUNT, SUPPORTED_LANGUAGES } from "./constants";
|
|
37
|
-
import {
|
|
37
|
+
import { useIsShop } from "../../hooks/usePlatform";
|
|
38
|
+
import { getPointSuffix, getFileType, getMediaMetadata, getFileMetadataParams, getDefaultFileList, createMultilingualData, createMultilingualFileList, isValueEqual, getBaseTime } from "./utils";
|
|
39
|
+
import { uploadFile } from "./shopUploadServe";
|
|
38
40
|
|
|
39
41
|
// @ts-ignore
|
|
40
42
|
import fallback from "./fallback.png";
|
|
@@ -57,6 +59,7 @@ var BaseUpload = function BaseUpload(props) {
|
|
|
57
59
|
propsMediaUploadUrl = props.mediaUploadUrl,
|
|
58
60
|
propsGetHeaders = props.getHeaders,
|
|
59
61
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
62
|
+
var isShop = useIsShop();
|
|
60
63
|
var _useState = useState([]),
|
|
61
64
|
_useState2 = _slicedToArray(_useState, 2),
|
|
62
65
|
fileList = _useState2[0],
|
|
@@ -77,10 +80,6 @@ var BaseUpload = function BaseUpload(props) {
|
|
|
77
80
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
78
81
|
editMultilingualFile = _useState10[0],
|
|
79
82
|
setEditMultilingualFile = _useState10[1];
|
|
80
|
-
var _useState11 = useState({}),
|
|
81
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
82
|
-
errorImageMap = _useState12[0],
|
|
83
|
-
setErrorImageMap = _useState12[1];
|
|
84
83
|
var fileListRef = useRef([]);
|
|
85
84
|
useEffect(function () {
|
|
86
85
|
fileListRef.current = fileList;
|
|
@@ -90,72 +89,6 @@ var BaseUpload = function BaseUpload(props) {
|
|
|
90
89
|
var _ref = (appHelper === null || appHelper === void 0 ? void 0 : appHelper.constants) || {},
|
|
91
90
|
mediaUploadUrl = _ref.mediaUploadUrl,
|
|
92
91
|
getHeaders = _ref.getHeaders;
|
|
93
|
-
var handleImageError = useCallback(function (file) {
|
|
94
|
-
setErrorImageMap(function (prev) {
|
|
95
|
-
return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, file.uid, true));
|
|
96
|
-
});
|
|
97
|
-
}, []);
|
|
98
|
-
var checkImageUrl = useCallback(function (url) {
|
|
99
|
-
return new Promise(function (resolve) {
|
|
100
|
-
var img = document.createElement('img');
|
|
101
|
-
img.onload = function () {
|
|
102
|
-
return resolve(true);
|
|
103
|
-
};
|
|
104
|
-
img.onerror = function () {
|
|
105
|
-
return resolve(false);
|
|
106
|
-
};
|
|
107
|
-
img.src = url;
|
|
108
|
-
});
|
|
109
|
-
}, []);
|
|
110
|
-
var getItemUrl = useCallback( /*#__PURE__*/function () {
|
|
111
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(file) {
|
|
112
|
-
var _file$response;
|
|
113
|
-
var url, isValid;
|
|
114
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
115
|
-
while (1) switch (_context.prev = _context.next) {
|
|
116
|
-
case 0:
|
|
117
|
-
if (!errorImageMap[file.uid]) {
|
|
118
|
-
_context.next = 2;
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
return _context.abrupt("return", fallback);
|
|
122
|
-
case 2:
|
|
123
|
-
url = file.url || ((_file$response = file.response) === null || _file$response === void 0 || (_file$response = _file$response.data) === null || _file$response === void 0 ? void 0 : _file$response.url) || '';
|
|
124
|
-
if (url) {
|
|
125
|
-
_context.next = 5;
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
return _context.abrupt("return", '');
|
|
129
|
-
case 5:
|
|
130
|
-
_context.prev = 5;
|
|
131
|
-
_context.next = 8;
|
|
132
|
-
return checkImageUrl(url);
|
|
133
|
-
case 8:
|
|
134
|
-
isValid = _context.sent;
|
|
135
|
-
if (isValid) {
|
|
136
|
-
_context.next = 12;
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
setErrorImageMap(function (prev) {
|
|
140
|
-
return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, file.uid, true));
|
|
141
|
-
});
|
|
142
|
-
return _context.abrupt("return", fallback);
|
|
143
|
-
case 12:
|
|
144
|
-
return _context.abrupt("return", url);
|
|
145
|
-
case 15:
|
|
146
|
-
_context.prev = 15;
|
|
147
|
-
_context.t0 = _context["catch"](5);
|
|
148
|
-
return _context.abrupt("return", fallback);
|
|
149
|
-
case 18:
|
|
150
|
-
case "end":
|
|
151
|
-
return _context.stop();
|
|
152
|
-
}
|
|
153
|
-
}, _callee, null, [[5, 15]]);
|
|
154
|
-
}));
|
|
155
|
-
return function (_x) {
|
|
156
|
-
return _ref2.apply(this, arguments);
|
|
157
|
-
};
|
|
158
|
-
}(), [errorImageMap]);
|
|
159
92
|
useEffect(function () {
|
|
160
93
|
// 只在 value 变化且不是由内部 onChange 触发时才更新 fileList
|
|
161
94
|
var currentValue = getValueFromFileList(fileListRef.current);
|
|
@@ -165,7 +98,6 @@ var BaseUpload = function BaseUpload(props) {
|
|
|
165
98
|
multiple: !!multiple
|
|
166
99
|
});
|
|
167
100
|
setFileList(newFileList);
|
|
168
|
-
setErrorImageMap({});
|
|
169
101
|
}
|
|
170
102
|
}, [value, enableMultilingual, multiple]);
|
|
171
103
|
var getValueFromFileList = function getValueFromFileList(fileList) {
|
|
@@ -174,16 +106,16 @@ var BaseUpload = function BaseUpload(props) {
|
|
|
174
106
|
var multilingualValues = fileList.filter(function (file) {
|
|
175
107
|
return file.status === 'done';
|
|
176
108
|
}).map(function (file) {
|
|
177
|
-
var _file$
|
|
178
|
-
return file.multilingual || createMultilingualData(((_file$
|
|
109
|
+
var _file$response;
|
|
110
|
+
return file.multilingual || createMultilingualData(((_file$response = file.response) === null || _file$response === void 0 || (_file$response = _file$response.data) === null || _file$response === void 0 ? void 0 : _file$response.url) || file.url || '');
|
|
179
111
|
});
|
|
180
112
|
return multiple ? multilingualValues : multilingualValues[0];
|
|
181
113
|
}
|
|
182
114
|
var urls = fileList.filter(function (file) {
|
|
183
115
|
return file.status === 'done';
|
|
184
116
|
}).map(function (file) {
|
|
185
|
-
var _file$
|
|
186
|
-
return ((_file$
|
|
117
|
+
var _file$response2;
|
|
118
|
+
return ((_file$response2 = file.response) === null || _file$response2 === void 0 || (_file$response2 = _file$response2.data) === null || _file$response2 === void 0 ? void 0 : _file$response2.url) || file.url || '';
|
|
187
119
|
});
|
|
188
120
|
return multiple ? urls : urls[0] || '';
|
|
189
121
|
};
|
|
@@ -226,10 +158,10 @@ var BaseUpload = function BaseUpload(props) {
|
|
|
226
158
|
});
|
|
227
159
|
});
|
|
228
160
|
});
|
|
229
|
-
var handleChange = useCallback(function (
|
|
230
|
-
var _file$
|
|
231
|
-
var file =
|
|
232
|
-
newFileList =
|
|
161
|
+
var handleChange = useCallback(function (_ref2) {
|
|
162
|
+
var _file$response3, _file$response6, _file$response7;
|
|
163
|
+
var file = _ref2.file,
|
|
164
|
+
newFileList = _ref2.fileList;
|
|
233
165
|
var updatedFileList = newFileList.map(function (item) {
|
|
234
166
|
var _item$response3;
|
|
235
167
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
@@ -237,7 +169,7 @@ var BaseUpload = function BaseUpload(props) {
|
|
|
237
169
|
});
|
|
238
170
|
});
|
|
239
171
|
setFileList(updatedFileList);
|
|
240
|
-
if (file.status === 'done' && (_file$
|
|
172
|
+
if (file.status === 'done' && (_file$response3 = file.response) !== null && _file$response3 !== void 0 && _file$response3.status) {
|
|
241
173
|
if (multiple) {
|
|
242
174
|
if (enableMultilingual) {
|
|
243
175
|
var multilingualUrls = updatedFileList.filter(function (item) {
|
|
@@ -259,24 +191,24 @@ var BaseUpload = function BaseUpload(props) {
|
|
|
259
191
|
}
|
|
260
192
|
} else {
|
|
261
193
|
if (enableMultilingual) {
|
|
262
|
-
var _file$
|
|
263
|
-
var multilingualData = createMultilingualData(((_file$
|
|
194
|
+
var _file$response4;
|
|
195
|
+
var multilingualData = createMultilingualData(((_file$response4 = file.response) === null || _file$response4 === void 0 || (_file$response4 = _file$response4.data) === null || _file$response4 === void 0 ? void 0 : _file$response4.url) || '');
|
|
264
196
|
fileDoneSetMultilingualFileList();
|
|
265
197
|
onChange === null || onChange === void 0 || onChange(multilingualData);
|
|
266
198
|
} else {
|
|
267
|
-
var _file$
|
|
268
|
-
onChange === null || onChange === void 0 || onChange(((_file$
|
|
199
|
+
var _file$response5;
|
|
200
|
+
onChange === null || onChange === void 0 || onChange(((_file$response5 = file.response) === null || _file$response5 === void 0 || (_file$response5 = _file$response5.data) === null || _file$response5 === void 0 ? void 0 : _file$response5.url) || '');
|
|
269
201
|
}
|
|
270
202
|
}
|
|
271
|
-
} else if (file.status === 'error' || isBoolean((_file$
|
|
203
|
+
} else if (file.status === 'error' || isBoolean((_file$response6 = file.response) === null || _file$response6 === void 0 ? void 0 : _file$response6.status) && ((_file$response7 = file.response) === null || _file$response7 === void 0 ? void 0 : _file$response7.status) === false) {
|
|
272
204
|
PisellToast({
|
|
273
205
|
content: getText('pisell-upload-error')(file.name)
|
|
274
206
|
});
|
|
275
207
|
}
|
|
276
208
|
}, [multiple, enableMultilingual, onChange]);
|
|
277
209
|
var handlePreview = useCallback(function (file) {
|
|
278
|
-
var _file$
|
|
279
|
-
setPreviewImage(file.url || ((_file$
|
|
210
|
+
var _file$response8;
|
|
211
|
+
setPreviewImage(file.url || ((_file$response8 = file.response) === null || _file$response8 === void 0 || (_file$response8 = _file$response8.data) === null || _file$response8 === void 0 ? void 0 : _file$response8.url) || '');
|
|
280
212
|
setPreviewOpen(true);
|
|
281
213
|
}, []);
|
|
282
214
|
var handleEditMultilingual = useCallback(function (file) {
|
|
@@ -380,10 +312,10 @@ var BaseUpload = function BaseUpload(props) {
|
|
|
380
312
|
setOpen(false);
|
|
381
313
|
}, []);
|
|
382
314
|
var beforeUpload = useCallback( /*#__PURE__*/function () {
|
|
383
|
-
var
|
|
315
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(file, newFileList) {
|
|
384
316
|
var currentFileCount, fileType, typeMaxSize, _maxSize, pointSuffix, metadata, cover, restMetadata;
|
|
385
|
-
return _regeneratorRuntime().wrap(function
|
|
386
|
-
while (1) switch (
|
|
317
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
318
|
+
while (1) switch (_context.prev = _context.next) {
|
|
387
319
|
case 0:
|
|
388
320
|
currentFileCount = 1;
|
|
389
321
|
newFileList.forEach(function (item, index) {
|
|
@@ -395,46 +327,46 @@ var BaseUpload = function BaseUpload(props) {
|
|
|
395
327
|
typeMaxSize = typeMaxSizeMap === null || typeMaxSizeMap === void 0 ? void 0 : typeMaxSizeMap[fileType];
|
|
396
328
|
_maxSize = typeMaxSize || maxSize || 10;
|
|
397
329
|
if (!(file.size > _maxSize * 1024 * 1024)) {
|
|
398
|
-
|
|
330
|
+
_context.next = 8;
|
|
399
331
|
break;
|
|
400
332
|
}
|
|
401
333
|
sizeError.run(getText('pisell-upload-setting-size-error')(_maxSize));
|
|
402
|
-
return
|
|
334
|
+
return _context.abrupt("return", Upload.LIST_IGNORE);
|
|
403
335
|
case 8:
|
|
404
336
|
pointSuffix = getPointSuffix(file.name);
|
|
405
337
|
if (!(accept !== '' && !accept.includes(pointSuffix))) {
|
|
406
|
-
|
|
338
|
+
_context.next = 12;
|
|
407
339
|
break;
|
|
408
340
|
}
|
|
409
341
|
typeError.run(getText('pisell-upload-setting-type-error')(pointSuffix));
|
|
410
|
-
return
|
|
342
|
+
return _context.abrupt("return", Upload.LIST_IGNORE);
|
|
411
343
|
case 12:
|
|
412
|
-
|
|
413
|
-
|
|
344
|
+
_context.prev = 12;
|
|
345
|
+
_context.next = 15;
|
|
414
346
|
return getMediaMetadata(file);
|
|
415
347
|
case 15:
|
|
416
|
-
metadata =
|
|
348
|
+
metadata = _context.sent;
|
|
417
349
|
if (metadata) {
|
|
418
350
|
cover = metadata.cover, restMetadata = _objectWithoutProperties(metadata, _excluded2);
|
|
419
351
|
file.metadata = restMetadata;
|
|
420
352
|
file.cover = cover;
|
|
421
353
|
}
|
|
422
|
-
|
|
354
|
+
_context.next = 22;
|
|
423
355
|
break;
|
|
424
356
|
case 19:
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
console.error('获取媒体元数据失败:',
|
|
357
|
+
_context.prev = 19;
|
|
358
|
+
_context.t0 = _context["catch"](12);
|
|
359
|
+
console.error('获取媒体元数据失败:', _context.t0);
|
|
428
360
|
case 22:
|
|
429
|
-
return
|
|
361
|
+
return _context.abrupt("return", file);
|
|
430
362
|
case 23:
|
|
431
363
|
case "end":
|
|
432
|
-
return
|
|
364
|
+
return _context.stop();
|
|
433
365
|
}
|
|
434
|
-
},
|
|
366
|
+
}, _callee, null, [[12, 19]]);
|
|
435
367
|
}));
|
|
436
|
-
return function (
|
|
437
|
-
return
|
|
368
|
+
return function (_x, _x2) {
|
|
369
|
+
return _ref3.apply(this, arguments);
|
|
438
370
|
};
|
|
439
371
|
}(), [accept, fileList.length, maxSize, minCount, maxCount, multiple, typeMaxSizeMap]);
|
|
440
372
|
var renderUploadButton = useCallback(function (showGlobeIcon) {
|
|
@@ -450,36 +382,65 @@ var BaseUpload = function BaseUpload(props) {
|
|
|
450
382
|
onClick: handleGlobeIconClick
|
|
451
383
|
}));
|
|
452
384
|
}, [restProps.disabled, handleGlobeIconClick]);
|
|
453
|
-
var
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
385
|
+
var customRequest = useMemo(function () {
|
|
386
|
+
if (!isShop) {
|
|
387
|
+
return {};
|
|
388
|
+
}
|
|
389
|
+
var handleUpload = function handleUpload(options) {
|
|
390
|
+
var onSuccess = options.onSuccess,
|
|
391
|
+
onError = options.onError,
|
|
392
|
+
onProgress = options.onProgress,
|
|
393
|
+
file = options.file;
|
|
394
|
+
var fileSize = file.size;
|
|
395
|
+
var baseTime = getBaseTime(fileSize);
|
|
396
|
+
var progress = 0;
|
|
397
|
+
|
|
398
|
+
// 模拟初始连接延迟
|
|
399
|
+
setTimeout(function () {
|
|
400
|
+
onProgress === null || onProgress === void 0 || onProgress({
|
|
401
|
+
percent: 1
|
|
402
|
+
});
|
|
403
|
+
}, 200);
|
|
404
|
+
var timer = setInterval(function () {
|
|
405
|
+
// 非线性进度增长
|
|
406
|
+
if (progress < 30) {
|
|
407
|
+
progress += 5; // 前30%快速增长
|
|
408
|
+
} else if (progress < 60) {
|
|
409
|
+
progress += 3; // 30-60%中速增长
|
|
410
|
+
} else if (progress < 80) {
|
|
411
|
+
progress += 2; // 60-80%减缓
|
|
412
|
+
} else if (progress < 90) {
|
|
413
|
+
progress += 0.5; // 80-90%更慢
|
|
477
414
|
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
415
|
+
if (progress >= 90) {
|
|
416
|
+
clearInterval(timer);
|
|
417
|
+
}
|
|
418
|
+
onProgress === null || onProgress === void 0 || onProgress({
|
|
419
|
+
percent: Math.min(90, progress)
|
|
420
|
+
});
|
|
421
|
+
}, baseTime / 30); // 将总时间分成约30个进度点
|
|
422
|
+
|
|
423
|
+
uploadFile(file).then(function (res) {
|
|
424
|
+
clearInterval(timer);
|
|
425
|
+
// 快速完成最后10%
|
|
426
|
+
onProgress === null || onProgress === void 0 || onProgress({
|
|
427
|
+
percent: 95
|
|
428
|
+
});
|
|
429
|
+
setTimeout(function () {
|
|
430
|
+
onProgress === null || onProgress === void 0 || onProgress({
|
|
431
|
+
percent: 100
|
|
432
|
+
});
|
|
433
|
+
onSuccess === null || onSuccess === void 0 || onSuccess(res);
|
|
434
|
+
}, 200);
|
|
435
|
+
}).catch(function (err) {
|
|
436
|
+
clearInterval(timer);
|
|
437
|
+
onError === null || onError === void 0 || onError(err);
|
|
438
|
+
});
|
|
439
|
+
};
|
|
440
|
+
return {
|
|
441
|
+
customRequest: handleUpload
|
|
442
|
+
};
|
|
443
|
+
}, [isShop]);
|
|
483
444
|
var uploadProps = _objectSpread(_objectSpread({}, restProps), {}, {
|
|
484
445
|
multiple: multiple,
|
|
485
446
|
showUploadList: {
|
|
@@ -519,7 +480,7 @@ var BaseUpload = function BaseUpload(props) {
|
|
|
519
480
|
headers: (propsGetHeaders === null || propsGetHeaders === void 0 ? void 0 : propsGetHeaders()) || (getHeaders === null || getHeaders === void 0 ? void 0 : getHeaders()),
|
|
520
481
|
beforeUpload: beforeUpload,
|
|
521
482
|
className: 'pisell-data-source-upload'
|
|
522
|
-
});
|
|
483
|
+
}, customRequest);
|
|
523
484
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(PisellUpload, _extends({}, uploadProps, {
|
|
524
485
|
fileList: fileList
|
|
525
486
|
}), fileList.length >= calcMaxCount ? null : renderUploadButton(!!enableMultilingual)), /*#__PURE__*/React.createElement(PisellModal, {
|
|
@@ -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 {
|
|
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
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
|
|
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>;
|