@nokecy/qc-ui 1.0.93 → 1.0.94
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/dist/cjs/ag-grid-plus/ag-gridPlus.js +24 -18
- package/dist/cjs/ag-grid-plus/context/gridContext.d.ts +6 -0
- package/dist/cjs/ag-grid-plus/index.d.ts +2 -4
- package/dist/cjs/ag-grid-plus/index.js +18 -79
- package/dist/cjs/ag-grid-plus/querySchemes/components/QuerySchemesManager.js +134 -117
- package/dist/cjs/ag-grid-plus/querySchemes/types.d.ts +2 -0
- package/dist/cjs/ag-grid-plus/schemes/index.d.ts +7 -0
- package/dist/cjs/ag-grid-plus/schemes/index.js +40 -0
- package/dist/cjs/ag-grid-plus/schemes/storage/configMerger.d.ts +10 -0
- package/dist/cjs/ag-grid-plus/schemes/storage/configMerger.js +34 -0
- package/dist/cjs/ag-grid-plus/schemes/storage/localStorageAdapter.d.ts +17 -2
- package/dist/cjs/ag-grid-plus/schemes/storage/localStorageAdapter.js +27 -7
- package/dist/cjs/ag-grid-plus/schemes/storage/priorityStorageAdapter.d.ts +122 -0
- package/dist/cjs/ag-grid-plus/schemes/storage/priorityStorageAdapter.js +476 -0
- package/dist/cjs/ag-grid-plus/schemes/storage/remoteStorageAdapter.d.ts +139 -0
- package/dist/cjs/ag-grid-plus/schemes/storage/remoteStorageAdapter.js +746 -0
- package/dist/cjs/ag-grid-plus/schemes/storage/useRemoteStorage.d.ts +29 -0
- package/dist/cjs/ag-grid-plus/schemes/storage/useRemoteStorage.js +45 -0
- package/dist/cjs/ag-grid-plus/setting/ColumnSetting.js +154 -270
- package/dist/cjs/ag-grid-plus/storage/index.d.ts +10 -5
- package/dist/cjs/ag-grid-plus/storage/index.js +0 -44
- package/dist/cjs/array-table/index.js +5 -3
- package/dist/cjs/draggableModal/index.d.ts +1 -1
- package/dist/cjs/draggableModal/index.js +23 -93
- package/dist/cjs/draggableModal/style.less +0 -73
- package/dist/cjs/index.d.ts +2 -3
- package/dist/cjs/index.js +8 -80
- package/dist/esm/ag-grid-plus/ag-gridPlus.js +24 -18
- package/dist/esm/ag-grid-plus/context/gridContext.d.ts +6 -0
- package/dist/esm/ag-grid-plus/errors/ErrorBoundary.d.ts +1 -1
- package/dist/esm/ag-grid-plus/index.d.ts +2 -4
- package/dist/esm/ag-grid-plus/index.js +5 -3
- package/dist/esm/ag-grid-plus/querySchemes/components/QuerySchemesManager.js +135 -118
- package/dist/esm/ag-grid-plus/querySchemes/types.d.ts +2 -0
- package/dist/esm/ag-grid-plus/schemes/index.d.ts +7 -0
- package/dist/esm/ag-grid-plus/schemes/index.js +5 -0
- package/dist/esm/ag-grid-plus/schemes/storage/configMerger.d.ts +10 -0
- package/dist/esm/ag-grid-plus/schemes/storage/configMerger.js +28 -0
- package/dist/esm/ag-grid-plus/schemes/storage/localStorageAdapter.d.ts +17 -2
- package/dist/esm/ag-grid-plus/schemes/storage/localStorageAdapter.js +29 -7
- package/dist/esm/ag-grid-plus/schemes/storage/priorityStorageAdapter.d.ts +122 -0
- package/dist/esm/ag-grid-plus/schemes/storage/priorityStorageAdapter.js +471 -0
- package/dist/esm/ag-grid-plus/schemes/storage/remoteStorageAdapter.d.ts +139 -0
- package/dist/esm/ag-grid-plus/schemes/storage/remoteStorageAdapter.js +746 -0
- package/dist/esm/ag-grid-plus/schemes/storage/useRemoteStorage.d.ts +29 -0
- package/dist/esm/ag-grid-plus/schemes/storage/useRemoteStorage.js +40 -0
- package/dist/esm/ag-grid-plus/setting/ColumnSetting.js +156 -272
- package/dist/esm/ag-grid-plus/storage/index.d.ts +10 -5
- package/dist/esm/ag-grid-plus/storage/index.js +13 -5
- package/dist/esm/array-table/index.js +6 -2
- package/dist/esm/draggableModal/index.d.ts +1 -1
- package/dist/esm/draggableModal/index.js +24 -93
- package/dist/esm/draggableModal/style.less +0 -73
- package/dist/esm/index.d.ts +2 -3
- package/dist/esm/index.js +10 -7
- package/dist/esm/standardFormDialog/useStandardFormSchema.d.ts +1 -1
- package/dist/umd/qc-ui.min.css +1 -1
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/ag-grid-plus/storage/MemoryStorageAdapter.d.ts +0 -76
- package/dist/cjs/ag-grid-plus/storage/MemoryStorageAdapter.js +0 -276
- package/dist/cjs/ag-grid-plus/storage/SchemeSyncManager.d.ts +0 -141
- package/dist/cjs/ag-grid-plus/storage/SchemeSyncManager.js +0 -902
- package/dist/cjs/ag-grid-plus/storage/globalSyncManager.d.ts +0 -106
- package/dist/cjs/ag-grid-plus/storage/globalSyncManager.js +0 -364
- package/dist/cjs/ag-grid-plus/storage/types.d.ts +0 -150
- package/dist/cjs/ag-grid-plus/storage/types.js +0 -5
- package/dist/esm/ag-grid-plus/storage/MemoryStorageAdapter.d.ts +0 -76
- package/dist/esm/ag-grid-plus/storage/MemoryStorageAdapter.js +0 -273
- package/dist/esm/ag-grid-plus/storage/SchemeSyncManager.d.ts +0 -141
- package/dist/esm/ag-grid-plus/storage/SchemeSyncManager.js +0 -896
- package/dist/esm/ag-grid-plus/storage/globalSyncManager.d.ts +0 -106
- package/dist/esm/ag-grid-plus/storage/globalSyncManager.js +0 -350
- package/dist/esm/ag-grid-plus/storage/types.d.ts +0 -150
- package/dist/esm/ag-grid-plus/storage/types.js +0 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { ColumnScheme, StorageAdapter } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* 优先级存储适配器配置
|
|
4
|
+
*/
|
|
5
|
+
export interface PriorityStorageConfig {
|
|
6
|
+
/**
|
|
7
|
+
* 主存储适配器(优先使用)
|
|
8
|
+
* 通常是远端存储适配器
|
|
9
|
+
*/
|
|
10
|
+
primary: StorageAdapter;
|
|
11
|
+
/**
|
|
12
|
+
* 备用存储适配器(主存储失败时使用)
|
|
13
|
+
* 通常是本地存储适配器
|
|
14
|
+
* 可选,如果不提供则主存储失败时直接抛出错误
|
|
15
|
+
*/
|
|
16
|
+
fallback?: StorageAdapter;
|
|
17
|
+
/**
|
|
18
|
+
* 是否启用自动降级
|
|
19
|
+
* 当主存储连续失败达到阈值时,自动切换到备用存储
|
|
20
|
+
* 默认: false
|
|
21
|
+
*/
|
|
22
|
+
enableAutoDemotion?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* 自动降级的失败阈值
|
|
25
|
+
* 默认: 3
|
|
26
|
+
*/
|
|
27
|
+
demotionThreshold?: number;
|
|
28
|
+
/**
|
|
29
|
+
* 降级恢复检测间隔(毫秒)
|
|
30
|
+
* 定期检测主存储是否恢复,如果恢复则切换回主存储
|
|
31
|
+
* 默认: 60000 (1分钟)
|
|
32
|
+
*/
|
|
33
|
+
recoveryCheckInterval?: number;
|
|
34
|
+
/**
|
|
35
|
+
* 是否在主存储可用时同步数据到备用存储
|
|
36
|
+
* 默认: false
|
|
37
|
+
*/
|
|
38
|
+
syncToFallback?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* 错误处理回调
|
|
41
|
+
*/
|
|
42
|
+
onError?: (error: Error, adapter: 'primary' | 'fallback') => void;
|
|
43
|
+
/**
|
|
44
|
+
* 降级事件回调
|
|
45
|
+
*/
|
|
46
|
+
onDemotion?: () => void;
|
|
47
|
+
/**
|
|
48
|
+
* 恢复事件回调
|
|
49
|
+
*/
|
|
50
|
+
onRecovery?: () => void;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* 优先级存储适配器
|
|
54
|
+
* 实现远端优先、本地备用的存储策略
|
|
55
|
+
*
|
|
56
|
+
* 核心特性:
|
|
57
|
+
* 1. 主存储优先:优先使用主存储(通常是远端)
|
|
58
|
+
* 2. 自动降级:主存储连续失败时,自动切换到备用存储
|
|
59
|
+
* 3. 自动恢复:定期检测主存储状态,恢复后自动切换回主存储
|
|
60
|
+
* 4. 数据同步:可选地将主存储数据同步到备用存储
|
|
61
|
+
* 5. 完全隔离:不会混用主存储和备用存储的数据
|
|
62
|
+
*/
|
|
63
|
+
export declare class PriorityStorageAdapter implements StorageAdapter {
|
|
64
|
+
private config;
|
|
65
|
+
private failureCount;
|
|
66
|
+
private isDemoted;
|
|
67
|
+
private recoveryCheckTimer?;
|
|
68
|
+
constructor(config: PriorityStorageConfig);
|
|
69
|
+
/**
|
|
70
|
+
* 开始恢复检测
|
|
71
|
+
*/
|
|
72
|
+
private startRecoveryCheck;
|
|
73
|
+
/**
|
|
74
|
+
* 停止恢复检测
|
|
75
|
+
*/
|
|
76
|
+
private stopRecoveryCheck;
|
|
77
|
+
/**
|
|
78
|
+
* 处理主存储错误
|
|
79
|
+
*/
|
|
80
|
+
private handlePrimaryError;
|
|
81
|
+
/**
|
|
82
|
+
* 执行带降级的操作
|
|
83
|
+
*/
|
|
84
|
+
private executeWithFallback;
|
|
85
|
+
/**
|
|
86
|
+
* 获取指定表格的所有方案
|
|
87
|
+
*/
|
|
88
|
+
getSchemes(gridId: string): Promise<ColumnScheme[]>;
|
|
89
|
+
/**
|
|
90
|
+
* 保存方案列表
|
|
91
|
+
* 只保存到主存储,确保数据一致性
|
|
92
|
+
*/
|
|
93
|
+
saveSchemes(gridId: string, schemes: ColumnScheme[]): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* 清除指定表格的所有方案
|
|
96
|
+
*/
|
|
97
|
+
clearSchemes(gridId: string): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* 获取当前激活的方案ID
|
|
100
|
+
*/
|
|
101
|
+
getCurrentSchemeId(gridId: string): Promise<string | null>;
|
|
102
|
+
/**
|
|
103
|
+
* 保存当前激活的方案ID
|
|
104
|
+
*/
|
|
105
|
+
saveCurrentSchemeId(gridId: string, schemeId: string | null): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* 获取当前存储状态
|
|
108
|
+
*/
|
|
109
|
+
getStatus(): {
|
|
110
|
+
isDemoted: boolean;
|
|
111
|
+
failureCount: number;
|
|
112
|
+
primaryAvailable: boolean;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* 手动重置到主存储
|
|
116
|
+
*/
|
|
117
|
+
resetToPrimary(): void;
|
|
118
|
+
/**
|
|
119
|
+
* 清理资源
|
|
120
|
+
*/
|
|
121
|
+
dispose(): void;
|
|
122
|
+
}
|
|
@@ -0,0 +1,471 @@
|
|
|
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 _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
|
+
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); } }
|
|
4
|
+
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); }); }; }
|
|
5
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
7
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
8
|
+
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; }
|
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
|
+
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); }
|
|
11
|
+
/**
|
|
12
|
+
* 优先级存储适配器配置
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 优先级存储适配器
|
|
17
|
+
* 实现远端优先、本地备用的存储策略
|
|
18
|
+
*
|
|
19
|
+
* 核心特性:
|
|
20
|
+
* 1. 主存储优先:优先使用主存储(通常是远端)
|
|
21
|
+
* 2. 自动降级:主存储连续失败时,自动切换到备用存储
|
|
22
|
+
* 3. 自动恢复:定期检测主存储状态,恢复后自动切换回主存储
|
|
23
|
+
* 4. 数据同步:可选地将主存储数据同步到备用存储
|
|
24
|
+
* 5. 完全隔离:不会混用主存储和备用存储的数据
|
|
25
|
+
*/
|
|
26
|
+
export var PriorityStorageAdapter = /*#__PURE__*/function () {
|
|
27
|
+
function PriorityStorageAdapter(config) {
|
|
28
|
+
var _config$enableAutoDem, _config$demotionThres, _config$recoveryCheck, _config$syncToFallbac;
|
|
29
|
+
_classCallCheck(this, PriorityStorageAdapter);
|
|
30
|
+
_defineProperty(this, "config", void 0);
|
|
31
|
+
_defineProperty(this, "failureCount", 0);
|
|
32
|
+
_defineProperty(this, "isDemoted", false);
|
|
33
|
+
_defineProperty(this, "recoveryCheckTimer", void 0);
|
|
34
|
+
this.config = {
|
|
35
|
+
primary: config.primary,
|
|
36
|
+
fallback: config.fallback,
|
|
37
|
+
enableAutoDemotion: (_config$enableAutoDem = config.enableAutoDemotion) !== null && _config$enableAutoDem !== void 0 ? _config$enableAutoDem : false,
|
|
38
|
+
demotionThreshold: (_config$demotionThres = config.demotionThreshold) !== null && _config$demotionThres !== void 0 ? _config$demotionThres : 3,
|
|
39
|
+
recoveryCheckInterval: (_config$recoveryCheck = config.recoveryCheckInterval) !== null && _config$recoveryCheck !== void 0 ? _config$recoveryCheck : 60000,
|
|
40
|
+
syncToFallback: (_config$syncToFallbac = config.syncToFallback) !== null && _config$syncToFallbac !== void 0 ? _config$syncToFallbac : false,
|
|
41
|
+
onError: config.onError,
|
|
42
|
+
onDemotion: config.onDemotion,
|
|
43
|
+
onRecovery: config.onRecovery
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// 如果启用自动降级,开始恢复检测
|
|
47
|
+
if (this.config.enableAutoDemotion && this.config.fallback) {
|
|
48
|
+
this.startRecoveryCheck();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 开始恢复检测
|
|
54
|
+
*/
|
|
55
|
+
_createClass(PriorityStorageAdapter, [{
|
|
56
|
+
key: "startRecoveryCheck",
|
|
57
|
+
value: function startRecoveryCheck() {
|
|
58
|
+
var _this = this;
|
|
59
|
+
this.recoveryCheckTimer = setInterval( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
60
|
+
var _this$config$onRecove, _this$config;
|
|
61
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
62
|
+
while (1) switch (_context.prev = _context.next) {
|
|
63
|
+
case 0:
|
|
64
|
+
if (!_this.isDemoted) {
|
|
65
|
+
_context.next = 12;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
_context.prev = 1;
|
|
69
|
+
_context.next = 4;
|
|
70
|
+
return _this.config.primary.getSchemes('__health_check__');
|
|
71
|
+
case 4:
|
|
72
|
+
// 如果成功,恢复到主存储
|
|
73
|
+
console.log('[PriorityStorageAdapter] 主存储已恢复,切换回主存储');
|
|
74
|
+
_this.isDemoted = false;
|
|
75
|
+
_this.failureCount = 0;
|
|
76
|
+
(_this$config$onRecove = (_this$config = _this.config).onRecovery) === null || _this$config$onRecove === void 0 || _this$config$onRecove.call(_this$config);
|
|
77
|
+
_context.next = 12;
|
|
78
|
+
break;
|
|
79
|
+
case 10:
|
|
80
|
+
_context.prev = 10;
|
|
81
|
+
_context.t0 = _context["catch"](1);
|
|
82
|
+
case 12:
|
|
83
|
+
case "end":
|
|
84
|
+
return _context.stop();
|
|
85
|
+
}
|
|
86
|
+
}, _callee, null, [[1, 10]]);
|
|
87
|
+
})), this.config.recoveryCheckInterval);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 停止恢复检测
|
|
92
|
+
*/
|
|
93
|
+
}, {
|
|
94
|
+
key: "stopRecoveryCheck",
|
|
95
|
+
value: function stopRecoveryCheck() {
|
|
96
|
+
if (this.recoveryCheckTimer) {
|
|
97
|
+
clearInterval(this.recoveryCheckTimer);
|
|
98
|
+
this.recoveryCheckTimer = undefined;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* 处理主存储错误
|
|
104
|
+
*/
|
|
105
|
+
}, {
|
|
106
|
+
key: "handlePrimaryError",
|
|
107
|
+
value: function handlePrimaryError(error, operation) {
|
|
108
|
+
var _this$config$onError, _this$config2;
|
|
109
|
+
console.error("[PriorityStorageAdapter] \u4E3B\u5B58\u50A8".concat(operation, "\u5931\u8D25:"), error);
|
|
110
|
+
(_this$config$onError = (_this$config2 = this.config).onError) === null || _this$config$onError === void 0 || _this$config$onError.call(_this$config2, error, 'primary');
|
|
111
|
+
|
|
112
|
+
// 增加失败计数
|
|
113
|
+
this.failureCount++;
|
|
114
|
+
|
|
115
|
+
// 检查是否需要降级
|
|
116
|
+
if (this.config.enableAutoDemotion && this.config.fallback && !this.isDemoted && this.failureCount >= this.config.demotionThreshold) {
|
|
117
|
+
var _this$config$onDemoti, _this$config3;
|
|
118
|
+
console.warn("[PriorityStorageAdapter] \u4E3B\u5B58\u50A8\u8FDE\u7EED\u5931\u8D25".concat(this.failureCount, "\u6B21\uFF0C\u964D\u7EA7\u5230\u5907\u7528\u5B58\u50A8"));
|
|
119
|
+
this.isDemoted = true;
|
|
120
|
+
(_this$config$onDemoti = (_this$config3 = this.config).onDemotion) === null || _this$config$onDemoti === void 0 || _this$config$onDemoti.call(_this$config3);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 执行带降级的操作
|
|
126
|
+
*/
|
|
127
|
+
}, {
|
|
128
|
+
key: "executeWithFallback",
|
|
129
|
+
value: (function () {
|
|
130
|
+
var _executeWithFallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(operation, primaryFn, fallbackFn) {
|
|
131
|
+
var _this$config$onError2, _this$config4, result, _this$config$onError3, _this$config5;
|
|
132
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
133
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
134
|
+
case 0:
|
|
135
|
+
if (!(this.isDemoted && fallbackFn)) {
|
|
136
|
+
_context2.next = 12;
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
_context2.prev = 1;
|
|
140
|
+
_context2.next = 4;
|
|
141
|
+
return fallbackFn();
|
|
142
|
+
case 4:
|
|
143
|
+
return _context2.abrupt("return", _context2.sent);
|
|
144
|
+
case 7:
|
|
145
|
+
_context2.prev = 7;
|
|
146
|
+
_context2.t0 = _context2["catch"](1);
|
|
147
|
+
console.error("[PriorityStorageAdapter] \u5907\u7528\u5B58\u50A8".concat(operation, "\u5931\u8D25:"), _context2.t0);
|
|
148
|
+
(_this$config$onError2 = (_this$config4 = this.config).onError) === null || _this$config$onError2 === void 0 || _this$config$onError2.call(_this$config4, _context2.t0, 'fallback');
|
|
149
|
+
throw _context2.t0;
|
|
150
|
+
case 12:
|
|
151
|
+
_context2.prev = 12;
|
|
152
|
+
_context2.next = 15;
|
|
153
|
+
return primaryFn();
|
|
154
|
+
case 15:
|
|
155
|
+
result = _context2.sent;
|
|
156
|
+
// 操作成功,重置失败计数
|
|
157
|
+
this.failureCount = 0;
|
|
158
|
+
return _context2.abrupt("return", result);
|
|
159
|
+
case 20:
|
|
160
|
+
_context2.prev = 20;
|
|
161
|
+
_context2.t1 = _context2["catch"](12);
|
|
162
|
+
this.handlePrimaryError(_context2.t1, operation);
|
|
163
|
+
|
|
164
|
+
// 如果有备用存储,尝试使用备用存储
|
|
165
|
+
if (!fallbackFn) {
|
|
166
|
+
_context2.next = 36;
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
_context2.prev = 24;
|
|
170
|
+
console.log("[PriorityStorageAdapter] \u4F7F\u7528\u5907\u7528\u5B58\u50A8\u6267\u884C".concat(operation));
|
|
171
|
+
_context2.next = 28;
|
|
172
|
+
return fallbackFn();
|
|
173
|
+
case 28:
|
|
174
|
+
return _context2.abrupt("return", _context2.sent);
|
|
175
|
+
case 31:
|
|
176
|
+
_context2.prev = 31;
|
|
177
|
+
_context2.t2 = _context2["catch"](24);
|
|
178
|
+
console.error("[PriorityStorageAdapter] \u5907\u7528\u5B58\u50A8".concat(operation, "\u4E5F\u5931\u8D25:"), _context2.t2);
|
|
179
|
+
(_this$config$onError3 = (_this$config5 = this.config).onError) === null || _this$config$onError3 === void 0 || _this$config$onError3.call(_this$config5, _context2.t2, 'fallback');
|
|
180
|
+
throw _context2.t2;
|
|
181
|
+
case 36:
|
|
182
|
+
throw _context2.t1;
|
|
183
|
+
case 37:
|
|
184
|
+
case "end":
|
|
185
|
+
return _context2.stop();
|
|
186
|
+
}
|
|
187
|
+
}, _callee2, this, [[1, 7], [12, 20], [24, 31]]);
|
|
188
|
+
}));
|
|
189
|
+
function executeWithFallback(_x, _x2, _x3) {
|
|
190
|
+
return _executeWithFallback.apply(this, arguments);
|
|
191
|
+
}
|
|
192
|
+
return executeWithFallback;
|
|
193
|
+
}()
|
|
194
|
+
/**
|
|
195
|
+
* 获取指定表格的所有方案
|
|
196
|
+
*/
|
|
197
|
+
)
|
|
198
|
+
}, {
|
|
199
|
+
key: "getSchemes",
|
|
200
|
+
value: (function () {
|
|
201
|
+
var _getSchemes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(gridId) {
|
|
202
|
+
var _this2 = this;
|
|
203
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
204
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
205
|
+
case 0:
|
|
206
|
+
return _context3.abrupt("return", this.executeWithFallback('获取方案列表', function () {
|
|
207
|
+
return _this2.config.primary.getSchemes(gridId);
|
|
208
|
+
}, this.config.fallback ? function () {
|
|
209
|
+
return _this2.config.fallback.getSchemes(gridId);
|
|
210
|
+
} : undefined));
|
|
211
|
+
case 1:
|
|
212
|
+
case "end":
|
|
213
|
+
return _context3.stop();
|
|
214
|
+
}
|
|
215
|
+
}, _callee3, this);
|
|
216
|
+
}));
|
|
217
|
+
function getSchemes(_x4) {
|
|
218
|
+
return _getSchemes.apply(this, arguments);
|
|
219
|
+
}
|
|
220
|
+
return getSchemes;
|
|
221
|
+
}()
|
|
222
|
+
/**
|
|
223
|
+
* 保存方案列表
|
|
224
|
+
* 只保存到主存储,确保数据一致性
|
|
225
|
+
*/
|
|
226
|
+
)
|
|
227
|
+
}, {
|
|
228
|
+
key: "saveSchemes",
|
|
229
|
+
value: (function () {
|
|
230
|
+
var _saveSchemes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(gridId, schemes) {
|
|
231
|
+
var _this3 = this;
|
|
232
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
233
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
234
|
+
case 0:
|
|
235
|
+
_context5.next = 2;
|
|
236
|
+
return this.executeWithFallback('保存方案列表', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
237
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
238
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
239
|
+
case 0:
|
|
240
|
+
_context4.next = 2;
|
|
241
|
+
return _this3.config.primary.saveSchemes(gridId, schemes);
|
|
242
|
+
case 2:
|
|
243
|
+
if (!(_this3.config.syncToFallback && _this3.config.fallback)) {
|
|
244
|
+
_context4.next = 12;
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
_context4.prev = 3;
|
|
248
|
+
_context4.next = 6;
|
|
249
|
+
return _this3.config.fallback.saveSchemes(gridId, schemes);
|
|
250
|
+
case 6:
|
|
251
|
+
console.log('[PriorityStorageAdapter] 已同步数据到备用存储');
|
|
252
|
+
_context4.next = 12;
|
|
253
|
+
break;
|
|
254
|
+
case 9:
|
|
255
|
+
_context4.prev = 9;
|
|
256
|
+
_context4.t0 = _context4["catch"](3);
|
|
257
|
+
console.warn('[PriorityStorageAdapter] 同步到备用存储失败,忽略该错误:', _context4.t0);
|
|
258
|
+
case 12:
|
|
259
|
+
case "end":
|
|
260
|
+
return _context4.stop();
|
|
261
|
+
}
|
|
262
|
+
}, _callee4, null, [[3, 9]]);
|
|
263
|
+
})), this.config.fallback ? function () {
|
|
264
|
+
return _this3.config.fallback.saveSchemes(gridId, schemes);
|
|
265
|
+
} : undefined);
|
|
266
|
+
case 2:
|
|
267
|
+
case "end":
|
|
268
|
+
return _context5.stop();
|
|
269
|
+
}
|
|
270
|
+
}, _callee5, this);
|
|
271
|
+
}));
|
|
272
|
+
function saveSchemes(_x5, _x6) {
|
|
273
|
+
return _saveSchemes.apply(this, arguments);
|
|
274
|
+
}
|
|
275
|
+
return saveSchemes;
|
|
276
|
+
}()
|
|
277
|
+
/**
|
|
278
|
+
* 清除指定表格的所有方案
|
|
279
|
+
*/
|
|
280
|
+
)
|
|
281
|
+
}, {
|
|
282
|
+
key: "clearSchemes",
|
|
283
|
+
value: (function () {
|
|
284
|
+
var _clearSchemes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(gridId) {
|
|
285
|
+
var _this4 = this,
|
|
286
|
+
_this$config$fallback;
|
|
287
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
288
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
289
|
+
case 0:
|
|
290
|
+
if (this.config.primary.clearSchemes) {
|
|
291
|
+
_context7.next = 2;
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
return _context7.abrupt("return");
|
|
295
|
+
case 2:
|
|
296
|
+
_context7.next = 4;
|
|
297
|
+
return this.executeWithFallback('清除方案', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
298
|
+
var _this4$config$fallbac;
|
|
299
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
300
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
301
|
+
case 0:
|
|
302
|
+
_context6.next = 2;
|
|
303
|
+
return _this4.config.primary.clearSchemes(gridId);
|
|
304
|
+
case 2:
|
|
305
|
+
if (!(_this4.config.syncToFallback && (_this4$config$fallbac = _this4.config.fallback) !== null && _this4$config$fallbac !== void 0 && _this4$config$fallbac.clearSchemes)) {
|
|
306
|
+
_context6.next = 12;
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
_context6.prev = 3;
|
|
310
|
+
_context6.next = 6;
|
|
311
|
+
return _this4.config.fallback.clearSchemes(gridId);
|
|
312
|
+
case 6:
|
|
313
|
+
console.log('[PriorityStorageAdapter] 已同步清除操作到备用存储');
|
|
314
|
+
_context6.next = 12;
|
|
315
|
+
break;
|
|
316
|
+
case 9:
|
|
317
|
+
_context6.prev = 9;
|
|
318
|
+
_context6.t0 = _context6["catch"](3);
|
|
319
|
+
console.warn('[PriorityStorageAdapter] 同步清除操作到备用存储失败,忽略该错误:', _context6.t0);
|
|
320
|
+
case 12:
|
|
321
|
+
case "end":
|
|
322
|
+
return _context6.stop();
|
|
323
|
+
}
|
|
324
|
+
}, _callee6, null, [[3, 9]]);
|
|
325
|
+
})), (_this$config$fallback = this.config.fallback) !== null && _this$config$fallback !== void 0 && _this$config$fallback.clearSchemes ? function () {
|
|
326
|
+
return _this4.config.fallback.clearSchemes(gridId);
|
|
327
|
+
} : undefined);
|
|
328
|
+
case 4:
|
|
329
|
+
case "end":
|
|
330
|
+
return _context7.stop();
|
|
331
|
+
}
|
|
332
|
+
}, _callee7, this);
|
|
333
|
+
}));
|
|
334
|
+
function clearSchemes(_x7) {
|
|
335
|
+
return _clearSchemes.apply(this, arguments);
|
|
336
|
+
}
|
|
337
|
+
return clearSchemes;
|
|
338
|
+
}()
|
|
339
|
+
/**
|
|
340
|
+
* 获取当前激活的方案ID
|
|
341
|
+
*/
|
|
342
|
+
)
|
|
343
|
+
}, {
|
|
344
|
+
key: "getCurrentSchemeId",
|
|
345
|
+
value: (function () {
|
|
346
|
+
var _getCurrentSchemeId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(gridId) {
|
|
347
|
+
var _this5 = this,
|
|
348
|
+
_this$config$fallback2;
|
|
349
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
350
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
351
|
+
case 0:
|
|
352
|
+
if (this.config.primary.getCurrentSchemeId) {
|
|
353
|
+
_context8.next = 2;
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
return _context8.abrupt("return", null);
|
|
357
|
+
case 2:
|
|
358
|
+
return _context8.abrupt("return", this.executeWithFallback('获取当前方案ID', function () {
|
|
359
|
+
return _this5.config.primary.getCurrentSchemeId(gridId);
|
|
360
|
+
}, (_this$config$fallback2 = this.config.fallback) !== null && _this$config$fallback2 !== void 0 && _this$config$fallback2.getCurrentSchemeId ? function () {
|
|
361
|
+
return _this5.config.fallback.getCurrentSchemeId(gridId);
|
|
362
|
+
} : undefined));
|
|
363
|
+
case 3:
|
|
364
|
+
case "end":
|
|
365
|
+
return _context8.stop();
|
|
366
|
+
}
|
|
367
|
+
}, _callee8, this);
|
|
368
|
+
}));
|
|
369
|
+
function getCurrentSchemeId(_x8) {
|
|
370
|
+
return _getCurrentSchemeId.apply(this, arguments);
|
|
371
|
+
}
|
|
372
|
+
return getCurrentSchemeId;
|
|
373
|
+
}()
|
|
374
|
+
/**
|
|
375
|
+
* 保存当前激活的方案ID
|
|
376
|
+
*/
|
|
377
|
+
)
|
|
378
|
+
}, {
|
|
379
|
+
key: "saveCurrentSchemeId",
|
|
380
|
+
value: (function () {
|
|
381
|
+
var _saveCurrentSchemeId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(gridId, schemeId) {
|
|
382
|
+
var _this6 = this,
|
|
383
|
+
_this$config$fallback3;
|
|
384
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
385
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
386
|
+
case 0:
|
|
387
|
+
if (this.config.primary.saveCurrentSchemeId) {
|
|
388
|
+
_context10.next = 2;
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
return _context10.abrupt("return");
|
|
392
|
+
case 2:
|
|
393
|
+
_context10.next = 4;
|
|
394
|
+
return this.executeWithFallback('保存当前方案ID', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
395
|
+
var _this6$config$fallbac;
|
|
396
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
397
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
398
|
+
case 0:
|
|
399
|
+
_context9.next = 2;
|
|
400
|
+
return _this6.config.primary.saveCurrentSchemeId(gridId, schemeId);
|
|
401
|
+
case 2:
|
|
402
|
+
if (!(_this6.config.syncToFallback && (_this6$config$fallbac = _this6.config.fallback) !== null && _this6$config$fallbac !== void 0 && _this6$config$fallbac.saveCurrentSchemeId)) {
|
|
403
|
+
_context9.next = 12;
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
_context9.prev = 3;
|
|
407
|
+
_context9.next = 6;
|
|
408
|
+
return _this6.config.fallback.saveCurrentSchemeId(gridId, schemeId);
|
|
409
|
+
case 6:
|
|
410
|
+
console.log('[PriorityStorageAdapter] 已同步当前方案ID到备用存储');
|
|
411
|
+
_context9.next = 12;
|
|
412
|
+
break;
|
|
413
|
+
case 9:
|
|
414
|
+
_context9.prev = 9;
|
|
415
|
+
_context9.t0 = _context9["catch"](3);
|
|
416
|
+
console.warn('[PriorityStorageAdapter] 同步当前方案ID到备用存储失败,忽略该错误:', _context9.t0);
|
|
417
|
+
case 12:
|
|
418
|
+
case "end":
|
|
419
|
+
return _context9.stop();
|
|
420
|
+
}
|
|
421
|
+
}, _callee9, null, [[3, 9]]);
|
|
422
|
+
})), (_this$config$fallback3 = this.config.fallback) !== null && _this$config$fallback3 !== void 0 && _this$config$fallback3.saveCurrentSchemeId ? function () {
|
|
423
|
+
return _this6.config.fallback.saveCurrentSchemeId(gridId, schemeId);
|
|
424
|
+
} : undefined);
|
|
425
|
+
case 4:
|
|
426
|
+
case "end":
|
|
427
|
+
return _context10.stop();
|
|
428
|
+
}
|
|
429
|
+
}, _callee10, this);
|
|
430
|
+
}));
|
|
431
|
+
function saveCurrentSchemeId(_x9, _x10) {
|
|
432
|
+
return _saveCurrentSchemeId.apply(this, arguments);
|
|
433
|
+
}
|
|
434
|
+
return saveCurrentSchemeId;
|
|
435
|
+
}()
|
|
436
|
+
/**
|
|
437
|
+
* 获取当前存储状态
|
|
438
|
+
*/
|
|
439
|
+
)
|
|
440
|
+
}, {
|
|
441
|
+
key: "getStatus",
|
|
442
|
+
value: function getStatus() {
|
|
443
|
+
return {
|
|
444
|
+
isDemoted: this.isDemoted,
|
|
445
|
+
failureCount: this.failureCount,
|
|
446
|
+
primaryAvailable: !this.isDemoted
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* 手动重置到主存储
|
|
452
|
+
*/
|
|
453
|
+
}, {
|
|
454
|
+
key: "resetToPrimary",
|
|
455
|
+
value: function resetToPrimary() {
|
|
456
|
+
this.isDemoted = false;
|
|
457
|
+
this.failureCount = 0;
|
|
458
|
+
console.log('[PriorityStorageAdapter] 已手动重置到主存储');
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* 清理资源
|
|
463
|
+
*/
|
|
464
|
+
}, {
|
|
465
|
+
key: "dispose",
|
|
466
|
+
value: function dispose() {
|
|
467
|
+
this.stopRecoveryCheck();
|
|
468
|
+
}
|
|
469
|
+
}]);
|
|
470
|
+
return PriorityStorageAdapter;
|
|
471
|
+
}();
|