@pisell/core 1.0.49 → 1.0.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/es/app/app.d.ts +7 -7
  2. package/es/app/index.d.ts +1 -1
  3. package/es/applicationManager/application.d.ts +2 -2
  4. package/es/cmd/const.d.ts +5 -5
  5. package/es/hooks/useStore/index.d.ts +1 -1
  6. package/es/indexDB/index.d.ts +28 -0
  7. package/es/indexDB/index.js +663 -314
  8. package/es/locales/type.d.ts +3 -3
  9. package/es/logger/index.d.ts +1 -1
  10. package/es/models/index.d.ts +4 -4
  11. package/es/pubsub/index.d.ts +1 -1
  12. package/es/request/cache.d.ts +1 -1
  13. package/es/request/cache.js +2 -2
  14. package/es/request/constants.js +1 -1
  15. package/es/request/index.js +3 -1
  16. package/es/request/pisell2Request.d.ts +1 -1
  17. package/es/request/type.d.ts +1 -1
  18. package/es/routes/index.d.ts +2 -2
  19. package/es/socket/types.d.ts +1 -1
  20. package/es/tasks/index.d.ts +1 -1
  21. package/es/tasks/type.d.ts +4 -4
  22. package/es/utils/adaptiveThrottle/index.d.ts +2 -2
  23. package/es/variables/index.d.ts +3 -3
  24. package/lib/app/app.d.ts +7 -7
  25. package/lib/app/index.d.ts +1 -1
  26. package/lib/applicationManager/application.d.ts +2 -2
  27. package/lib/aws/index.js +3 -0
  28. package/lib/cmd/const.d.ts +5 -5
  29. package/lib/cmd/const.js +5 -5
  30. package/lib/cmd/index.js +2 -0
  31. package/lib/cookie/index.js +2 -4
  32. package/lib/data/index.js +3 -0
  33. package/lib/hooks/useStore/index.d.ts +1 -1
  34. package/lib/indexDB/index.d.ts +28 -0
  35. package/lib/indexDB/index.js +157 -1
  36. package/lib/locales/index.js +95 -94
  37. package/lib/locales/type.d.ts +3 -3
  38. package/lib/logger/index.d.ts +1 -1
  39. package/lib/models/index.d.ts +4 -4
  40. package/lib/pubsub/index.d.ts +1 -1
  41. package/lib/pubsub/index.js +1 -3
  42. package/lib/request/cache.d.ts +1 -1
  43. package/lib/request/cache.js +2 -2
  44. package/lib/request/constants.js +1 -1
  45. package/lib/request/pisell2Request.d.ts +1 -1
  46. package/lib/request/type.d.ts +1 -1
  47. package/lib/routes/index.d.ts +2 -2
  48. package/lib/routes/index.js +3 -1
  49. package/lib/socket/components/SocketMonitorPage.js +6 -12
  50. package/lib/socket/heartbeat.js +10 -5
  51. package/lib/socket/index.js +1 -3
  52. package/lib/socket/monitor.js +26 -24
  53. package/lib/socket/reconnect.js +10 -3
  54. package/lib/socket/socket.js +12 -10
  55. package/lib/socket/types.d.ts +1 -1
  56. package/lib/storage/index.js +25 -24
  57. package/lib/tasks/index.d.ts +1 -1
  58. package/lib/tasks/index.js +333 -329
  59. package/lib/tasks/type.d.ts +4 -4
  60. package/lib/utils/adaptiveThrottle/index.d.ts +2 -2
  61. package/lib/variables/index.d.ts +3 -3
  62. package/package.json +1 -1
@@ -1,4 +1,7 @@
1
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 _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
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; }
3
6
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
7
  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."); }
