@pisell/core 0.0.2
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/README.md +1 -0
- package/es/app/app.d.ts +101 -0
- package/es/app/app.js +177 -0
- package/es/app/const.d.ts +4 -0
- package/es/app/const.js +6 -0
- package/es/app/index.d.ts +14 -0
- package/es/app/index.js +52 -0
- package/es/applicationManager/application.d.ts +197 -0
- package/es/applicationManager/application.js +469 -0
- package/es/applicationManager/index.d.ts +19 -0
- package/es/applicationManager/index.js +206 -0
- package/es/aws/index.d.ts +16 -0
- package/es/aws/index.js +76 -0
- package/es/cmd/const.d.ts +11 -0
- package/es/cmd/const.js +13 -0
- package/es/cmd/index.d.ts +13 -0
- package/es/cmd/index.js +91 -0
- package/es/cmd/type.d.ts +5 -0
- package/es/cmd/type.js +1 -0
- package/es/communicationManager/index.d.ts +59 -0
- package/es/communicationManager/index.js +174 -0
- package/es/config.d.ts +3 -0
- package/es/config.js +14 -0
- package/es/cookie/index.d.ts +13 -0
- package/es/cookie/index.js +47 -0
- package/es/css/global.less +73 -0
- package/es/css/index.less +31 -0
- package/es/css/variables.css +84 -0
- package/es/data/index.d.ts +8 -0
- package/es/data/index.js +16 -0
- package/es/history/config.d.ts +24 -0
- package/es/history/config.js +43 -0
- package/es/history/index.d.ts +26 -0
- package/es/history/index.js +80 -0
- package/es/history/type.d.ts +2 -0
- package/es/history/type.js +1 -0
- package/es/hooks/index.d.ts +12 -0
- package/es/hooks/index.js +13 -0
- package/es/hooks/useDelayedValue/index.d.ts +2 -0
- package/es/hooks/useDelayedValue/index.js +26 -0
- package/es/hooks/useDispatch/index.d.ts +2 -0
- package/es/hooks/useDispatch/index.js +2 -0
- package/es/hooks/useLowCode/index.d.ts +13 -0
- package/es/hooks/useLowCode/index.js +74 -0
- package/es/hooks/useStore/index.d.ts +6 -0
- package/es/hooks/useStore/index.js +11 -0
- package/es/index.d.ts +8 -0
- package/es/index.js +10 -0
- package/es/indexDB/index.d.ts +296 -0
- package/es/indexDB/index.js +1619 -0
- package/es/locales/en.d.ts +3 -0
- package/es/locales/en.js +5 -0
- package/es/locales/index.d.ts +39 -0
- package/es/locales/index.js +199 -0
- package/es/locales/original.d.ts +3 -0
- package/es/locales/original.js +7 -0
- package/es/locales/type.d.ts +19 -0
- package/es/locales/type.js +1 -0
- package/es/locales/zh-CN.d.ts +3 -0
- package/es/locales/zh-CN.js +5 -0
- package/es/locales/zh-HK.d.ts +3 -0
- package/es/locales/zh-HK.js +5 -0
- package/es/logger/feishu.d.ts +11 -0
- package/es/logger/feishu.js +50 -0
- package/es/logger/index.d.ts +135 -0
- package/es/logger/index.js +870 -0
- package/es/menuManager/hooks.d.ts +17 -0
- package/es/menuManager/hooks.js +136 -0
- package/es/menuManager/index.d.ts +28 -0
- package/es/menuManager/index.js +165 -0
- package/es/models/global.d.ts +32 -0
- package/es/models/global.js +66 -0
- package/es/models/index.d.ts +45 -0
- package/es/models/index.js +65 -0
- package/es/models/type.d.ts +2 -0
- package/es/models/type.js +1 -0
- package/es/plugin/index.d.ts +0 -0
- package/es/plugin/index.js +0 -0
- package/es/pubsub/example.d.ts +5 -0
- package/es/pubsub/example.js +92 -0
- package/es/pubsub/index.d.ts +73 -0
- package/es/pubsub/index.js +166 -0
- package/es/render/index.d.ts +0 -0
- package/es/render/index.js +0 -0
- package/es/request/cache.d.ts +46 -0
- package/es/request/cache.js +372 -0
- package/es/request/cancelToken.d.ts +38 -0
- package/es/request/cancelToken.js +59 -0
- package/es/request/config.d.ts +3 -0
- package/es/request/config.js +63 -0
- package/es/request/constants.d.ts +2 -0
- package/es/request/constants.js +6 -0
- package/es/request/index.d.ts +24 -0
- package/es/request/index.js +267 -0
- package/es/request/pisell2Request.d.ts +6 -0
- package/es/request/pisell2Request.js +62 -0
- package/es/request/type.d.ts +57 -0
- package/es/request/type.js +10 -0
- package/es/request/utils.d.ts +46 -0
- package/es/request/utils.js +147 -0
- package/es/routes/config.d.ts +7 -0
- package/es/routes/config.js +17 -0
- package/es/routes/index.d.ts +28 -0
- package/es/routes/index.js +151 -0
- package/es/socket/components/SocketMonitorPage.d.ts +6 -0
- package/es/socket/components/SocketMonitorPage.js +485 -0
- package/es/socket/components/index.d.ts +2 -0
- package/es/socket/components/index.js +2 -0
- package/es/socket/constants.d.ts +33 -0
- package/es/socket/constants.js +39 -0
- package/es/socket/events.d.ts +31 -0
- package/es/socket/events.js +19 -0
- package/es/socket/heartbeat.d.ts +66 -0
- package/es/socket/heartbeat.js +184 -0
- package/es/socket/index.d.ts +61 -0
- package/es/socket/index.js +246 -0
- package/es/socket/monitor.d.ts +169 -0
- package/es/socket/monitor.js +448 -0
- package/es/socket/reconnect.d.ts +61 -0
- package/es/socket/reconnect.js +199 -0
- package/es/socket/socket.d.ts +130 -0
- package/es/socket/socket.js +613 -0
- package/es/socket/types.d.ts +85 -0
- package/es/socket/types.js +35 -0
- package/es/storage/index.d.ts +17 -0
- package/es/storage/index.js +46 -0
- package/es/tasks/index.d.ts +127 -0
- package/es/tasks/index.js +1119 -0
- package/es/tasks/scheduledTasksExample.d.ts +61 -0
- package/es/tasks/scheduledTasksExample.js +351 -0
- package/es/tasks/type.d.ts +100 -0
- package/es/tasks/type.js +1 -0
- package/es/tasks/useTasks.d.ts +5 -0
- package/es/tasks/useTasks.js +25 -0
- package/es/type.d.ts +2 -0
- package/es/type.js +1 -0
- package/es/utils/adaptiveThrottle/index.d.ts +36 -0
- package/es/utils/adaptiveThrottle/index.js +136 -0
- package/es/variables/VariablesProvider.d.ts +7 -0
- package/es/variables/VariablesProvider.js +12 -0
- package/es/variables/config.d.ts +3 -0
- package/es/variables/config.js +16 -0
- package/es/variables/index.d.ts +6 -0
- package/es/variables/index.js +5 -0
- package/es/variables/type.d.ts +2 -0
- package/es/variables/type.js +1 -0
- package/es/website/index.d.ts +6 -0
- package/es/website/index.js +65 -0
- package/lib/app/app.d.ts +101 -0
- package/lib/app/app.js +171 -0
- package/lib/app/const.d.ts +4 -0
- package/lib/app/const.js +33 -0
- package/lib/app/index.d.ts +14 -0
- package/lib/app/index.js +76 -0
- package/lib/applicationManager/application.d.ts +197 -0
- package/lib/applicationManager/application.js +280 -0
- package/lib/applicationManager/index.d.ts +19 -0
- package/lib/applicationManager/index.js +88 -0
- package/lib/aws/index.d.ts +16 -0
- package/lib/aws/index.js +67 -0
- package/lib/cmd/const.d.ts +11 -0
- package/lib/cmd/const.js +39 -0
- package/lib/cmd/index.d.ts +13 -0
- package/lib/cmd/index.js +96 -0
- package/lib/cmd/type.d.ts +5 -0
- package/lib/cmd/type.js +17 -0
- package/lib/communicationManager/index.d.ts +59 -0
- package/lib/communicationManager/index.js +102 -0
- package/lib/config.d.ts +3 -0
- package/lib/config.js +36 -0
- package/lib/cookie/index.d.ts +13 -0
- package/lib/cookie/index.js +62 -0
- package/lib/css/global.less +73 -0
- package/lib/css/index.less +31 -0
- package/lib/css/variables.css +84 -0
- package/lib/data/index.d.ts +8 -0
- package/lib/data/index.js +38 -0
- package/lib/history/config.d.ts +24 -0
- package/lib/history/config.js +41 -0
- package/lib/history/index.d.ts +26 -0
- package/lib/history/index.js +99 -0
- package/lib/history/type.d.ts +2 -0
- package/lib/history/type.js +17 -0
- package/lib/hooks/index.d.ts +12 -0
- package/lib/hooks/index.js +44 -0
- package/lib/hooks/useDelayedValue/index.d.ts +2 -0
- package/lib/hooks/useDelayedValue/index.js +36 -0
- package/lib/hooks/useDispatch/index.d.ts +2 -0
- package/lib/hooks/useDispatch/index.js +26 -0
- package/lib/hooks/useLowCode/index.d.ts +13 -0
- package/lib/hooks/useLowCode/index.js +75 -0
- package/lib/hooks/useStore/index.d.ts +6 -0
- package/lib/hooks/useStore/index.js +33 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +58 -0
- package/lib/indexDB/index.d.ts +296 -0
- package/lib/indexDB/index.js +767 -0
- package/lib/locales/en.d.ts +3 -0
- package/lib/locales/en.js +29 -0
- package/lib/locales/index.d.ts +39 -0
- package/lib/locales/index.js +159 -0
- package/lib/locales/original.d.ts +3 -0
- package/lib/locales/original.js +31 -0
- package/lib/locales/type.d.ts +19 -0
- package/lib/locales/type.js +17 -0
- package/lib/locales/zh-CN.d.ts +3 -0
- package/lib/locales/zh-CN.js +29 -0
- package/lib/locales/zh-HK.d.ts +3 -0
- package/lib/locales/zh-HK.js +29 -0
- package/lib/logger/feishu.d.ts +11 -0
- package/lib/logger/feishu.js +52 -0
- package/lib/logger/index.d.ts +135 -0
- package/lib/logger/index.js +476 -0
- package/lib/menuManager/hooks.d.ts +17 -0
- package/lib/menuManager/hooks.js +135 -0
- package/lib/menuManager/index.d.ts +28 -0
- package/lib/menuManager/index.js +125 -0
- package/lib/models/global.d.ts +32 -0
- package/lib/models/global.js +62 -0
- package/lib/models/index.d.ts +45 -0
- package/lib/models/index.js +69 -0
- package/lib/models/type.d.ts +2 -0
- package/lib/models/type.js +17 -0
- package/lib/plugin/index.d.ts +0 -0
- package/lib/plugin/index.js +0 -0
- package/lib/pubsub/example.d.ts +5 -0
- package/lib/pubsub/example.js +61 -0
- package/lib/pubsub/index.d.ts +73 -0
- package/lib/pubsub/index.js +141 -0
- package/lib/render/index.d.ts +0 -0
- package/lib/render/index.js +0 -0
- package/lib/request/cache.d.ts +46 -0
- package/lib/request/cache.js +195 -0
- package/lib/request/cancelToken.d.ts +38 -0
- package/lib/request/cancelToken.js +59 -0
- package/lib/request/config.d.ts +3 -0
- package/lib/request/config.js +69 -0
- package/lib/request/constants.d.ts +2 -0
- package/lib/request/constants.js +34 -0
- package/lib/request/index.d.ts +24 -0
- package/lib/request/index.js +210 -0
- package/lib/request/pisell2Request.d.ts +6 -0
- package/lib/request/pisell2Request.js +75 -0
- package/lib/request/type.d.ts +57 -0
- package/lib/request/type.js +36 -0
- package/lib/request/utils.d.ts +46 -0
- package/lib/request/utils.js +113 -0
- package/lib/routes/config.d.ts +7 -0
- package/lib/routes/config.js +50 -0
- package/lib/routes/index.d.ts +28 -0
- package/lib/routes/index.js +121 -0
- package/lib/socket/components/SocketMonitorPage.d.ts +6 -0
- package/lib/socket/components/SocketMonitorPage.js +340 -0
- package/lib/socket/components/index.d.ts +2 -0
- package/lib/socket/components/index.js +39 -0
- package/lib/socket/constants.d.ts +33 -0
- package/lib/socket/constants.js +62 -0
- package/lib/socket/events.d.ts +31 -0
- package/lib/socket/events.js +44 -0
- package/lib/socket/heartbeat.d.ts +66 -0
- package/lib/socket/heartbeat.js +157 -0
- package/lib/socket/index.d.ts +61 -0
- package/lib/socket/index.js +198 -0
- package/lib/socket/monitor.d.ts +169 -0
- package/lib/socket/monitor.js +350 -0
- package/lib/socket/reconnect.d.ts +61 -0
- package/lib/socket/reconnect.js +157 -0
- package/lib/socket/socket.d.ts +130 -0
- package/lib/socket/socket.js +426 -0
- package/lib/socket/types.d.ts +85 -0
- package/lib/socket/types.js +36 -0
- package/lib/storage/index.d.ts +17 -0
- package/lib/storage/index.js +64 -0
- package/lib/tasks/index.d.ts +127 -0
- package/lib/tasks/index.js +710 -0
- package/lib/tasks/scheduledTasksExample.d.ts +61 -0
- package/lib/tasks/scheduledTasksExample.js +267 -0
- package/lib/tasks/type.d.ts +100 -0
- package/lib/tasks/type.js +17 -0
- package/lib/tasks/useTasks.d.ts +5 -0
- package/lib/tasks/useTasks.js +37 -0
- package/lib/type.d.ts +2 -0
- package/lib/type.js +17 -0
- package/lib/utils/adaptiveThrottle/index.d.ts +36 -0
- package/lib/utils/adaptiveThrottle/index.js +121 -0
- package/lib/variables/VariablesProvider.d.ts +7 -0
- package/lib/variables/VariablesProvider.js +51 -0
- package/lib/variables/config.d.ts +3 -0
- package/lib/variables/config.js +38 -0
- package/lib/variables/index.d.ts +6 -0
- package/lib/variables/index.js +29 -0
- package/lib/variables/type.d.ts +2 -0
- package/lib/variables/type.js +17 -0
- package/lib/website/index.d.ts +6 -0
- package/lib/website/index.js +75 -0
- package/package.json +49 -0
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
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(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
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); }
|
|
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 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; }
|
|
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
|
+
//@ts-ignore
|
|
11
|
+
import md5 from 'js-md5';
|
|
12
|
+
import { getConfig } from "./config";
|
|
13
|
+
import { RequestModeENUM } from "./type";
|
|
14
|
+
import { getApp } from "../app";
|
|
15
|
+
// 缓存池
|
|
16
|
+
var CACHES = {};
|
|
17
|
+
|
|
18
|
+
// 最大缓存时间
|
|
19
|
+
var MAX_CACHE_TIME = 7 * 60 * 60 * 1000;
|
|
20
|
+
/**
|
|
21
|
+
* @title: 创建缓存唯一标识
|
|
22
|
+
* @description: 格式为 url_data
|
|
23
|
+
* @param {string} url
|
|
24
|
+
* @param {any} data
|
|
25
|
+
* @return {*}
|
|
26
|
+
* @Author: zhiwei.Wang
|
|
27
|
+
*/
|
|
28
|
+
var createCacheKey = function createCacheKey(url, data, cache) {
|
|
29
|
+
var _getConfig = getConfig(),
|
|
30
|
+
storage = _getConfig.storage;
|
|
31
|
+
var _data = (cache === null || cache === void 0 ? void 0 : cache.cacheKeyData) || data;
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
return cache.key ? storage.createKey(cache.key) : md5("".concat(url, "_").concat(JSON.stringify(_data)));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @title: 设置缓存
|
|
38
|
+
* @description:
|
|
39
|
+
* @return {*}
|
|
40
|
+
* @Author: zhiwei.Wang
|
|
41
|
+
*/
|
|
42
|
+
export var setCache = /*#__PURE__*/function () {
|
|
43
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(key, data, cache) {
|
|
44
|
+
var _getConfig2, storage, cacheData, app, tasksData;
|
|
45
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
46
|
+
while (1) switch (_context.prev = _context.next) {
|
|
47
|
+
case 0:
|
|
48
|
+
_getConfig2 = getConfig(), storage = _getConfig2.storage;
|
|
49
|
+
cacheData = {
|
|
50
|
+
// 数据
|
|
51
|
+
data: data,
|
|
52
|
+
// 当前时间戳
|
|
53
|
+
time: new Date().getTime(),
|
|
54
|
+
id: key
|
|
55
|
+
};
|
|
56
|
+
if (!(cache.type === 'memory')) {
|
|
57
|
+
_context.next = 6;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
// 将数据存储至缓存池
|
|
61
|
+
CACHES[key] = cacheData;
|
|
62
|
+
_context.next = 23;
|
|
63
|
+
break;
|
|
64
|
+
case 6:
|
|
65
|
+
if (!(cache.type === 'storage')) {
|
|
66
|
+
_context.next = 10;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
// 设置缓存
|
|
70
|
+
storage.setStorage(key, JSON.stringify(cacheData));
|
|
71
|
+
_context.next = 23;
|
|
72
|
+
break;
|
|
73
|
+
case 10:
|
|
74
|
+
if (!(cache.type === 'indexDB')) {
|
|
75
|
+
_context.next = 23;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
// 设置缓存
|
|
79
|
+
app = getApp();
|
|
80
|
+
if (!app.dbManager) {
|
|
81
|
+
_context.next = 23;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
_context.next = 15;
|
|
85
|
+
return app.dbManager.get('requests', key);
|
|
86
|
+
case 15:
|
|
87
|
+
tasksData = _context.sent;
|
|
88
|
+
if (tasksData) {
|
|
89
|
+
_context.next = 21;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
_context.next = 19;
|
|
93
|
+
return app.dbManager.debouncedAdd('requests', cacheData);
|
|
94
|
+
case 19:
|
|
95
|
+
_context.next = 23;
|
|
96
|
+
break;
|
|
97
|
+
case 21:
|
|
98
|
+
_context.next = 23;
|
|
99
|
+
return app.dbManager.debouncedUpdate('requests', cacheData);
|
|
100
|
+
case 23:
|
|
101
|
+
console.log('设置缓存成功', CACHES);
|
|
102
|
+
case 24:
|
|
103
|
+
case "end":
|
|
104
|
+
return _context.stop();
|
|
105
|
+
}
|
|
106
|
+
}, _callee);
|
|
107
|
+
}));
|
|
108
|
+
return function setCache(_x, _x2, _x3) {
|
|
109
|
+
return _ref.apply(this, arguments);
|
|
110
|
+
};
|
|
111
|
+
}();
|
|
112
|
+
var getIsEffectiveTime = function getIsEffectiveTime(time) {
|
|
113
|
+
// 获取当前时间
|
|
114
|
+
var currentTime = new Date().getTime();
|
|
115
|
+
return currentTime - time <= MAX_CACHE_TIME;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @title: 获取缓存数据
|
|
120
|
+
* @description:
|
|
121
|
+
* @param {string} key
|
|
122
|
+
* @return {*}
|
|
123
|
+
* @Author: zhiwei.Wang
|
|
124
|
+
*/
|
|
125
|
+
var getCache = /*#__PURE__*/function () {
|
|
126
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key, cache) {
|
|
127
|
+
var _getConfig3, storage, storageDetail, _storageDetail, app, indexDBDetail;
|
|
128
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
129
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
130
|
+
case 0:
|
|
131
|
+
_getConfig3 = getConfig(), storage = _getConfig3.storage; // 如果 当前时间 - 数据缓存时间 小于 超时时间, 则数据正常.
|
|
132
|
+
if (!(cache.type === 'memory')) {
|
|
133
|
+
_context2.next = 8;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
if (CACHES[key]) {
|
|
137
|
+
_context2.next = 4;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
return _context2.abrupt("return", null);
|
|
141
|
+
case 4:
|
|
142
|
+
if (!getIsEffectiveTime(CACHES[key].time)) {
|
|
143
|
+
_context2.next = 6;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
return _context2.abrupt("return", CACHES[key].data);
|
|
147
|
+
case 6:
|
|
148
|
+
_context2.next = 23;
|
|
149
|
+
break;
|
|
150
|
+
case 8:
|
|
151
|
+
if (!(cache.type === 'storage')) {
|
|
152
|
+
_context2.next = 15;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
storageDetail = storage.getStorage(key) || "";
|
|
156
|
+
if (storageDetail) {
|
|
157
|
+
storageDetail = JSON.parse(storageDetail);
|
|
158
|
+
}
|
|
159
|
+
if (!getIsEffectiveTime(storageDetail.time)) {
|
|
160
|
+
_context2.next = 13;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
return _context2.abrupt("return", (_storageDetail = storageDetail) === null || _storageDetail === void 0 ? void 0 : _storageDetail.data);
|
|
164
|
+
case 13:
|
|
165
|
+
_context2.next = 23;
|
|
166
|
+
break;
|
|
167
|
+
case 15:
|
|
168
|
+
if (!(cache.type === 'indexDB')) {
|
|
169
|
+
_context2.next = 23;
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
app = getApp();
|
|
173
|
+
if (!app.dbManager) {
|
|
174
|
+
_context2.next = 23;
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
_context2.next = 20;
|
|
178
|
+
return app.dbManager.get('requests', key);
|
|
179
|
+
case 20:
|
|
180
|
+
indexDBDetail = _context2.sent;
|
|
181
|
+
if (!indexDBDetail) {
|
|
182
|
+
_context2.next = 23;
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
return _context2.abrupt("return", indexDBDetail === null || indexDBDetail === void 0 ? void 0 : indexDBDetail.data);
|
|
186
|
+
case 23:
|
|
187
|
+
return _context2.abrupt("return", null);
|
|
188
|
+
case 24:
|
|
189
|
+
case "end":
|
|
190
|
+
return _context2.stop();
|
|
191
|
+
}
|
|
192
|
+
}, _callee2);
|
|
193
|
+
}));
|
|
194
|
+
return function getCache(_x4, _x5) {
|
|
195
|
+
return _ref2.apply(this, arguments);
|
|
196
|
+
};
|
|
197
|
+
}();
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* @title: 删除缓存数据
|
|
201
|
+
* @description:
|
|
202
|
+
* @return {*}
|
|
203
|
+
* @Author: zhiwei.Wang
|
|
204
|
+
*/
|
|
205
|
+
export var removeCache = function removeCache(key, cache) {
|
|
206
|
+
var _getConfig4 = getConfig(),
|
|
207
|
+
storage = _getConfig4.storage;
|
|
208
|
+
if (cache.type === 'memory') {
|
|
209
|
+
if (CACHES[key]) {
|
|
210
|
+
delete CACHES[key];
|
|
211
|
+
}
|
|
212
|
+
} else if (cache.type === 'storage') {
|
|
213
|
+
var _data = storage.getStorage(key);
|
|
214
|
+
if (_data) {
|
|
215
|
+
storage.removeStorage(key);
|
|
216
|
+
}
|
|
217
|
+
} else if (cache.type === 'indexDB') {
|
|
218
|
+
var app = getApp();
|
|
219
|
+
if (app.dbManager) {
|
|
220
|
+
app.dbManager.delete('requests', key);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* @title: 获取数据
|
|
227
|
+
* @description:
|
|
228
|
+
* @param {any} url
|
|
229
|
+
* @param {any} data
|
|
230
|
+
* @return {*}
|
|
231
|
+
* @Author: zhiwei.Wang
|
|
232
|
+
*/
|
|
233
|
+
export var getCacheData = /*#__PURE__*/function () {
|
|
234
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(url, data, cache) {
|
|
235
|
+
var _key, res;
|
|
236
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
237
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
238
|
+
case 0:
|
|
239
|
+
// 创建缓存key
|
|
240
|
+
_key = createCacheKey(url, data, cache);
|
|
241
|
+
_context3.next = 3;
|
|
242
|
+
return getCache(_key, cache);
|
|
243
|
+
case 3:
|
|
244
|
+
res = _context3.sent;
|
|
245
|
+
return _context3.abrupt("return", res);
|
|
246
|
+
case 5:
|
|
247
|
+
case "end":
|
|
248
|
+
return _context3.stop();
|
|
249
|
+
}
|
|
250
|
+
}, _callee3);
|
|
251
|
+
}));
|
|
252
|
+
return function getCacheData(_x6, _x7, _x8) {
|
|
253
|
+
return _ref3.apply(this, arguments);
|
|
254
|
+
};
|
|
255
|
+
}();
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* @title: 设置缓存
|
|
259
|
+
* @description:
|
|
260
|
+
* @param {any} url 路径
|
|
261
|
+
* @param {any} data 参数
|
|
262
|
+
* @param {any} res 数据
|
|
263
|
+
* @return {*}
|
|
264
|
+
* @Author: zhiwei.Wang
|
|
265
|
+
*/
|
|
266
|
+
export var setCacheData = function setCacheData(url, data, res) {
|
|
267
|
+
var cache = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
|
|
268
|
+
type: 'memory'
|
|
269
|
+
};
|
|
270
|
+
// 创建缓存key
|
|
271
|
+
var _key = createCacheKey(url, data, cache);
|
|
272
|
+
setCache(_key, res, cache);
|
|
273
|
+
};
|
|
274
|
+
var getIsCache = function getIsCache(config) {
|
|
275
|
+
// 没有传递缓存参数, 则不缓存
|
|
276
|
+
if (!(config !== null && config !== void 0 && config.cache) && !(config !== null && config !== void 0 && config.useCache)) {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
var cache = (config === null || config === void 0 ? void 0 : config.cache) || {};
|
|
280
|
+
|
|
281
|
+
// 强制本地走缓存
|
|
282
|
+
if (cache.mode === RequestModeENUM.LOCAL) {
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// 强制云端不走缓存
|
|
287
|
+
if (cache.mode === RequestModeENUM.REMOTE) {
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// 优先本地缓存
|
|
292
|
+
if (cache.mode === RequestModeENUM.LOCAL_REMOTE) {
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// 优先使用云端, 没网使用本地
|
|
297
|
+
if (cache.mode === RequestModeENUM.REMOTE_LOCAL) {
|
|
298
|
+
// 暂时关闭远程本地缓存
|
|
299
|
+
return false;
|
|
300
|
+
// // 判断是否有网络, 有网络就使用接口
|
|
301
|
+
// if (getApp()?.getPlugin("network")?.connected) {
|
|
302
|
+
// return false;
|
|
303
|
+
// }
|
|
304
|
+
|
|
305
|
+
// return true;
|
|
306
|
+
}
|
|
307
|
+
return true;
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* @title: 缓存函数包装器
|
|
312
|
+
* @description:
|
|
313
|
+
* @param {any} url
|
|
314
|
+
* @param {any} data
|
|
315
|
+
* @param {any} config
|
|
316
|
+
* @param {any} fn
|
|
317
|
+
* @return {*}
|
|
318
|
+
* @Author: zhiwei.Wang
|
|
319
|
+
*/
|
|
320
|
+
export var cacheFn = /*#__PURE__*/function () {
|
|
321
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(props, fn) {
|
|
322
|
+
var url, data, config, isCache, cache, _data, _cache, _cache2;
|
|
323
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
324
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
325
|
+
case 0:
|
|
326
|
+
url = props.url, data = props.data, config = props.config;
|
|
327
|
+
isCache = getIsCache(config);
|
|
328
|
+
if (!isCache) {
|
|
329
|
+
_context4.next = 12;
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
cache = config.cache;
|
|
333
|
+
if (config.useCache) {
|
|
334
|
+
cache = {
|
|
335
|
+
type: 'memory'
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
if (!cache.mode) {
|
|
339
|
+
cache.mode = RequestModeENUM.LOCAL_REMOTE;
|
|
340
|
+
}
|
|
341
|
+
// 获取缓存数据
|
|
342
|
+
_context4.next = 8;
|
|
343
|
+
return getCacheData(url, data, cache);
|
|
344
|
+
case 8:
|
|
345
|
+
_data = _context4.sent;
|
|
346
|
+
if (!_data) {
|
|
347
|
+
_context4.next = 12;
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
// 如果开启更新缓存执行函数
|
|
351
|
+
if ((_cache = cache) !== null && _cache !== void 0 && _cache.updateCache && ((_cache2 = cache) === null || _cache2 === void 0 ? void 0 : _cache2.mode) === RequestModeENUM.LOCAL_REMOTE) {
|
|
352
|
+
fn(_objectSpread(_objectSpread({}, props), {}, {
|
|
353
|
+
config: _objectSpread(_objectSpread({}, props.config), {}, {
|
|
354
|
+
cache: _objectSpread(_objectSpread({}, cache), {}, {
|
|
355
|
+
updateCache: false
|
|
356
|
+
})
|
|
357
|
+
})
|
|
358
|
+
}));
|
|
359
|
+
}
|
|
360
|
+
return _context4.abrupt("return", _data);
|
|
361
|
+
case 12:
|
|
362
|
+
return _context4.abrupt("return", fn(props));
|
|
363
|
+
case 13:
|
|
364
|
+
case "end":
|
|
365
|
+
return _context4.stop();
|
|
366
|
+
}
|
|
367
|
+
}, _callee4);
|
|
368
|
+
}));
|
|
369
|
+
return function cacheFn(_x9, _x10) {
|
|
370
|
+
return _ref4.apply(this, arguments);
|
|
371
|
+
};
|
|
372
|
+
}();
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @Title: 请求列表
|
|
3
|
+
* @Describe:
|
|
4
|
+
* @Author: Wzw
|
|
5
|
+
*/
|
|
6
|
+
export declare let requestList: {
|
|
7
|
+
[key: string]: AbortController;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* @Title: 创建一个控制器
|
|
11
|
+
* @Describe:
|
|
12
|
+
* @Author: Wzw
|
|
13
|
+
* @param {string} key
|
|
14
|
+
*/
|
|
15
|
+
export declare const createController: (key: string) => AbortController;
|
|
16
|
+
/**
|
|
17
|
+
* @Title: 储存请求
|
|
18
|
+
* @Describe:
|
|
19
|
+
* @Author: Wzw
|
|
20
|
+
* @param {AbortController} controller
|
|
21
|
+
* @param {string} key
|
|
22
|
+
*/
|
|
23
|
+
export declare const setRequestList: (controller: AbortController, key: string) => void;
|
|
24
|
+
/**
|
|
25
|
+
* @Title: 取消请求
|
|
26
|
+
* @Describe:
|
|
27
|
+
* @Author: Wzw
|
|
28
|
+
* @param {string} key
|
|
29
|
+
*/
|
|
30
|
+
export declare const abortRequest: (key: string) => void;
|
|
31
|
+
/**
|
|
32
|
+
* @Title: 创建signal
|
|
33
|
+
* @Describe:
|
|
34
|
+
* @Author: Wzw
|
|
35
|
+
* @param {string} isAbort
|
|
36
|
+
* @param {string} url
|
|
37
|
+
*/
|
|
38
|
+
export declare const createSignal: (isAbort: boolean, url: string) => AbortSignal | null;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @Title: 请求列表
|
|
3
|
+
* @Describe:
|
|
4
|
+
* @Author: Wzw
|
|
5
|
+
*/
|
|
6
|
+
export var requestList = {};
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @Title: 创建一个控制器
|
|
10
|
+
* @Describe:
|
|
11
|
+
* @Author: Wzw
|
|
12
|
+
* @param {string} key
|
|
13
|
+
*/
|
|
14
|
+
export var createController = function createController(key) {
|
|
15
|
+
var controller = new AbortController(); // 创建一个控制器
|
|
16
|
+
setRequestList(controller, key);
|
|
17
|
+
return controller;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @Title: 储存请求
|
|
22
|
+
* @Describe:
|
|
23
|
+
* @Author: Wzw
|
|
24
|
+
* @param {AbortController} controller
|
|
25
|
+
* @param {string} key
|
|
26
|
+
*/
|
|
27
|
+
export var setRequestList = function setRequestList(controller, key) {
|
|
28
|
+
requestList[key] = controller;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @Title: 取消请求
|
|
33
|
+
* @Describe:
|
|
34
|
+
* @Author: Wzw
|
|
35
|
+
* @param {string} key
|
|
36
|
+
*/
|
|
37
|
+
export var abortRequest = function abortRequest(key) {
|
|
38
|
+
if (requestList[key]) {
|
|
39
|
+
requestList[key].abort();
|
|
40
|
+
delete requestList[key];
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @Title: 创建signal
|
|
46
|
+
* @Describe:
|
|
47
|
+
* @Author: Wzw
|
|
48
|
+
* @param {string} isAbort
|
|
49
|
+
* @param {string} url
|
|
50
|
+
*/
|
|
51
|
+
export var createSignal = function createSignal(isAbort, url) {
|
|
52
|
+
var signal = null;
|
|
53
|
+
//@ts-ignore
|
|
54
|
+
if (isAbort) {
|
|
55
|
+
abortRequest(url);
|
|
56
|
+
signal = createController(url).signal;
|
|
57
|
+
}
|
|
58
|
+
return signal;
|
|
59
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
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(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
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); }
|
|
7
|
+
import { axiosConfig } from "./constants";
|
|
8
|
+
import { Storage } from "../storage";
|
|
9
|
+
import { mergeWith } from 'lodash';
|
|
10
|
+
var defaultConfig = {
|
|
11
|
+
axiosConfig: axiosConfig,
|
|
12
|
+
storage: new Storage(),
|
|
13
|
+
logger: {
|
|
14
|
+
maxRequestCount: 6,
|
|
15
|
+
maxRequestTime: 5000,
|
|
16
|
+
filterUrls: []
|
|
17
|
+
},
|
|
18
|
+
requestCallbacks: {
|
|
19
|
+
200: function _(resData) {
|
|
20
|
+
var res = resData.res,
|
|
21
|
+
props = resData.props,
|
|
22
|
+
resolve = resData.resolve,
|
|
23
|
+
reject = resData.reject,
|
|
24
|
+
err = resData.err;
|
|
25
|
+
resolve(res);
|
|
26
|
+
return res;
|
|
27
|
+
},
|
|
28
|
+
401: function _(resData) {
|
|
29
|
+
var res = resData.res,
|
|
30
|
+
props = resData.props,
|
|
31
|
+
resolve = resData.resolve,
|
|
32
|
+
reject = resData.reject,
|
|
33
|
+
err = resData.err;
|
|
34
|
+
resolve(res);
|
|
35
|
+
return res;
|
|
36
|
+
},
|
|
37
|
+
403: function _(resData) {
|
|
38
|
+
var res = resData.res,
|
|
39
|
+
props = resData.props,
|
|
40
|
+
resolve = resData.resolve,
|
|
41
|
+
reject = resData.reject,
|
|
42
|
+
err = resData.err;
|
|
43
|
+
resolve(res);
|
|
44
|
+
return res;
|
|
45
|
+
},
|
|
46
|
+
other: function other(resData) {
|
|
47
|
+
var res = resData.res,
|
|
48
|
+
props = resData.props,
|
|
49
|
+
resolve = resData.resolve,
|
|
50
|
+
reject = resData.reject,
|
|
51
|
+
err = resData.err;
|
|
52
|
+
resolve(res);
|
|
53
|
+
return res;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var config = _objectSpread({}, defaultConfig);
|
|
58
|
+
export var setConfig = function setConfig(newConfig) {
|
|
59
|
+
config = mergeWith(config, newConfig);
|
|
60
|
+
};
|
|
61
|
+
export var getConfig = function getConfig() {
|
|
62
|
+
return config;
|
|
63
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RequestWrapperProps, RequestConfig } from "./type";
|
|
2
|
+
export declare const createRequest: (props: RequestWrapperProps) => Promise<unknown>;
|
|
3
|
+
/**
|
|
4
|
+
* 请求
|
|
5
|
+
* @param props
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare const request: (props: RequestWrapperProps) => any;
|
|
9
|
+
export declare const get: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
10
|
+
export declare const post: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
11
|
+
export declare const put: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
12
|
+
export declare const remove: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
13
|
+
export declare const custom: (url: RequestWrapperProps["url"], config: RequestWrapperProps["config"]) => any;
|
|
14
|
+
export * from "./type";
|
|
15
|
+
declare const _default: {
|
|
16
|
+
get: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
17
|
+
post: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
18
|
+
put: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
19
|
+
remove: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
20
|
+
custom: (url: string, config: import("./type").RequestSetting | undefined) => any;
|
|
21
|
+
setConfig: (newConfig: Partial<RequestConfig>) => void;
|
|
22
|
+
getConfig: () => RequestConfig;
|
|
23
|
+
};
|
|
24
|
+
export default _default;
|