@@ -61,6 +64,24 @@ var IndexDBManager = /*#__PURE__*/function () {
61
64
  _defineProperty(this, "memoryStorage", new Map());
62
65
  // 操作超时时间(毫秒)
63
66
  _defineProperty(this, "timeout", 10000);
67
+ // ===== 防抖 add 相关 =====
68
+ // 每个 store 一个 buffer
69
+ _defineProperty(this, "debouncedBuffers", new Map());
70
+ // 每个 store 一个 timer
71
+ _defineProperty(this, "debouncedTimers", new Map());
72
+ // 正在 flush 的 store
73
+ _defineProperty(this, "debouncedFlushing", new Set());
74
+ // 防抖时间(ms)
75
+ _defineProperty(this, "debouncedDelay", 200);
76
+ // 单次事务最大写入条数
77
+ _defineProperty(this, "debouncedBatchSize", 50);
78
+ // ===== 防抖 update 相关 =====
79
+ // 每个 store 一个 Map(key -> data)
80
+ _defineProperty(this, "debouncedUpdateBuffers", new Map());
81
+ _defineProperty(this, "debouncedUpdateTimers", new Map());
82
+ _defineProperty(this, "debouncedUpdateFlushing", new Set());
83
+ _defineProperty(this, "debouncedUpdateDelay", 200);
84
+ _defineProperty(this, "debouncedUpdateBatchSize", 50);
64
85
  this.app = app;
65
86
  this.dbName = options.dbName;
66
87
  this.version = options.version;
@@ -239,6 +260,332 @@ var IndexDBManager = /*#__PURE__*/function () {
239
260
  return store;
240
261
  }
241
262
 
263
+ /**
264
+ * 防抖合并 add(用于高频写入场景)
265
+ * @param storeName 存储对象名称
266
+ * @param data 数据
267
+ */
268
+ }, {
269
+ key: "debouncedAdd",
270
+ value: function debouncedAdd(storeName, data) {
271
+ var _this4 = this;
272
+ // 内存模式直接走内存
273
+ if (!this.useIndexDB) {
274
+ var storeConfig = this.stores.find(function (s) {
275
+ return s.name === storeName;
276
+ });
277
+ var keyPath = (storeConfig === null || storeConfig === void 0 ? void 0 : storeConfig.keyPath) || 'id';
278
+ var _key = data[keyPath];
279
+ this.getMemoryStore(storeName).set(_key, data);
280
+ return;
281
+ }
282
+ if (!this.db) return;
283
+
284
+ // 初始化 buffer
285
+ if (!this.debouncedBuffers.has(storeName)) {
286
+ this.debouncedBuffers.set(storeName, []);
287
+ }
288
+ this.debouncedBuffers.get(storeName).push(data);
289
+
290
+ // 如果正在 flush,不重新 debounce
291
+ if (this.debouncedFlushing.has(storeName)) return;
292
+
293
+ // 重置 timer
294
+ var oldTimer = this.debouncedTimers.get(storeName);
295
+ if (oldTimer) clearTimeout(oldTimer);
296
+ this.debouncedTimers.set(storeName, setTimeout(function () {
297
+ _this4.flushDebouncedAdd(storeName);
298
+ }, this.debouncedDelay));
299
+ }
300
+
301
+ /**
302
+ * 立即 flush 指定 store 的防抖 add
303
+ */
304
+ }, {
305
+ key: "flushDebouncedAdd",
306
+ value: (function () {
307
+ var _flushDebouncedAdd = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(storeName) {
308
+ var _this5 = this;
309
+ var buffer, uuid, _loop;
310
+ return _regeneratorRuntime().wrap(function _callee4$(_context5) {
311
+ while (1) switch (_context5.prev = _context5.next) {
312
+ case 0:
313
+ if (!(!this.useIndexDB || !this.db)) {
314
+ _context5.next = 2;
315
+ break;
316
+ }
317
+ return _context5.abrupt("return");
318
+ case 2:
319
+ if (!this.debouncedFlushing.has(storeName)) {
320
+ _context5.next = 4;
321
+ break;
322
+ }
323
+ return _context5.abrupt("return");
324
+ case 4:
325
+ buffer = this.debouncedBuffers.get(storeName);
326
+ if (!(!buffer || buffer.length === 0)) {
327
+ _context5.next = 7;
328
+ break;
329
+ }
330
+ return _context5.abrupt("return");
331
+ case 7:
332
+ this.debouncedFlushing.add(storeName);
333
+ uuid = "[ IndexDB ] DEBOUNCED_ADD: - ".concat(storeName, " - ").concat(dayjs().valueOf());
334
+ _context5.prev = 9;
335
+ _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
336
+ var batch;
337
+ return _regeneratorRuntime().wrap(function _loop$(_context4) {
338
+ while (1) switch (_context4.prev = _context4.next) {
339
+ case 0:
340
+ batch = buffer.splice(0, _this5.debouncedBatchSize);
341
+ _context4.next = 3;
342
+ return _this5.db.transaction('rw', _this5.db.table(storeName), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
343
+ var _iterator, _step, item;
344
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
345
+ while (1) switch (_context3.prev = _context3.next) {
346
+ case 0:
347
+ _iterator = _createForOfIteratorHelper(batch);
348
+ _context3.prev = 1;
349
+ _iterator.s();
350
+ case 3:
351
+ if ((_step = _iterator.n()).done) {
352
+ _context3.next = 9;
353
+ break;
354
+ }
355
+ item = _step.value;
356
+ _context3.next = 7;
357
+ return _this5.add(storeName, item);
358
+ case 7:
359
+ _context3.next = 3;
360
+ break;
361
+ case 9:
362
+ _context3.next = 14;
363
+ break;
364
+ case 11:
365
+ _context3.prev = 11;
366
+ _context3.t0 = _context3["catch"](1);
367
+ _iterator.e(_context3.t0);
368
+ case 14:
369
+ _context3.prev = 14;
370
+ _iterator.f();
371
+ return _context3.finish(14);
372
+ case 17:
373
+ case "end":
374
+ return _context3.stop();
375
+ }
376
+ }, _callee3, null, [[1, 11, 14, 17]]);
377
+ })));
378
+ case 3:
379
+ case "end":
380
+ return _context4.stop();
381
+ }
382
+ }, _loop);
383
+ });
384
+ case 11:
385
+ if (!(buffer.length > 0)) {
386
+ _context5.next = 15;
387
+ break;
388
+ }
389
+ return _context5.delegateYield(_loop(), "t0", 13);
390
+ case 13:
391
+ _context5.next = 11;
392
+ break;
393
+ case 15:
394
+ _context5.next = 20;
395
+ break;
396
+ case 17:
397
+ _context5.prev = 17;
398
+ _context5.t1 = _context5["catch"](9);
399
+ this.app.logger.addLog({
400
+ type: 'error',
401
+ title: uuid,
402
+ metadata: {
403
+ msg: '防抖合并 add 失败',
404
+ error: _context5.t1.message
405
+ }
406
+ });
407
+ case 20:
408
+ _context5.prev = 20;
409
+ this.debouncedFlushing.delete(storeName);
410
+ return _context5.finish(20);
411
+ case 23:
412
+ case "end":
413
+ return _context5.stop();
414
+ }
415
+ }, _callee4, this, [[9, 17, 20, 23]]);
416
+ }));
417
+ function flushDebouncedAdd(_x) {
418
+ return _flushDebouncedAdd.apply(this, arguments);
419
+ }
420
+ return flushDebouncedAdd;
421
+ }()
422
+ /**
423
+ * 防抖合并 update(同 key 自动合并)
424
+ */
425
+ )
426
+ }, {
427
+ key: "debouncedUpdate",
428
+ value: function debouncedUpdate(storeName, data) {
429
+ var _this6 = this;
430
+ // 内存模式
431
+ if (!this.useIndexDB) {
432
+ var _storeConfig = this.stores.find(function (s) {
433
+ return s.name === storeName;
434
+ });
435
+ var _keyPath = (_storeConfig === null || _storeConfig === void 0 ? void 0 : _storeConfig.keyPath) || 'id';
436
+ var _key2 = data[_keyPath];
437
+ this.getMemoryStore(storeName).set(_key2, _objectSpread(_objectSpread({}, this.getMemoryStore(storeName).get(_key2)), data));
438
+ return;
439
+ }
440
+ if (!this.db) return;
441
+ var storeConfig = this.stores.find(function (s) {
442
+ return s.name === storeName;
443
+ });
444
+ var keyPath = (storeConfig === null || storeConfig === void 0 ? void 0 : storeConfig.keyPath) || 'id';
445
+ var key = data[keyPath];
446
+ if (key == null) {
447
+ console.warn("[IndexDB] debouncedUpdate missing keyPath: ".concat(keyPath));
448
+ return;
449
+ }
450
+ if (!this.debouncedUpdateBuffers.has(storeName)) {
451
+ this.debouncedUpdateBuffers.set(storeName, new Map());
452
+ }
453
+
454
+ // 同 key 合并(后写覆盖)
455
+ var storeBuffer = this.debouncedUpdateBuffers.get(storeName);
456
+ storeBuffer.set(key, _objectSpread(_objectSpread({}, storeBuffer.get(key) || {}), data));
457
+ if (this.debouncedUpdateFlushing.has(storeName)) return;
458
+ var oldTimer = this.debouncedUpdateTimers.get(storeName);
459
+ if (oldTimer) clearTimeout(oldTimer);
460
+ this.debouncedUpdateTimers.set(storeName, setTimeout(function () {
461
+ _this6.flushDebouncedUpdate(storeName);
462
+ }, this.debouncedUpdateDelay));
463
+ }
464
+ /**
465
+ * flush 防抖 update
466
+ */
467
+ }, {
468
+ key: "flushDebouncedUpdate",
469
+ value: (function () {
470
+ var _flushDebouncedUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(storeName) {
471
+ var _this7 = this;
472
+ var bufferMap, uuid, entries, _loop2, i;
473
+ return _regeneratorRuntime().wrap(function _callee6$(_context8) {
474
+ while (1) switch (_context8.prev = _context8.next) {
475
+ case 0:
476
+ if (!(!this.useIndexDB || !this.db)) {
477
+ _context8.next = 2;
478
+ break;
479
+ }
480
+ return _context8.abrupt("return");
481
+ case 2:
482
+ if (!this.debouncedUpdateFlushing.has(storeName)) {
483
+ _context8.next = 4;
484
+ break;
485
+ }
486
+ return _context8.abrupt("return");
487
+ case 4:
488
+ bufferMap = this.debouncedUpdateBuffers.get(storeName);
489
+ if (!(!bufferMap || bufferMap.size === 0)) {
490
+ _context8.next = 7;
491
+ break;
492
+ }
493
+ return _context8.abrupt("return");
494
+ case 7:
495
+ this.debouncedUpdateFlushing.add(storeName);
496
+ uuid = "[ IndexDB ] DEBOUNCED_UPDATE: - ".concat(storeName, " - ").concat(dayjs().valueOf());
497
+ _context8.prev = 9;
498
+ entries = Array.from(bufferMap.values());
499
+ bufferMap.clear();
500
+ _loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
501
+ var batch;
502
+ return _regeneratorRuntime().wrap(function _loop2$(_context7) {
503
+ while (1) switch (_context7.prev = _context7.next) {
504
+ case 0:
505
+ batch = entries.slice(i, i + _this7.debouncedUpdateBatchSize);
506
+ _context7.next = 3;
507
+ return _this7.db.transaction('rw', _this7.db.table(storeName), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
508
+ var _iterator2, _step2, item;
509
+ return _regeneratorRuntime().wrap(function _callee5$(_context6) {
510
+ while (1) switch (_context6.prev = _context6.next) {
511
+ case 0:
512
+ _iterator2 = _createForOfIteratorHelper(batch);
513
+ _context6.prev = 1;
514
+ _iterator2.s();
515
+ case 3:
516
+ if ((_step2 = _iterator2.n()).done) {
517
+ _context6.next = 9;
518
+ break;
519
+ }
520
+ item = _step2.value;
521
+ _context6.next = 7;
522
+ return _this7.update(storeName, item);
523
+ case 7:
524
+ _context6.next = 3;
525
+ break;
526
+ case 9:
527
+ _context6.next = 14;
528
+ break;
529
+ case 11:
530
+ _context6.prev = 11;
531
+ _context6.t0 = _context6["catch"](1);
532
+ _iterator2.e(_context6.t0);
533
+ case 14:
534
+ _context6.prev = 14;
535
+ _iterator2.f();
536
+ return _context6.finish(14);
537
+ case 17:
538
+ case "end":
539
+ return _context6.stop();
540
+ }
541
+ }, _callee5, null, [[1, 11, 14, 17]]);
542
+ })));
543
+ case 3:
544
+ case "end":
545
+ return _context7.stop();
546
+ }
547
+ }, _loop2);
548
+ });
549
+ i = 0;
550
+ case 14:
551
+ if (!(i < entries.length)) {
552
+ _context8.next = 19;
553
+ break;
554
+ }
555
+ return _context8.delegateYield(_loop2(), "t0", 16);
556
+ case 16:
557
+ i += this.debouncedUpdateBatchSize;
558
+ _context8.next = 14;
559
+ break;
560
+ case 19:
561
+ _context8.next = 24;
562
+ break;
563
+ case 21:
564
+ _context8.prev = 21;
565
+ _context8.t1 = _context8["catch"](9);
566
+ this.app.logger.addLog({
567
+ type: 'error',
568
+ title: uuid,
569
+ metadata: {
570
+ msg: '防抖合并 update 失败',
571
+ error: _context8.t1.message
572
+ }
573
+ });
574
+ case 24:
575
+ _context8.prev = 24;
576
+ this.debouncedUpdateFlushing.delete(storeName);
577
+ return _context8.finish(24);
578
+ case 27:
579
+ case "end":
580
+ return _context8.stop();
581
+ }
582
+ }, _callee6, this, [[9, 21, 24, 27]]);
583
+ }));
584
+ function flushDebouncedUpdate(_x2) {
585
+ return _flushDebouncedUpdate.apply(this, arguments);
586
+ }
587
+ return flushDebouncedUpdate;
588
+ }()
242
589
  /**
243
590
  * 添加数据到指定的存储对象
244
591
  * @param {string} storeName - 存储对象名称
@@ -247,24 +594,25 @@ var IndexDBManager = /*#__PURE__*/function () {
247
594
  * @returns {Promise<T>} 添加的数据
248
595
  * @template T
249
596
  */
597
+ )
250
598
  }, {
251
599
  key: "add",
252
600
  value: (function () {
253
- var _add = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(storeName, data) {
254
- var _this4 = this;
601
+ var _add = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(storeName, data) {
602
+ var _this8 = this;
255
603
  var log,
256
604
  storeConfig,
257
605
  keyPath,
258
- _key,
606
+ _key3,
259
607
  memStore,
260
608
  uuid,
261
- _args4 = arguments;
262
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
263
- while (1) switch (_context4.prev = _context4.next) {
609
+ _args10 = arguments;
610
+ return _regeneratorRuntime().wrap(function _callee8$(_context10) {
611
+ while (1) switch (_context10.prev = _context10.next) {
264
612
  case 0:
265
- log = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : false;
613
+ log = _args10.length > 2 && _args10[2] !== undefined ? _args10[2] : false;
266
614
  if (this.useIndexDB) {
267
- _context4.next = 8;
615
+ _context10.next = 8;
268
616
  break;
269
617
  }
270
618
  // 使用内存存储
@@ -272,10 +620,10 @@ var IndexDBManager = /*#__PURE__*/function () {
272
620
  return s.name === storeName;
273
621
  });
274
622
  keyPath = (storeConfig === null || storeConfig === void 0 ? void 0 : storeConfig.keyPath) || 'id';
275
- _key = data[keyPath];
623
+ _key3 = data[keyPath];
276
624
  memStore = this.getMemoryStore(storeName);
277
- memStore.set(_key, data);
278
- return _context4.abrupt("return", data);
625
+ memStore.set(_key3, data);
626
+ return _context10.abrupt("return", data);
279
627
  case 8:
280
628
  uuid = "[ IndexDB ] ADD: - ".concat(storeName, " - ").concat(dayjs().valueOf());
281
629
  if (log) {
@@ -285,16 +633,16 @@ var IndexDBManager = /*#__PURE__*/function () {
285
633
  // metadata: { msg: '添加数据前', data: data }
286
634
  // })
287
635
  }
288
- return _context4.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
289
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
290
- while (1) switch (_context3.prev = _context3.next) {
636
+ return _context10.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
637
+ return _regeneratorRuntime().wrap(function _callee7$(_context9) {
638
+ while (1) switch (_context9.prev = _context9.next) {
291
639
  case 0:
292
- if (_this4.db) {
293
- _context3.next = 3;
640
+ if (_this8.db) {
641
+ _context9.next = 3;
294
642
  break;
295
643
  }
296
644
  if (log) {
297
- _this4.app.logger.addLog({
645
+ _this8.app.logger.addLog({
298
646
  type: 'error',
299
647
  title: uuid,
300
648
  metadata: {
@@ -305,9 +653,9 @@ var IndexDBManager = /*#__PURE__*/function () {
305
653
  }
306
654
  throw new Error('数据库未连接');
307
655
  case 3:
308
- _context3.prev = 3;
309
- _context3.next = 6;
310
- return _this4.db.table(storeName).add(data);
656
+ _context9.prev = 3;
657
+ _context9.next = 6;
658
+ return _this8.db.table(storeName).add(data);
311
659
  case 6:
312
660
  if (log) {
313
661
  // this.app.logger.addLog({
@@ -322,32 +670,33 @@ var IndexDBManager = /*#__PURE__*/function () {
322
670
  // metadata: { msg: '事务完成' }
323
671
  // });
324
672
  }
325
- return _context3.abrupt("return", data);
673
+ return _context9.abrupt("return", data);
326
674
  case 10:
327
- _context3.prev = 10;
328
- _context3.t0 = _context3["catch"](3);
329
- _this4.app.logger.addLog({
675
+ _context9.prev = 10;
676
+ _context9.t0 = _context9["catch"](3);
677
+ _this8.app.logger.addLog({
330
678
  type: 'error',
331
679
  title: uuid,
332
680
  metadata: {
333
681
  msg: '添加数据失败',
334
- error: _context3.t0.message
682
+ data: data,
683
+ error: _context9.t0.message
335
684
  }
336
685
  });
337
- throw new Error(_context3.t0 === null || _context3.t0 === void 0 ? void 0 : _context3.t0.message);
686
+ throw new Error(_context9.t0 === null || _context9.t0 === void 0 ? void 0 : _context9.t0.message);
338
687
  case 14:
339
688
  case "end":
340
- return _context3.stop();
689
+ return _context9.stop();
341
690
  }
342
- }, _callee3, null, [[3, 10]]);
691
+ }, _callee7, null, [[3, 10]]);
343
692
  }))(), "add(".concat(storeName, ")")));
344
693
  case 11:
345
694
  case "end":
346
- return _context4.stop();
695
+ return _context10.stop();
347
696
  }
348
- }, _callee4, this);
697
+ }, _callee8, this);
349
698
  }));
350
- function add(_x, _x2) {
699
+ function add(_x3, _x4) {
351
700
  return _add.apply(this, arguments);
352
701
  }
353
702
  return add;
@@ -362,54 +711,54 @@ var IndexDBManager = /*#__PURE__*/function () {
362
711
  }, {
363
712
  key: "exists",
364
713
  value: (function () {
365
- var _exists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(storeName, key) {
366
- var _this5 = this;
714
+ var _exists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(storeName, key) {
715
+ var _this9 = this;
367
716
  var memStore;
368
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
369
- while (1) switch (_context6.prev = _context6.next) {
717
+ return _regeneratorRuntime().wrap(function _callee10$(_context12) {
718
+ while (1) switch (_context12.prev = _context12.next) {
370
719
  case 0:
371
720
  if (this.useIndexDB) {
372
- _context6.next = 3;
721
+ _context12.next = 3;
373
722
  break;
374
723
  }
375
724
  // 使用内存存储
376
725
  memStore = this.getMemoryStore(storeName);
377
- return _context6.abrupt("return", memStore.has(key));
726
+ return _context12.abrupt("return", memStore.has(key));
378
727
  case 3:
379
- return _context6.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
728
+ return _context12.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
380
729
  var result;
381
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
382
- while (1) switch (_context5.prev = _context5.next) {
730
+ return _regeneratorRuntime().wrap(function _callee9$(_context11) {
731
+ while (1) switch (_context11.prev = _context11.next) {
383
732
  case 0:
384
- if (_this5.db) {
385
- _context5.next = 2;
733
+ if (_this9.db) {
734
+ _context11.next = 2;
386
735
  break;
387
736
  }
388
737
  throw new Error('数据库未连接');
389
738
  case 2:
390
- _context5.prev = 2;
391
- _context5.next = 5;
392
- return _this5.db.table(storeName).get(key);
739
+ _context11.prev = 2;
740
+ _context11.next = 5;
741
+ return _this9.db.table(storeName).get(key);
393
742
  case 5:
394
- result = _context5.sent;
395
- return _context5.abrupt("return", result !== undefined);
743
+ result = _context11.sent;
744
+ return _context11.abrupt("return", result !== undefined);
396
745
  case 9:
397
- _context5.prev = 9;
398
- _context5.t0 = _context5["catch"](2);
746
+ _context11.prev = 9;
747
+ _context11.t0 = _context11["catch"](2);
399
748
  throw new Error('检查数据存在性失败');
400
749
  case 12:
401
750
  case "end":
402
- return _context5.stop();
751
+ return _context11.stop();
403
752
  }
404
- }, _callee5, null, [[2, 9]]);
753
+ }, _callee9, null, [[2, 9]]);
405
754
  }))(), "exists(".concat(storeName, ")")));
406
755
  case 4:
407
756
  case "end":
408
- return _context6.stop();
757
+ return _context12.stop();
409
758
  }
410
- }, _callee6, this);
759
+ }, _callee10, this);
411
760
  }));
412
- function exists(_x3, _x4) {
761
+ function exists(_x5, _x6) {
413
762
  return _exists.apply(this, arguments);
414
763
  }
415
764
  return exists;
@@ -426,17 +775,17 @@ var IndexDBManager = /*#__PURE__*/function () {
426
775
  }, {
427
776
  key: "get",
428
777
  value: (function () {
429
- var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(storeName, key) {
430
- var _this6 = this;
778
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(storeName, key) {
779
+ var _this10 = this;
431
780
  var log,
432
781
  uuid,
433
782
  _memStore$get,
434
783
  memStore,
435
- _args8 = arguments;
436
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
437
- while (1) switch (_context8.prev = _context8.next) {
784
+ _args14 = arguments;
785
+ return _regeneratorRuntime().wrap(function _callee12$(_context14) {
786
+ while (1) switch (_context14.prev = _context14.next) {
438
787
  case 0:
439
- log = _args8.length > 2 && _args8[2] !== undefined ? _args8[2] : false;
788
+ log = _args14.length > 2 && _args14[2] !== undefined ? _args14[2] : false;
440
789
  uuid = "[ IndexDB ] GET: - ".concat(storeName, " - ").concat(key, " - ").concat(dayjs().valueOf());
441
790
  if (log) {
442
791
  // this.app.logger.addLog({
@@ -446,24 +795,24 @@ var IndexDBManager = /*#__PURE__*/function () {
446
795
  // })
447
796
  }
448
797
  if (this.useIndexDB) {
449
- _context8.next = 6;
798
+ _context14.next = 6;
450
799
  break;
451
800
  }
452
801
  // 使用内存存储
453
802
  memStore = this.getMemoryStore(storeName);
454
- return _context8.abrupt("return", (_memStore$get = memStore.get(key)) !== null && _memStore$get !== void 0 ? _memStore$get : null);
803
+ return _context14.abrupt("return", (_memStore$get = memStore.get(key)) !== null && _memStore$get !== void 0 ? _memStore$get : null);
455
804
  case 6:
456
- return _context8.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
805
+ return _context14.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
457
806
  var result;
458
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
459
- while (1) switch (_context7.prev = _context7.next) {
807
+ return _regeneratorRuntime().wrap(function _callee11$(_context13) {
808
+ while (1) switch (_context13.prev = _context13.next) {
460
809
  case 0:
461
- if (_this6.db) {
462
- _context7.next = 3;
810
+ if (_this10.db) {
811
+ _context13.next = 3;
463
812
  break;
464
813
  }
465
814
  if (log) {
466
- _this6.app.logger.addLog({
815
+ _this10.app.logger.addLog({
467
816
  type: 'error',
468
817
  title: uuid,
469
818
  metadata: {
@@ -473,11 +822,11 @@ var IndexDBManager = /*#__PURE__*/function () {
473
822
  }
474
823
  throw new Error('数据库未连接');
475
824
  case 3:
476
- _context7.prev = 3;
477
- _context7.next = 6;
478
- return _this6.db.table(storeName).get(key);
825
+ _context13.prev = 3;
826
+ _context13.next = 6;
827
+ return _this10.db.table(storeName).get(key);
479
828
  case 6:
480
- result = _context7.sent;
829
+ result = _context13.sent;
481
830
  if (log) {
482
831
  // this.app.logger.addLog({
483
832
  // type: 'info',
@@ -490,34 +839,34 @@ var IndexDBManager = /*#__PURE__*/function () {
490
839
  // metadata: { msg: '事务完成' }
491
840
  // });
492
841
  }
493
- return _context7.abrupt("return", result !== null && result !== void 0 ? result : null);
842
+ return _context13.abrupt("return", result !== null && result !== void 0 ? result : null);
494
843
  case 11:
495
- _context7.prev = 11;
496
- _context7.t0 = _context7["catch"](3);
844
+ _context13.prev = 11;
845
+ _context13.t0 = _context13["catch"](3);
497
846
  if (log) {
498
- _this6.app.logger.addLog({
847
+ _this10.app.logger.addLog({
499
848
  type: 'error',
500
849
  title: uuid,
501
850
  metadata: {
502
851
  msg: '获取失败',
503
- error: _context7.t0.message
852
+ error: _context13.t0.message
504
853
  }
505
854
  });
506
855
  }
507
856
  throw new Error('获取数据失败');
508
857
  case 15:
509
858
  case "end":
510
- return _context7.stop();
859
+ return _context13.stop();
511
860
  }
512
- }, _callee7, null, [[3, 11]]);
861
+ }, _callee11, null, [[3, 11]]);
513
862
  }))(), "get(".concat(storeName, ")")));
514
863
  case 7:
515
864
  case "end":
516
- return _context8.stop();
865
+ return _context14.stop();
517
866
  }
518
- }, _callee8, this);
867
+ }, _callee12, this);
519
868
  }));
520
- function get(_x5, _x6) {
869
+ function get(_x7, _x8) {
521
870
  return _get.apply(this, arguments);
522
871
  }
523
872
  return get;
@@ -534,21 +883,21 @@ var IndexDBManager = /*#__PURE__*/function () {
534
883
  }, {
535
884
  key: "update",
536
885
  value: (function () {
537
- var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(storeName, data) {
538
- var _this7 = this;
886
+ var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(storeName, data) {
887
+ var _this11 = this;
539
888
  var log,
540
889
  storeConfig,
541
890
  keyPath,
542
- _key2,
891
+ _key4,
543
892
  memStore,
544
893
  uuid,
545
- _args10 = arguments;
546
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
547
- while (1) switch (_context10.prev = _context10.next) {
894
+ _args16 = arguments;
895
+ return _regeneratorRuntime().wrap(function _callee14$(_context16) {
896
+ while (1) switch (_context16.prev = _context16.next) {
548
897
  case 0:
549
- log = _args10.length > 2 && _args10[2] !== undefined ? _args10[2] : false;
898
+ log = _args16.length > 2 && _args16[2] !== undefined ? _args16[2] : false;
550
899
  if (this.useIndexDB) {
551
- _context10.next = 8;
900
+ _context16.next = 8;
552
901
  break;
553
902
  }
554
903
  // 使用内存存储
@@ -556,10 +905,10 @@ var IndexDBManager = /*#__PURE__*/function () {
556
905
  return s.name === storeName;
557
906
  });
558
907
  keyPath = (storeConfig === null || storeConfig === void 0 ? void 0 : storeConfig.keyPath) || 'id';
559
- _key2 = data[keyPath];
908
+ _key4 = data[keyPath];
560
909
  memStore = this.getMemoryStore(storeName);
561
- memStore.set(_key2, data);
562
- return _context10.abrupt("return", data);
910
+ memStore.set(_key4, data);
911
+ return _context16.abrupt("return", data);
563
912
  case 8:
564
913
  uuid = "[ IndexDB ] UPDATE: - ".concat(storeName, " - ").concat(dayjs().valueOf());
565
914
  if (log) {
@@ -569,16 +918,16 @@ var IndexDBManager = /*#__PURE__*/function () {
569
918
  // metadata: { msg: '更新数据前', data: data }
570
919
  // })
571
920
  }
572
- return _context10.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
573
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
574
- while (1) switch (_context9.prev = _context9.next) {
921
+ return _context16.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
922
+ return _regeneratorRuntime().wrap(function _callee13$(_context15) {
923
+ while (1) switch (_context15.prev = _context15.next) {
575
924
  case 0:
576
- if (_this7.db) {
577
- _context9.next = 3;
925
+ if (_this11.db) {
926
+ _context15.next = 3;
578
927
  break;
579
928
  }
580
929
  if (log) {
581
- _this7.app.logger.addLog({
930
+ _this11.app.logger.addLog({
582
931
  type: 'error',
583
932
  title: uuid,
584
933
  metadata: {
@@ -588,9 +937,9 @@ var IndexDBManager = /*#__PURE__*/function () {
588
937
  }
589
938
  throw new Error('数据库未连接');
590
939
  case 3:
591
- _context9.prev = 3;
592
- _context9.next = 6;
593
- return _this7.db.table(storeName).put(data);
940
+ _context15.prev = 3;
941
+ _context15.next = 6;
942
+ return _this11.db.table(storeName).put(data);
594
943
  case 6:
595
944
  if (log) {
596
945
  // this.app.logger.addLog({
@@ -605,32 +954,32 @@ var IndexDBManager = /*#__PURE__*/function () {
605
954
  // metadata: { msg: '事务完成' }
606
955
  // });
607
956
  }
608
- return _context9.abrupt("return", data);
957
+ return _context15.abrupt("return", data);
609
958
  case 10:
610
- _context9.prev = 10;
611
- _context9.t0 = _context9["catch"](3);
612
- _this7.app.logger.addLog({
959
+ _context15.prev = 10;
960
+ _context15.t0 = _context15["catch"](3);
961
+ _this11.app.logger.addLog({
613
962
  type: 'error',
614
963
  title: uuid,
615
964
  metadata: {
616
965
  msg: '数据更新失败',
617
- error: _context9.t0.message
966
+ error: _context15.t0.message
618
967
  }
619
968
  });
620
- throw new Error(_context9.t0 === null || _context9.t0 === void 0 ? void 0 : _context9.t0.message);
969
+ throw new Error(_context15.t0 === null || _context15.t0 === void 0 ? void 0 : _context15.t0.message);
621
970
  case 14:
622
971
  case "end":
623
- return _context9.stop();
972
+ return _context15.stop();
624
973
  }
625
- }, _callee9, null, [[3, 10]]);
974
+ }, _callee13, null, [[3, 10]]);
626
975
  }))(), "update(".concat(storeName, ")")));
627
976
  case 11:
628
977
  case "end":
629
- return _context10.stop();
978
+ return _context16.stop();
630
979
  }
631
- }, _callee10, this);
980
+ }, _callee14, this);
632
981
  }));
633
- function update(_x7, _x8) {
982
+ function update(_x9, _x10) {
634
983
  return _update.apply(this, arguments);
635
984
  }
636
985
  return update;
@@ -645,52 +994,52 @@ var IndexDBManager = /*#__PURE__*/function () {
645
994
  }, {
646
995
  key: "delete",
647
996
  value: (function () {
648
- var _delete2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(storeName, key) {
649
- var _this8 = this;
997
+ var _delete2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(storeName, key) {
998
+ var _this12 = this;
650
999
  var memStore;
651
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
652
- while (1) switch (_context12.prev = _context12.next) {
1000
+ return _regeneratorRuntime().wrap(function _callee16$(_context18) {
1001
+ while (1) switch (_context18.prev = _context18.next) {
653
1002
  case 0:
654
1003
  if (this.useIndexDB) {
655
- _context12.next = 3;
1004
+ _context18.next = 3;
656
1005
  break;
657
1006
  }
658
1007
  // 使用内存存储
659
1008
  memStore = this.getMemoryStore(storeName);
660
- return _context12.abrupt("return", memStore.delete(key));
1009
+ return _context18.abrupt("return", memStore.delete(key));
661
1010
  case 3:
662
- return _context12.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
663
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
664
- while (1) switch (_context11.prev = _context11.next) {
1011
+ return _context18.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1012
+ return _regeneratorRuntime().wrap(function _callee15$(_context17) {
1013
+ while (1) switch (_context17.prev = _context17.next) {
665
1014
  case 0:
666
- if (_this8.db) {
667
- _context11.next = 2;
1015
+ if (_this12.db) {
1016
+ _context17.next = 2;
668
1017
  break;
669
1018
  }
670
1019
  throw new Error('数据库未连接');
671
1020
  case 2:
672
- _context11.prev = 2;
673
- _context11.next = 5;
674
- return _this8.db.table(storeName).delete(key);
1021
+ _context17.prev = 2;
1022
+ _context17.next = 5;
1023
+ return _this12.db.table(storeName).delete(key);
675
1024
  case 5:
676
- return _context11.abrupt("return", true);
1025
+ return _context17.abrupt("return", true);
677
1026
  case 8:
678
- _context11.prev = 8;
679
- _context11.t0 = _context11["catch"](2);
1027
+ _context17.prev = 8;
1028
+ _context17.t0 = _context17["catch"](2);
680
1029
  throw new Error('删除数据失败');
681
1030
  case 11:
682
1031
  case "end":
683
- return _context11.stop();
1032
+ return _context17.stop();
684
1033
  }
685
- }, _callee11, null, [[2, 8]]);
1034
+ }, _callee15, null, [[2, 8]]);
686
1035
  }))(), "delete(".concat(storeName, ")")));
687
1036
  case 4:
688
1037
  case "end":
689
- return _context12.stop();
1038
+ return _context18.stop();
690
1039
  }
691
- }, _callee12, this);
1040
+ }, _callee16, this);
692
1041
  }));
693
- function _delete(_x9, _x10) {
1042
+ function _delete(_x11, _x12) {
694
1043
  return _delete2.apply(this, arguments);
695
1044
  }
696
1045
  return _delete;
@@ -707,20 +1056,20 @@ var IndexDBManager = /*#__PURE__*/function () {
707
1056
  }, {
708
1057
  key: "getByIndex",
709
1058
  value: (function () {
710
- var _getByIndex = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(storeName, indexName, indexValue) {
711
- var _this9 = this;
1059
+ var _getByIndex = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(storeName, indexName, indexValue) {
1060
+ var _this13 = this;
712
1061
  var _storeConfig$indexes, allData, storeConfig, index;
713
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
714
- while (1) switch (_context14.prev = _context14.next) {
1062
+ return _regeneratorRuntime().wrap(function _callee18$(_context20) {
1063
+ while (1) switch (_context20.prev = _context20.next) {
715
1064
  case 0:
716
1065
  if (this.useIndexDB) {
717
- _context14.next = 9;
1066
+ _context20.next = 9;
718
1067
  break;
719
1068
  }
720
- _context14.next = 3;
1069
+ _context20.next = 3;
721
1070
  return this.getAll(storeName);
722
1071
  case 3:
723
- allData = _context14.sent;
1072
+ allData = _context20.sent;
724
1073
  storeConfig = this.stores.find(function (s) {
725
1074
  return s.name === storeName;
726
1075
  });
@@ -728,49 +1077,49 @@ var IndexDBManager = /*#__PURE__*/function () {
728
1077
  return i.name === indexName;
729
1078
  });
730
1079
  if (index) {
731
- _context14.next = 8;
1080
+ _context20.next = 8;
732
1081
  break;
733
1082
  }
734
- return _context14.abrupt("return", null);
1083
+ return _context20.abrupt("return", null);
735
1084
  case 8:
736
- return _context14.abrupt("return", allData.find(function (item) {
1085
+ return _context20.abrupt("return", allData.find(function (item) {
737
1086
  return item[index.keyPath] === indexValue;
738
1087
  }) || null);
739
1088
  case 9:
740
- return _context14.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
1089
+ return _context20.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
741
1090
  var result;
742
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
743
- while (1) switch (_context13.prev = _context13.next) {
1091
+ return _regeneratorRuntime().wrap(function _callee17$(_context19) {
1092
+ while (1) switch (_context19.prev = _context19.next) {
744
1093
  case 0:
745
- if (_this9.db) {
746
- _context13.next = 2;
1094
+ if (_this13.db) {
1095
+ _context19.next = 2;
747
1096
  break;
748
1097
  }
749
1098
  throw new Error('数据库未连接');
750
1099
  case 2:
751
- _context13.prev = 2;
752
- _context13.next = 5;
753
- return _this9.db.table(storeName).where(indexName).equals(indexValue).first();
1100
+ _context19.prev = 2;
1101
+ _context19.next = 5;
1102
+ return _this13.db.table(storeName).where(indexName).equals(indexValue).first();
754
1103
  case 5:
755
- result = _context13.sent;
756
- return _context13.abrupt("return", result || null);
1104
+ result = _context19.sent;
1105
+ return _context19.abrupt("return", result || null);
757
1106
  case 9:
758
- _context13.prev = 9;
759
- _context13.t0 = _context13["catch"](2);
1107
+ _context19.prev = 9;
1108
+ _context19.t0 = _context19["catch"](2);
760
1109
  throw new Error('通过索引获取数据失败');
761
1110
  case 12:
762
1111
  case "end":
763
- return _context13.stop();
1112
+ return _context19.stop();
764
1113
  }
765
- }, _callee13, null, [[2, 9]]);
1114
+ }, _callee17, null, [[2, 9]]);
766
1115
  }))(), "getByIndex(".concat(storeName, ", ").concat(indexName, ")")));
767
1116
  case 10:
768
1117
  case "end":
769
- return _context14.stop();
1118
+ return _context20.stop();
770
1119
  }
771
- }, _callee14, this);
1120
+ }, _callee18, this);
772
1121
  }));
773
- function getByIndex(_x11, _x12, _x13) {
1122
+ function getByIndex(_x13, _x14, _x15) {
774
1123
  return _getByIndex.apply(this, arguments);
775
1124
  }
776
1125
  return getByIndex;
@@ -786,20 +1135,20 @@ var IndexDBManager = /*#__PURE__*/function () {
786
1135
  }, {
787
1136
  key: "existsByIndex",
788
1137
  value: (function () {
789
- var _existsByIndex = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(storeName, indexName, indexValue) {
790
- var _this10 = this;
1138
+ var _existsByIndex = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(storeName, indexName, indexValue) {
1139
+ var _this14 = this;
791
1140
  var _storeConfig$indexes2, allData, storeConfig, index;
792
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
793
- while (1) switch (_context16.prev = _context16.next) {
1141
+ return _regeneratorRuntime().wrap(function _callee20$(_context22) {
1142
+ while (1) switch (_context22.prev = _context22.next) {
794
1143
  case 0:
795
1144
  if (this.useIndexDB) {
796
- _context16.next = 9;
1145
+ _context22.next = 9;
797
1146
  break;
798
1147
  }
799
- _context16.next = 3;
1148
+ _context22.next = 3;
800
1149
  return this.getAll(storeName);
801
1150
  case 3:
802
- allData = _context16.sent;
1151
+ allData = _context22.sent;
803
1152
  storeConfig = this.stores.find(function (s) {
804
1153
  return s.name === storeName;
805
1154
  });
@@ -807,49 +1156,49 @@ var IndexDBManager = /*#__PURE__*/function () {
807
1156
  return i.name === indexName;
808
1157
  });
809
1158
  if (index) {
810
- _context16.next = 8;
1159
+ _context22.next = 8;
811
1160
  break;
812
1161
  }
813
- return _context16.abrupt("return", false);
1162
+ return _context22.abrupt("return", false);
814
1163
  case 8:
815
- return _context16.abrupt("return", allData.some(function (item) {
1164
+ return _context22.abrupt("return", allData.some(function (item) {
816
1165
  return item[index.keyPath] === indexValue;
817
1166
  }));
818
1167
  case 9:
819
- return _context16.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1168
+ return _context22.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
820
1169
  var count;
821
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
822
- while (1) switch (_context15.prev = _context15.next) {
1170
+ return _regeneratorRuntime().wrap(function _callee19$(_context21) {
1171
+ while (1) switch (_context21.prev = _context21.next) {
823
1172
  case 0:
824
- if (_this10.db) {
825
- _context15.next = 2;
1173
+ if (_this14.db) {
1174
+ _context21.next = 2;
826
1175
  break;
827
1176
  }
828
1177
  throw new Error('数据库未连接');
829
1178
  case 2:
830
- _context15.prev = 2;
831
- _context15.next = 5;
832
- return _this10.db.table(storeName).where(indexName).equals(indexValue).count();
1179
+ _context21.prev = 2;
1180
+ _context21.next = 5;
1181
+ return _this14.db.table(storeName).where(indexName).equals(indexValue).count();
833
1182
  case 5:
834
- count = _context15.sent;
835
- return _context15.abrupt("return", count > 0);
1183
+ count = _context21.sent;
1184
+ return _context21.abrupt("return", count > 0);
836
1185
  case 9:
837
- _context15.prev = 9;
838
- _context15.t0 = _context15["catch"](2);
1186
+ _context21.prev = 9;
1187
+ _context21.t0 = _context21["catch"](2);
839
1188
  throw new Error('通过索引检查数据存在性失败');
840
1189
  case 12:
841
1190
  case "end":
842
- return _context15.stop();
1191
+ return _context21.stop();
843
1192
  }
844
- }, _callee15, null, [[2, 9]]);
1193
+ }, _callee19, null, [[2, 9]]);
845
1194
  }))(), "existsByIndex(".concat(storeName, ", ").concat(indexName, ")")));
846
1195
  case 10:
847
1196
  case "end":
848
- return _context16.stop();
1197
+ return _context22.stop();
849
1198
  }
850
- }, _callee16, this);
1199
+ }, _callee20, this);
851
1200
  }));
852
- function existsByIndex(_x14, _x15, _x16) {
1201
+ function existsByIndex(_x16, _x17, _x18) {
853
1202
  return _existsByIndex.apply(this, arguments);
854
1203
  }
855
1204
  return existsByIndex;
@@ -866,20 +1215,20 @@ var IndexDBManager = /*#__PURE__*/function () {
866
1215
  }, {
867
1216
  key: "getAllByIndex",
868
1217
  value: (function () {
869
- var _getAllByIndex = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(storeName, indexName, indexValue) {
870
- var _this11 = this;
1218
+ var _getAllByIndex = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(storeName, indexName, indexValue) {
1219
+ var _this15 = this;
871
1220
  var _storeConfig$indexes3, allData, storeConfig, index;
872
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
873
- while (1) switch (_context18.prev = _context18.next) {
1221
+ return _regeneratorRuntime().wrap(function _callee22$(_context24) {
1222
+ while (1) switch (_context24.prev = _context24.next) {
874
1223
  case 0:
875
1224
  if (this.useIndexDB) {
876
- _context18.next = 9;
1225
+ _context24.next = 9;
877
1226
  break;
878
1227
  }
879
- _context18.next = 3;
1228
+ _context24.next = 3;
880
1229
  return this.getAll(storeName);
881
1230
  case 3:
882
- allData = _context18.sent;
1231
+ allData = _context24.sent;
883
1232
  storeConfig = this.stores.find(function (s) {
884
1233
  return s.name === storeName;
885
1234
  });
@@ -887,49 +1236,49 @@ var IndexDBManager = /*#__PURE__*/function () {
887
1236
  return i.name === indexName;
888
1237
  });
889
1238
  if (index) {
890
- _context18.next = 8;
1239
+ _context24.next = 8;
891
1240
  break;
892
1241
  }
893
- return _context18.abrupt("return", []);
1242
+ return _context24.abrupt("return", []);
894
1243
  case 8:
895
- return _context18.abrupt("return", allData.filter(function (item) {
1244
+ return _context24.abrupt("return", allData.filter(function (item) {
896
1245
  return item[index.keyPath] === indexValue;
897
1246
  }));
898
1247
  case 9:
899
- return _context18.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1248
+ return _context24.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
900
1249
  var results;
901
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
902
- while (1) switch (_context17.prev = _context17.next) {
1250
+ return _regeneratorRuntime().wrap(function _callee21$(_context23) {
1251
+ while (1) switch (_context23.prev = _context23.next) {
903
1252
  case 0:
904
- if (_this11.db) {
905
- _context17.next = 2;
1253
+ if (_this15.db) {
1254
+ _context23.next = 2;
906
1255
  break;
907
1256
  }
908
1257
  throw new Error('数据库未连接');
909
1258
  case 2:
910
- _context17.prev = 2;
911
- _context17.next = 5;
912
- return _this11.db.table(storeName).where(indexName).equals(indexValue).toArray();
1259
+ _context23.prev = 2;
1260
+ _context23.next = 5;
1261
+ return _this15.db.table(storeName).where(indexName).equals(indexValue).toArray();
913
1262
  case 5:
914
- results = _context17.sent;
915
- return _context17.abrupt("return", results);
1263
+ results = _context23.sent;
1264
+ return _context23.abrupt("return", results);
916
1265
  case 9:
917
- _context17.prev = 9;
918
- _context17.t0 = _context17["catch"](2);
1266
+ _context23.prev = 9;
1267
+ _context23.t0 = _context23["catch"](2);
919
1268
  throw new Error('通过索引获取多条数据失败');
920
1269
  case 12:
921
1270
  case "end":
922
- return _context17.stop();
1271
+ return _context23.stop();
923
1272
  }
924
- }, _callee17, null, [[2, 9]]);
1273
+ }, _callee21, null, [[2, 9]]);
925
1274
  }))(), "getAllByIndex(".concat(storeName, ", ").concat(indexName, ")")));
926
1275
  case 10:
927
1276
  case "end":
928
- return _context18.stop();
1277
+ return _context24.stop();
929
1278
  }
930
- }, _callee18, this);
1279
+ }, _callee22, this);
931
1280
  }));
932
- function getAllByIndex(_x17, _x18, _x19) {
1281
+ function getAllByIndex(_x19, _x20, _x21) {
933
1282
  return _getAllByIndex.apply(this, arguments);
934
1283
  }
935
1284
  return getAllByIndex;
@@ -943,56 +1292,56 @@ var IndexDBManager = /*#__PURE__*/function () {
943
1292
  }, {
944
1293
  key: "count",
945
1294
  value: (function () {
946
- var _count = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(storeName) {
947
- var _this12 = this;
1295
+ var _count = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(storeName) {
1296
+ var _this16 = this;
948
1297
  var allData;
949
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
950
- while (1) switch (_context20.prev = _context20.next) {
1298
+ return _regeneratorRuntime().wrap(function _callee24$(_context26) {
1299
+ while (1) switch (_context26.prev = _context26.next) {
951
1300
  case 0:
952
1301
  if (this.useIndexDB) {
953
- _context20.next = 5;
1302
+ _context26.next = 5;
954
1303
  break;
955
1304
  }
956
- _context20.next = 3;
1305
+ _context26.next = 3;
957
1306
  return this.getAll(storeName);
958
1307
  case 3:
959
- allData = _context20.sent;
960
- return _context20.abrupt("return", allData.length);
1308
+ allData = _context26.sent;
1309
+ return _context26.abrupt("return", allData.length);
961
1310
  case 5:
962
- return _context20.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1311
+ return _context26.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
963
1312
  var _count2;
964
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
965
- while (1) switch (_context19.prev = _context19.next) {
1313
+ return _regeneratorRuntime().wrap(function _callee23$(_context25) {
1314
+ while (1) switch (_context25.prev = _context25.next) {
966
1315
  case 0:
967
- if (_this12.db) {
968
- _context19.next = 2;
1316
+ if (_this16.db) {
1317
+ _context25.next = 2;
969
1318
  break;
970
1319
  }
971
1320
  throw new Error('数据库未连接');
972
1321
  case 2:
973
- _context19.prev = 2;
974
- _context19.next = 5;
975
- return _this12.db.table(storeName).count();
1322
+ _context25.prev = 2;
1323
+ _context25.next = 5;
1324
+ return _this16.db.table(storeName).count();
976
1325
  case 5:
977
- _count2 = _context19.sent;
978
- return _context19.abrupt("return", _count2);
1326
+ _count2 = _context25.sent;
1327
+ return _context25.abrupt("return", _count2);
979
1328
  case 9:
980
- _context19.prev = 9;
981
- _context19.t0 = _context19["catch"](2);
1329
+ _context25.prev = 9;
1330
+ _context25.t0 = _context25["catch"](2);
982
1331
  throw new Error('统计数据数量失败');
983
1332
  case 12:
984
1333
  case "end":
985
- return _context19.stop();
1334
+ return _context25.stop();
986
1335
  }
987
- }, _callee19, null, [[2, 9]]);
1336
+ }, _callee23, null, [[2, 9]]);
988
1337
  }))(), "count(".concat(storeName, ")")));
989
1338
  case 6:
990
1339
  case "end":
991
- return _context20.stop();
1340
+ return _context26.stop();
992
1341
  }
993
- }, _callee20, this);
1342
+ }, _callee24, this);
994
1343
  }));
995
- function count(_x20) {
1344
+ function count(_x22) {
996
1345
  return _count.apply(this, arguments);
997
1346
  }
998
1347
  return count;
@@ -1008,56 +1357,56 @@ var IndexDBManager = /*#__PURE__*/function () {
1008
1357
  }, {
1009
1358
  key: "countByIndex",
1010
1359
  value: (function () {
1011
- var _countByIndex = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(storeName, indexName, indexValue) {
1012
- var _this13 = this;
1360
+ var _countByIndex = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(storeName, indexName, indexValue) {
1361
+ var _this17 = this;
1013
1362
  var matchingData;
1014
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1015
- while (1) switch (_context22.prev = _context22.next) {
1363
+ return _regeneratorRuntime().wrap(function _callee26$(_context28) {
1364
+ while (1) switch (_context28.prev = _context28.next) {
1016
1365
  case 0:
1017
1366
  if (this.useIndexDB) {
1018
- _context22.next = 5;
1367
+ _context28.next = 5;
1019
1368
  break;
1020
1369
  }
1021
- _context22.next = 3;
1370
+ _context28.next = 3;
1022
1371
  return this.getAllByIndex(storeName, indexName, indexValue);
1023
1372
  case 3:
1024
- matchingData = _context22.sent;
1025
- return _context22.abrupt("return", matchingData.length);
1373
+ matchingData = _context28.sent;
1374
+ return _context28.abrupt("return", matchingData.length);
1026
1375
  case 5:
1027
- return _context22.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1376
+ return _context28.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
1028
1377
  var count;
1029
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1030
- while (1) switch (_context21.prev = _context21.next) {
1378
+ return _regeneratorRuntime().wrap(function _callee25$(_context27) {
1379
+ while (1) switch (_context27.prev = _context27.next) {
1031
1380
  case 0:
1032
- if (_this13.db) {
1033
- _context21.next = 2;
1381
+ if (_this17.db) {
1382
+ _context27.next = 2;
1034
1383
  break;
1035
1384
  }
1036
1385
  throw new Error('数据库未连接');
1037
1386
  case 2:
1038
- _context21.prev = 2;
1039
- _context21.next = 5;
1040
- return _this13.db.table(storeName).where(indexName).equals(indexValue).count();
1387
+ _context27.prev = 2;
1388
+ _context27.next = 5;
1389
+ return _this17.db.table(storeName).where(indexName).equals(indexValue).count();
1041
1390
  case 5:
1042
- count = _context21.sent;
1043
- return _context21.abrupt("return", count);
1391
+ count = _context27.sent;
1392
+ return _context27.abrupt("return", count);
1044
1393
  case 9:
1045
- _context21.prev = 9;
1046
- _context21.t0 = _context21["catch"](2);
1394
+ _context27.prev = 9;
1395
+ _context27.t0 = _context27["catch"](2);
1047
1396
  throw new Error('通过索引统计数据数量失败');
1048
1397
  case 12:
1049
1398
  case "end":
1050
- return _context21.stop();
1399
+ return _context27.stop();
1051
1400
  }
1052
- }, _callee21, null, [[2, 9]]);
1401
+ }, _callee25, null, [[2, 9]]);
1053
1402
  }))(), "countByIndex(".concat(storeName, ", ").concat(indexName, ")")));
1054
1403
  case 6:
1055
1404
  case "end":
1056
- return _context22.stop();
1405
+ return _context28.stop();
1057
1406
  }
1058
- }, _callee22, this);
1407
+ }, _callee26, this);
1059
1408
  }));
1060
- function countByIndex(_x21, _x22, _x23) {
1409
+ function countByIndex(_x23, _x24, _x25) {
1061
1410
  return _countByIndex.apply(this, arguments);
1062
1411
  }
1063
1412
  return countByIndex;
@@ -1072,62 +1421,62 @@ var IndexDBManager = /*#__PURE__*/function () {
1072
1421
  }, {
1073
1422
  key: "getAll",
1074
1423
  value: (function () {
1075
- var _getAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(storeName) {
1076
- var _this14 = this;
1424
+ var _getAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(storeName) {
1425
+ var _this18 = this;
1077
1426
  var memStore;
1078
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1079
- while (1) switch (_context24.prev = _context24.next) {
1427
+ return _regeneratorRuntime().wrap(function _callee28$(_context30) {
1428
+ while (1) switch (_context30.prev = _context30.next) {
1080
1429
  case 0:
1081
1430
  if (this.useIndexDB) {
1082
- _context24.next = 3;
1431
+ _context30.next = 3;
1083
1432
  break;
1084
1433
  }
1085
1434
  // 使用内存存储
1086
1435
  memStore = this.getMemoryStore(storeName);
1087
- return _context24.abrupt("return", Array.from(memStore.values()));
1436
+ return _context30.abrupt("return", Array.from(memStore.values()));
1088
1437
  case 3:
1089
- return _context24.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
1438
+ return _context30.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
1090
1439
  var results;
1091
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1092
- while (1) switch (_context23.prev = _context23.next) {
1440
+ return _regeneratorRuntime().wrap(function _callee27$(_context29) {
1441
+ while (1) switch (_context29.prev = _context29.next) {
1093
1442
  case 0:
1094
- if (_this14.db) {
1095
- _context23.next = 2;
1443
+ if (_this18.db) {
1444
+ _context29.next = 2;
1096
1445
  break;
1097
1446
  }
1098
1447
  throw new Error('数据库未连接');
1099
1448
  case 2:
1100
- _context23.prev = 2;
1101
- _context23.next = 5;
1102
- return _this14.db.table(storeName).toArray();
1449
+ _context29.prev = 2;
1450
+ _context29.next = 5;
1451
+ return _this18.db.table(storeName).toArray();
1103
1452
  case 5:
1104
- results = _context23.sent;
1105
- return _context23.abrupt("return", results);
1453
+ results = _context29.sent;
1454
+ return _context29.abrupt("return", results);
1106
1455
  case 9:
1107
- _context23.prev = 9;
1108
- _context23.t0 = _context23["catch"](2);
1109
- _this14.app.logger.addLog({
1456
+ _context29.prev = 9;
1457
+ _context29.t0 = _context29["catch"](2);
1458
+ _this18.app.logger.addLog({
1110
1459
  type: 'error',
1111
1460
  title: "[ IndexDB ] ERROR: - getAll(".concat(storeName, ")"),
1112
1461
  metadata: {
1113
1462
  msg: '获取所有数据失败',
1114
- error: _context23.t0.message
1463
+ error: _context29.t0.message
1115
1464
  }
1116
1465
  });
1117
- throw new Error(_context23.t0 === null || _context23.t0 === void 0 ? void 0 : _context23.t0.message);
1466
+ throw new Error(_context29.t0 === null || _context29.t0 === void 0 ? void 0 : _context29.t0.message);
1118
1467
  case 13:
1119
1468
  case "end":
1120
- return _context23.stop();
1469
+ return _context29.stop();
1121
1470
  }
1122
- }, _callee23, null, [[2, 9]]);
1471
+ }, _callee27, null, [[2, 9]]);
1123
1472
  }))(), "getAll(".concat(storeName, ")")));
1124
1473
  case 4:
1125
1474
  case "end":
1126
- return _context24.stop();
1475
+ return _context30.stop();
1127
1476
  }
1128
- }, _callee24, this);
1477
+ }, _callee28, this);
1129
1478
  }));
1130
- function getAll(_x24) {
1479
+ function getAll(_x26) {
1131
1480
  return _getAll.apply(this, arguments);
1132
1481
  }
1133
1482
  return getAll;
@@ -1141,53 +1490,53 @@ var IndexDBManager = /*#__PURE__*/function () {
1141
1490
  }, {
1142
1491
  key: "clear",
1143
1492
  value: (function () {
1144
- var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(storeName) {
1145
- var _this15 = this;
1493
+ var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(storeName) {
1494
+ var _this19 = this;
1146
1495
  var memStore;
1147
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1148
- while (1) switch (_context26.prev = _context26.next) {
1496
+ return _regeneratorRuntime().wrap(function _callee30$(_context32) {
1497
+ while (1) switch (_context32.prev = _context32.next) {
1149
1498
  case 0:
1150
1499
  if (this.useIndexDB) {
1151
- _context26.next = 4;
1500
+ _context32.next = 4;
1152
1501
  break;
1153
1502
  }
1154
1503
  // 使用内存存储
1155
1504
  memStore = this.getMemoryStore(storeName);
1156
1505
  memStore.clear();
1157
- return _context26.abrupt("return", true);
1506
+ return _context32.abrupt("return", true);
1158
1507
  case 4:
1159
- return _context26.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
1160
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1161
- while (1) switch (_context25.prev = _context25.next) {
1508
+ return _context32.abrupt("return", this.withTimeout(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
1509
+ return _regeneratorRuntime().wrap(function _callee29$(_context31) {
1510
+ while (1) switch (_context31.prev = _context31.next) {
1162
1511
  case 0:
1163
- if (_this15.db) {
1164
- _context25.next = 2;
1512
+ if (_this19.db) {
1513
+ _context31.next = 2;
1165
1514
  break;
1166
1515
  }
1167
1516
  throw new Error('数据库未连接');
1168
1517
  case 2:
1169
- _context25.prev = 2;
1170
- _context25.next = 5;
1171
- return _this15.db.table(storeName).clear();
1518
+ _context31.prev = 2;
1519
+ _context31.next = 5;
1520
+ return _this19.db.table(storeName).clear();
1172
1521
  case 5:
1173
- return _context25.abrupt("return", true);
1522
+ return _context31.abrupt("return", true);
1174
1523
  case 8:
1175
- _context25.prev = 8;
1176
- _context25.t0 = _context25["catch"](2);
1524
+ _context31.prev = 8;
1525
+ _context31.t0 = _context31["catch"](2);
1177
1526
  throw new Error('清空数据失败');
1178
1527
  case 11:
1179
1528
  case "end":
1180
- return _context25.stop();
1529
+ return _context31.stop();
1181
1530
  }
1182
- }, _callee25, null, [[2, 8]]);
1531
+ }, _callee29, null, [[2, 8]]);
1183
1532
  }))(), "clear(".concat(storeName, ")")));
1184
1533
  case 5:
1185
1534
  case "end":
1186
- return _context26.stop();
1535
+ return _context32.stop();
1187
1536
  }
1188
- }, _callee26, this);
1537
+ }, _callee30, this);
1189
1538
  }));
1190
- function clear(_x25) {
1539
+ function clear(_x27) {
1191
1540
  return _clear.apply(this, arguments);
1192
1541
  }
1193
1542
  return clear;