@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,746 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
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); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.StorageErrorType = exports.StorageError = exports.RemoteStorageAdapter = void 0;
|
|
8
|
+
var _antd = require("antd");
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
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; }
|
|
12
|
+
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); } }
|
|
13
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
14
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
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); } }
|
|
16
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
17
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
18
|
+
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); }
|
|
19
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
20
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
21
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
22
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
23
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
24
|
+
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
25
|
+
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
26
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
27
|
+
function _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf("[native code]") !== -1; } catch (e) { return typeof fn === "function"; } }
|
|
28
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
29
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
30
|
+
/**
|
|
31
|
+
* 存储错误类型
|
|
32
|
+
*/
|
|
33
|
+
var StorageErrorType = exports.StorageErrorType = /*#__PURE__*/function (StorageErrorType) {
|
|
34
|
+
StorageErrorType["NETWORK_ERROR"] = "NETWORK_ERROR";
|
|
35
|
+
StorageErrorType["TIMEOUT"] = "TIMEOUT";
|
|
36
|
+
StorageErrorType["UNAUTHORIZED"] = "UNAUTHORIZED";
|
|
37
|
+
StorageErrorType["NOT_FOUND"] = "NOT_FOUND";
|
|
38
|
+
StorageErrorType["SERVER_ERROR"] = "SERVER_ERROR";
|
|
39
|
+
StorageErrorType["UNKNOWN"] = "UNKNOWN";
|
|
40
|
+
return StorageErrorType;
|
|
41
|
+
}({});
|
|
42
|
+
/**
|
|
43
|
+
* 存储错误类
|
|
44
|
+
*/
|
|
45
|
+
var StorageError = exports.StorageError = /*#__PURE__*/function (_Error) {
|
|
46
|
+
_inherits(StorageError, _Error);
|
|
47
|
+
var _super = _createSuper(StorageError);
|
|
48
|
+
function StorageError(type, message, originalError) {
|
|
49
|
+
var _this;
|
|
50
|
+
_classCallCheck(this, StorageError);
|
|
51
|
+
_this = _super.call(this, message);
|
|
52
|
+
_this.type = type;
|
|
53
|
+
_this.originalError = originalError;
|
|
54
|
+
_this.name = 'StorageError';
|
|
55
|
+
return _this;
|
|
56
|
+
}
|
|
57
|
+
return _createClass(StorageError);
|
|
58
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
59
|
+
/**
|
|
60
|
+
* 远程存储适配器配置
|
|
61
|
+
*/
|
|
62
|
+
/**
|
|
63
|
+
* 缓存数据结构
|
|
64
|
+
*/
|
|
65
|
+
/**
|
|
66
|
+
* 远程存储适配器实现
|
|
67
|
+
* 专门用于远端 API 存储,完全独立于本地存储
|
|
68
|
+
*
|
|
69
|
+
* 特性:
|
|
70
|
+
* - 智能错误处理和重试机制
|
|
71
|
+
* - 请求取消和防重复
|
|
72
|
+
* - 灵活的缓存策略
|
|
73
|
+
* - 统一的 API 路径配置
|
|
74
|
+
*/
|
|
75
|
+
/**
|
|
76
|
+
* 内部配置类型(所有字段必填)
|
|
77
|
+
*/
|
|
78
|
+
var RemoteStorageAdapter = exports.RemoteStorageAdapter = /*#__PURE__*/function () {
|
|
79
|
+
function RemoteStorageAdapter(config) {
|
|
80
|
+
var _config$maxRetries;
|
|
81
|
+
_classCallCheck(this, RemoteStorageAdapter);
|
|
82
|
+
_defineProperty(this, "config", void 0);
|
|
83
|
+
_defineProperty(this, "schemeCache", new Map());
|
|
84
|
+
_defineProperty(this, "currentSchemeCache", new Map());
|
|
85
|
+
_defineProperty(this, "requestControllers", new Map());
|
|
86
|
+
_defineProperty(this, "saveDebouncers", new Map());
|
|
87
|
+
var apiVersion = config.apiVersion || 'v1';
|
|
88
|
+
var apiPrefix = config.apiPrefix || '/api';
|
|
89
|
+
this.config = {
|
|
90
|
+
apiBaseUrl: config.apiBaseUrl,
|
|
91
|
+
getToken: config.getToken || function () {
|
|
92
|
+
return null;
|
|
93
|
+
},
|
|
94
|
+
getUserId: config.getUserId || function () {
|
|
95
|
+
return null;
|
|
96
|
+
},
|
|
97
|
+
apiVersion: apiVersion,
|
|
98
|
+
apiPrefix: apiPrefix,
|
|
99
|
+
getSchemesPath: config.getSchemesPath || "".concat(apiPrefix, "/").concat(apiVersion, "/schemes"),
|
|
100
|
+
saveSchemesPath: config.saveSchemesPath || "".concat(apiPrefix, "/").concat(apiVersion, "/schemes"),
|
|
101
|
+
getCurrentSchemePath: config.getCurrentSchemePath || "".concat(apiPrefix, "/").concat(apiVersion, "/schemes/current"),
|
|
102
|
+
saveCurrentSchemePath: config.saveCurrentSchemePath || "".concat(apiPrefix, "/").concat(apiVersion, "/schemes/current"),
|
|
103
|
+
timeout: config.timeout || 10000,
|
|
104
|
+
maxRetries: (_config$maxRetries = config.maxRetries) !== null && _config$maxRetries !== void 0 ? _config$maxRetries : 3,
|
|
105
|
+
retryDelay: config.retryDelay || 1000,
|
|
106
|
+
enableCache: config.enableCache !== false,
|
|
107
|
+
cacheStrategy: config.cacheStrategy || 'time-based',
|
|
108
|
+
cacheExpiration: config.cacheExpiration || 60000,
|
|
109
|
+
onCacheInvalidate: config.onCacheInvalidate
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* 生成请求头
|
|
115
|
+
*/
|
|
116
|
+
_createClass(RemoteStorageAdapter, [{
|
|
117
|
+
key: "getHeaders",
|
|
118
|
+
value: function getHeaders() {
|
|
119
|
+
var headers = {
|
|
120
|
+
'Content-Type': 'application/json'
|
|
121
|
+
};
|
|
122
|
+
var token = this.config.getToken();
|
|
123
|
+
if (token) {
|
|
124
|
+
headers['Authorization'] = "Bearer ".concat(token);
|
|
125
|
+
}
|
|
126
|
+
return headers;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* 生成包含用户ID的完整 URL
|
|
131
|
+
*/
|
|
132
|
+
}, {
|
|
133
|
+
key: "buildUrl",
|
|
134
|
+
value: function buildUrl(path, gridId) {
|
|
135
|
+
var userId = this.config.getUserId();
|
|
136
|
+
var baseUrl = "".concat(this.config.apiBaseUrl).concat(path);
|
|
137
|
+
var params = new URLSearchParams({
|
|
138
|
+
gridId: gridId
|
|
139
|
+
});
|
|
140
|
+
if (userId) {
|
|
141
|
+
params.append('userId', userId);
|
|
142
|
+
}
|
|
143
|
+
return "".concat(baseUrl, "?").concat(params.toString());
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* 延迟函数
|
|
148
|
+
*/
|
|
149
|
+
}, {
|
|
150
|
+
key: "delay",
|
|
151
|
+
value: function delay(ms) {
|
|
152
|
+
return new Promise(function (resolve) {
|
|
153
|
+
return setTimeout(resolve, ms);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* 判断错误是否可重试
|
|
159
|
+
*/
|
|
160
|
+
}, {
|
|
161
|
+
key: "isRetryable",
|
|
162
|
+
value: function isRetryable(error) {
|
|
163
|
+
// 网络错误、超时、5xx 错误可重试
|
|
164
|
+
if (error instanceof StorageError) {
|
|
165
|
+
return error.type === StorageErrorType.NETWORK_ERROR || error.type === StorageErrorType.TIMEOUT || error.type === StorageErrorType.SERVER_ERROR;
|
|
166
|
+
}
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* 发送 HTTP 请求(带重试机制)
|
|
172
|
+
*/
|
|
173
|
+
}, {
|
|
174
|
+
key: "requestWithRetry",
|
|
175
|
+
value: (function () {
|
|
176
|
+
var _requestWithRetry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url) {
|
|
177
|
+
var options,
|
|
178
|
+
requestKey,
|
|
179
|
+
retries,
|
|
180
|
+
_args = arguments;
|
|
181
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
182
|
+
while (1) switch (_context.prev = _context.next) {
|
|
183
|
+
case 0:
|
|
184
|
+
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
185
|
+
requestKey = _args.length > 2 ? _args[2] : undefined;
|
|
186
|
+
retries = _args.length > 3 && _args[3] !== undefined ? _args[3] : this.config.maxRetries;
|
|
187
|
+
_context.prev = 3;
|
|
188
|
+
_context.next = 6;
|
|
189
|
+
return this.request(url, options, requestKey);
|
|
190
|
+
case 6:
|
|
191
|
+
return _context.abrupt("return", _context.sent);
|
|
192
|
+
case 9:
|
|
193
|
+
_context.prev = 9;
|
|
194
|
+
_context.t0 = _context["catch"](3);
|
|
195
|
+
if (!(retries > 0 && this.isRetryable(_context.t0))) {
|
|
196
|
+
_context.next = 16;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
console.warn("[RemoteStorageAdapter] \u8BF7\u6C42\u5931\u8D25,\u91CD\u8BD5\u4E2D... (\u5269\u4F59 ".concat(retries, " \u6B21)"), _context.t0);
|
|
200
|
+
_context.next = 15;
|
|
201
|
+
return this.delay(this.config.retryDelay);
|
|
202
|
+
case 15:
|
|
203
|
+
return _context.abrupt("return", this.requestWithRetry(url, options, requestKey, retries - 1));
|
|
204
|
+
case 16:
|
|
205
|
+
throw _context.t0;
|
|
206
|
+
case 17:
|
|
207
|
+
case "end":
|
|
208
|
+
return _context.stop();
|
|
209
|
+
}
|
|
210
|
+
}, _callee, this, [[3, 9]]);
|
|
211
|
+
}));
|
|
212
|
+
function requestWithRetry(_x) {
|
|
213
|
+
return _requestWithRetry.apply(this, arguments);
|
|
214
|
+
}
|
|
215
|
+
return requestWithRetry;
|
|
216
|
+
}()
|
|
217
|
+
/**
|
|
218
|
+
* 发送 HTTP 请求(基础实现)
|
|
219
|
+
*/
|
|
220
|
+
)
|
|
221
|
+
}, {
|
|
222
|
+
key: "request",
|
|
223
|
+
value: (function () {
|
|
224
|
+
var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(url) {
|
|
225
|
+
var options,
|
|
226
|
+
requestKey,
|
|
227
|
+
prevController,
|
|
228
|
+
controller,
|
|
229
|
+
timeoutId,
|
|
230
|
+
response,
|
|
231
|
+
errorText,
|
|
232
|
+
_args2 = arguments;
|
|
233
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
234
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
235
|
+
case 0:
|
|
236
|
+
options = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
|
|
237
|
+
requestKey = _args2.length > 2 ? _args2[2] : undefined;
|
|
238
|
+
// 如果有请求键,取消之前的同类请求
|
|
239
|
+
if (requestKey) {
|
|
240
|
+
prevController = this.requestControllers.get(requestKey);
|
|
241
|
+
if (prevController) {
|
|
242
|
+
prevController.abort();
|
|
243
|
+
console.log("[RemoteStorageAdapter] \u53D6\u6D88\u4E4B\u524D\u7684\u8BF7\u6C42: ".concat(requestKey));
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
controller = new AbortController();
|
|
247
|
+
if (requestKey) {
|
|
248
|
+
this.requestControllers.set(requestKey, controller);
|
|
249
|
+
}
|
|
250
|
+
timeoutId = setTimeout(function () {
|
|
251
|
+
return controller.abort();
|
|
252
|
+
}, this.config.timeout);
|
|
253
|
+
_context2.prev = 6;
|
|
254
|
+
_context2.next = 9;
|
|
255
|
+
return fetch(url, _objectSpread(_objectSpread({}, options), {}, {
|
|
256
|
+
headers: this.getHeaders(),
|
|
257
|
+
signal: controller.signal
|
|
258
|
+
}));
|
|
259
|
+
case 9:
|
|
260
|
+
response = _context2.sent;
|
|
261
|
+
clearTimeout(timeoutId);
|
|
262
|
+
|
|
263
|
+
// 根据状态码返回不同错误
|
|
264
|
+
if (response.ok) {
|
|
265
|
+
_context2.next = 22;
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
_context2.next = 14;
|
|
269
|
+
return response.text();
|
|
270
|
+
case 14:
|
|
271
|
+
errorText = _context2.sent;
|
|
272
|
+
if (!(response.status === 401 || response.status === 403)) {
|
|
273
|
+
_context2.next = 17;
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
throw new StorageError(StorageErrorType.UNAUTHORIZED, '认证失败,请重新登录');
|
|
277
|
+
case 17:
|
|
278
|
+
if (!(response.status === 404)) {
|
|
279
|
+
_context2.next = 19;
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
throw new StorageError(StorageErrorType.NOT_FOUND, '请求的资源不存在');
|
|
283
|
+
case 19:
|
|
284
|
+
if (!(response.status >= 500)) {
|
|
285
|
+
_context2.next = 21;
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
throw new StorageError(StorageErrorType.SERVER_ERROR, '服务器错误,请稍后重试');
|
|
289
|
+
case 21:
|
|
290
|
+
throw new StorageError(StorageErrorType.UNKNOWN, "\u8BF7\u6C42\u5931\u8D25 (".concat(response.status, "): ").concat(errorText));
|
|
291
|
+
case 22:
|
|
292
|
+
_context2.next = 24;
|
|
293
|
+
return response.json();
|
|
294
|
+
case 24:
|
|
295
|
+
return _context2.abrupt("return", _context2.sent);
|
|
296
|
+
case 27:
|
|
297
|
+
_context2.prev = 27;
|
|
298
|
+
_context2.t0 = _context2["catch"](6);
|
|
299
|
+
clearTimeout(timeoutId);
|
|
300
|
+
if (!(_context2.t0 instanceof StorageError)) {
|
|
301
|
+
_context2.next = 32;
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
throw _context2.t0;
|
|
305
|
+
case 32:
|
|
306
|
+
if (!(_context2.t0 instanceof Error && _context2.t0.name === 'AbortError')) {
|
|
307
|
+
_context2.next = 35;
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
if (requestKey) {
|
|
311
|
+
console.log("[RemoteStorageAdapter] \u8BF7\u6C42\u5DF2\u53D6\u6D88: ".concat(requestKey));
|
|
312
|
+
}
|
|
313
|
+
throw new StorageError(StorageErrorType.TIMEOUT, '请求超时,请检查网络连接', _context2.t0);
|
|
314
|
+
case 35:
|
|
315
|
+
throw new StorageError(StorageErrorType.NETWORK_ERROR, '网络错误,请检查网络连接', _context2.t0);
|
|
316
|
+
case 36:
|
|
317
|
+
_context2.prev = 36;
|
|
318
|
+
if (requestKey) {
|
|
319
|
+
this.requestControllers.delete(requestKey);
|
|
320
|
+
}
|
|
321
|
+
return _context2.finish(36);
|
|
322
|
+
case 39:
|
|
323
|
+
case "end":
|
|
324
|
+
return _context2.stop();
|
|
325
|
+
}
|
|
326
|
+
}, _callee2, this, [[6, 27, 36, 39]]);
|
|
327
|
+
}));
|
|
328
|
+
function request(_x2) {
|
|
329
|
+
return _request.apply(this, arguments);
|
|
330
|
+
}
|
|
331
|
+
return request;
|
|
332
|
+
}()
|
|
333
|
+
/**
|
|
334
|
+
* 检查缓存是否有效
|
|
335
|
+
*/
|
|
336
|
+
)
|
|
337
|
+
}, {
|
|
338
|
+
key: "isCacheValid",
|
|
339
|
+
value: function isCacheValid(cache) {
|
|
340
|
+
if (!this.config.enableCache || !cache) {
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
if (this.config.cacheStrategy === 'none') {
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
if (this.config.cacheStrategy === 'forever') {
|
|
347
|
+
return true;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// time-based 策略
|
|
351
|
+
return Date.now() - cache.timestamp < this.config.cacheExpiration;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* 智能缓存失效
|
|
356
|
+
*/
|
|
357
|
+
}, {
|
|
358
|
+
key: "invalidateCache",
|
|
359
|
+
value: function invalidateCache(gridId, reason) {
|
|
360
|
+
var hadCache = this.schemeCache.has(gridId) || this.currentSchemeCache.has(gridId);
|
|
361
|
+
this.schemeCache.delete(gridId);
|
|
362
|
+
this.currentSchemeCache.delete(gridId);
|
|
363
|
+
if (hadCache) {
|
|
364
|
+
var _this$config$onCacheI, _this$config;
|
|
365
|
+
console.log("[RemoteStorageAdapter] \u7F13\u5B58\u5DF2\u5931\u6548: ".concat(gridId, " (\u539F\u56E0: ").concat(reason, ")"));
|
|
366
|
+
(_this$config$onCacheI = (_this$config = this.config).onCacheInvalidate) === null || _this$config$onCacheI === void 0 || _this$config$onCacheI.call(_this$config, gridId);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* 获取指定表格的所有方案
|
|
372
|
+
*/
|
|
373
|
+
}, {
|
|
374
|
+
key: "getSchemes",
|
|
375
|
+
value: (function () {
|
|
376
|
+
var _getSchemes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(gridId) {
|
|
377
|
+
var cached, url, requestKey, response, schemes;
|
|
378
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
379
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
380
|
+
case 0:
|
|
381
|
+
_context3.prev = 0;
|
|
382
|
+
// 检查缓存
|
|
383
|
+
cached = this.schemeCache.get(gridId);
|
|
384
|
+
if (!this.isCacheValid(cached)) {
|
|
385
|
+
_context3.next = 5;
|
|
386
|
+
break;
|
|
387
|
+
}
|
|
388
|
+
console.log("[RemoteStorageAdapter] \u4F7F\u7528\u7F13\u5B58\u7684\u65B9\u6848\u5217\u8868: ".concat(gridId));
|
|
389
|
+
return _context3.abrupt("return", cached.data);
|
|
390
|
+
case 5:
|
|
391
|
+
// 从远端获取
|
|
392
|
+
url = this.buildUrl(this.config.getSchemesPath, gridId);
|
|
393
|
+
requestKey = "getSchemes-".concat(gridId);
|
|
394
|
+
_context3.next = 9;
|
|
395
|
+
return this.requestWithRetry(url, {}, requestKey);
|
|
396
|
+
case 9:
|
|
397
|
+
response = _context3.sent;
|
|
398
|
+
schemes = response.schemes || []; // 更新缓存
|
|
399
|
+
if (this.config.enableCache) {
|
|
400
|
+
this.schemeCache.set(gridId, {
|
|
401
|
+
data: schemes,
|
|
402
|
+
timestamp: Date.now()
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
console.log("[RemoteStorageAdapter] \u4ECE\u8FDC\u7AEF\u52A0\u8F7D\u65B9\u6848\u5217\u8868: ".concat(gridId, ", \u6570\u91CF: ").concat(schemes.length));
|
|
406
|
+
return _context3.abrupt("return", schemes);
|
|
407
|
+
case 16:
|
|
408
|
+
_context3.prev = 16;
|
|
409
|
+
_context3.t0 = _context3["catch"](0);
|
|
410
|
+
console.error('[RemoteStorageAdapter] 加载方案失败:', _context3.t0);
|
|
411
|
+
if (!(_context3.t0 instanceof StorageError)) {
|
|
412
|
+
_context3.next = 32;
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
415
|
+
_context3.t1 = _context3.t0.type;
|
|
416
|
+
_context3.next = _context3.t1 === StorageErrorType.UNAUTHORIZED ? 23 : _context3.t1 === StorageErrorType.TIMEOUT ? 25 : _context3.t1 === StorageErrorType.SERVER_ERROR ? 27 : 29;
|
|
417
|
+
break;
|
|
418
|
+
case 23:
|
|
419
|
+
_antd.message.error('登录已过期,请重新登录');
|
|
420
|
+
return _context3.abrupt("break", 30);
|
|
421
|
+
case 25:
|
|
422
|
+
_antd.message.error('请求超时,请检查网络连接');
|
|
423
|
+
return _context3.abrupt("break", 30);
|
|
424
|
+
case 27:
|
|
425
|
+
_antd.message.error('服务器错误,请稍后重试');
|
|
426
|
+
return _context3.abrupt("break", 30);
|
|
427
|
+
case 29:
|
|
428
|
+
_antd.message.error('加载远端方案失败');
|
|
429
|
+
case 30:
|
|
430
|
+
_context3.next = 33;
|
|
431
|
+
break;
|
|
432
|
+
case 32:
|
|
433
|
+
_antd.message.error('加载远端方案失败,请检查网络连接');
|
|
434
|
+
case 33:
|
|
435
|
+
throw _context3.t0;
|
|
436
|
+
case 34:
|
|
437
|
+
case "end":
|
|
438
|
+
return _context3.stop();
|
|
439
|
+
}
|
|
440
|
+
}, _callee3, this, [[0, 16]]);
|
|
441
|
+
}));
|
|
442
|
+
function getSchemes(_x3) {
|
|
443
|
+
return _getSchemes.apply(this, arguments);
|
|
444
|
+
}
|
|
445
|
+
return getSchemes;
|
|
446
|
+
}()
|
|
447
|
+
/**
|
|
448
|
+
* 保存方案列表到远端
|
|
449
|
+
*/
|
|
450
|
+
)
|
|
451
|
+
}, {
|
|
452
|
+
key: "saveSchemes",
|
|
453
|
+
value: (function () {
|
|
454
|
+
var _saveSchemes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(gridId, schemes) {
|
|
455
|
+
var url, requestKey;
|
|
456
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
457
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
458
|
+
case 0:
|
|
459
|
+
_context4.prev = 0;
|
|
460
|
+
url = this.buildUrl(this.config.saveSchemesPath, gridId);
|
|
461
|
+
requestKey = "saveSchemes-".concat(gridId);
|
|
462
|
+
_context4.next = 5;
|
|
463
|
+
return this.requestWithRetry(url, {
|
|
464
|
+
method: 'POST',
|
|
465
|
+
body: JSON.stringify({
|
|
466
|
+
schemes: schemes
|
|
467
|
+
})
|
|
468
|
+
}, requestKey);
|
|
469
|
+
case 5:
|
|
470
|
+
// ✅ 保存成功后,立即更新缓存(而不是等下次请求)
|
|
471
|
+
if (this.config.enableCache) {
|
|
472
|
+
this.schemeCache.set(gridId, {
|
|
473
|
+
data: schemes,
|
|
474
|
+
timestamp: Date.now()
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
console.log("[RemoteStorageAdapter] \u4FDD\u5B58\u65B9\u6848\u5230\u8FDC\u7AEF\u6210\u529F: ".concat(gridId, ", \u6570\u91CF: ").concat(schemes.length));
|
|
478
|
+
_context4.next = 28;
|
|
479
|
+
break;
|
|
480
|
+
case 9:
|
|
481
|
+
_context4.prev = 9;
|
|
482
|
+
_context4.t0 = _context4["catch"](0);
|
|
483
|
+
console.error('[RemoteStorageAdapter] 保存方案失败:', _context4.t0);
|
|
484
|
+
|
|
485
|
+
// ❌ 保存失败,缓存可能已过期,失效缓存
|
|
486
|
+
this.invalidateCache(gridId, '保存失败');
|
|
487
|
+
if (!(_context4.t0 instanceof StorageError)) {
|
|
488
|
+
_context4.next = 26;
|
|
489
|
+
break;
|
|
490
|
+
}
|
|
491
|
+
_context4.t1 = _context4.t0.type;
|
|
492
|
+
_context4.next = _context4.t1 === StorageErrorType.UNAUTHORIZED ? 17 : _context4.t1 === StorageErrorType.TIMEOUT ? 19 : _context4.t1 === StorageErrorType.SERVER_ERROR ? 21 : 23;
|
|
493
|
+
break;
|
|
494
|
+
case 17:
|
|
495
|
+
_antd.message.error('登录已过期,请重新登录');
|
|
496
|
+
return _context4.abrupt("break", 24);
|
|
497
|
+
case 19:
|
|
498
|
+
_antd.message.error('保存超时,请检查网络连接');
|
|
499
|
+
return _context4.abrupt("break", 24);
|
|
500
|
+
case 21:
|
|
501
|
+
_antd.message.error('服务器错误,请稍后重试');
|
|
502
|
+
return _context4.abrupt("break", 24);
|
|
503
|
+
case 23:
|
|
504
|
+
_antd.message.error('保存方案到远端失败');
|
|
505
|
+
case 24:
|
|
506
|
+
_context4.next = 27;
|
|
507
|
+
break;
|
|
508
|
+
case 26:
|
|
509
|
+
_antd.message.error('保存方案到远端失败');
|
|
510
|
+
case 27:
|
|
511
|
+
throw _context4.t0;
|
|
512
|
+
case 28:
|
|
513
|
+
case "end":
|
|
514
|
+
return _context4.stop();
|
|
515
|
+
}
|
|
516
|
+
}, _callee4, this, [[0, 9]]);
|
|
517
|
+
}));
|
|
518
|
+
function saveSchemes(_x4, _x5) {
|
|
519
|
+
return _saveSchemes.apply(this, arguments);
|
|
520
|
+
}
|
|
521
|
+
return saveSchemes;
|
|
522
|
+
}()
|
|
523
|
+
/**
|
|
524
|
+
* 清除指定表格的所有方案
|
|
525
|
+
*/
|
|
526
|
+
)
|
|
527
|
+
}, {
|
|
528
|
+
key: "clearSchemes",
|
|
529
|
+
value: (function () {
|
|
530
|
+
var _clearSchemes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(gridId) {
|
|
531
|
+
var url, requestKey;
|
|
532
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
533
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
534
|
+
case 0:
|
|
535
|
+
_context5.prev = 0;
|
|
536
|
+
url = this.buildUrl(this.config.saveSchemesPath, gridId);
|
|
537
|
+
requestKey = "clearSchemes-".concat(gridId);
|
|
538
|
+
_context5.next = 5;
|
|
539
|
+
return this.requestWithRetry(url, {
|
|
540
|
+
method: 'DELETE'
|
|
541
|
+
}, requestKey);
|
|
542
|
+
case 5:
|
|
543
|
+
// 清除缓存
|
|
544
|
+
this.invalidateCache(gridId, '方案已清除');
|
|
545
|
+
console.log("[RemoteStorageAdapter] \u6E05\u9664\u65B9\u6848\u6210\u529F: ".concat(gridId));
|
|
546
|
+
_context5.next = 27;
|
|
547
|
+
break;
|
|
548
|
+
case 9:
|
|
549
|
+
_context5.prev = 9;
|
|
550
|
+
_context5.t0 = _context5["catch"](0);
|
|
551
|
+
console.error('[RemoteStorageAdapter] 清除方案失败:', _context5.t0);
|
|
552
|
+
if (!(_context5.t0 instanceof StorageError)) {
|
|
553
|
+
_context5.next = 25;
|
|
554
|
+
break;
|
|
555
|
+
}
|
|
556
|
+
_context5.t1 = _context5.t0.type;
|
|
557
|
+
_context5.next = _context5.t1 === StorageErrorType.UNAUTHORIZED ? 16 : _context5.t1 === StorageErrorType.TIMEOUT ? 18 : _context5.t1 === StorageErrorType.SERVER_ERROR ? 20 : 22;
|
|
558
|
+
break;
|
|
559
|
+
case 16:
|
|
560
|
+
_antd.message.error('登录已过期,请重新登录');
|
|
561
|
+
return _context5.abrupt("break", 23);
|
|
562
|
+
case 18:
|
|
563
|
+
_antd.message.error('清除超时,请检查网络连接');
|
|
564
|
+
return _context5.abrupt("break", 23);
|
|
565
|
+
case 20:
|
|
566
|
+
_antd.message.error('服务器错误,请稍后重试');
|
|
567
|
+
return _context5.abrupt("break", 23);
|
|
568
|
+
case 22:
|
|
569
|
+
_antd.message.error('清除方案失败');
|
|
570
|
+
case 23:
|
|
571
|
+
_context5.next = 26;
|
|
572
|
+
break;
|
|
573
|
+
case 25:
|
|
574
|
+
_antd.message.error('清除方案失败');
|
|
575
|
+
case 26:
|
|
576
|
+
throw _context5.t0;
|
|
577
|
+
case 27:
|
|
578
|
+
case "end":
|
|
579
|
+
return _context5.stop();
|
|
580
|
+
}
|
|
581
|
+
}, _callee5, this, [[0, 9]]);
|
|
582
|
+
}));
|
|
583
|
+
function clearSchemes(_x6) {
|
|
584
|
+
return _clearSchemes.apply(this, arguments);
|
|
585
|
+
}
|
|
586
|
+
return clearSchemes;
|
|
587
|
+
}()
|
|
588
|
+
/**
|
|
589
|
+
* 获取当前激活的方案ID
|
|
590
|
+
*/
|
|
591
|
+
)
|
|
592
|
+
}, {
|
|
593
|
+
key: "getCurrentSchemeId",
|
|
594
|
+
value: (function () {
|
|
595
|
+
var _getCurrentSchemeId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(gridId) {
|
|
596
|
+
var cached, url, requestKey, response, schemeId;
|
|
597
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
598
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
599
|
+
case 0:
|
|
600
|
+
_context6.prev = 0;
|
|
601
|
+
// 检查缓存
|
|
602
|
+
cached = this.currentSchemeCache.get(gridId);
|
|
603
|
+
if (!this.isCacheValid(cached)) {
|
|
604
|
+
_context6.next = 4;
|
|
605
|
+
break;
|
|
606
|
+
}
|
|
607
|
+
return _context6.abrupt("return", cached.data);
|
|
608
|
+
case 4:
|
|
609
|
+
// 从远端获取
|
|
610
|
+
url = this.buildUrl(this.config.getCurrentSchemePath, gridId);
|
|
611
|
+
requestKey = "getCurrentSchemeId-".concat(gridId);
|
|
612
|
+
_context6.next = 8;
|
|
613
|
+
return this.requestWithRetry(url, {}, requestKey);
|
|
614
|
+
case 8:
|
|
615
|
+
response = _context6.sent;
|
|
616
|
+
schemeId = response.schemeId || null; // 更新缓存
|
|
617
|
+
if (this.config.enableCache) {
|
|
618
|
+
this.currentSchemeCache.set(gridId, {
|
|
619
|
+
data: schemeId,
|
|
620
|
+
timestamp: Date.now()
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
return _context6.abrupt("return", schemeId);
|
|
624
|
+
case 14:
|
|
625
|
+
_context6.prev = 14;
|
|
626
|
+
_context6.t0 = _context6["catch"](0);
|
|
627
|
+
console.error('[RemoteStorageAdapter] 获取当前方案ID失败:', _context6.t0);
|
|
628
|
+
return _context6.abrupt("return", null);
|
|
629
|
+
case 18:
|
|
630
|
+
case "end":
|
|
631
|
+
return _context6.stop();
|
|
632
|
+
}
|
|
633
|
+
}, _callee6, this, [[0, 14]]);
|
|
634
|
+
}));
|
|
635
|
+
function getCurrentSchemeId(_x7) {
|
|
636
|
+
return _getCurrentSchemeId.apply(this, arguments);
|
|
637
|
+
}
|
|
638
|
+
return getCurrentSchemeId;
|
|
639
|
+
}()
|
|
640
|
+
/**
|
|
641
|
+
* 保存当前激活的方案ID
|
|
642
|
+
*/
|
|
643
|
+
)
|
|
644
|
+
}, {
|
|
645
|
+
key: "saveCurrentSchemeId",
|
|
646
|
+
value: (function () {
|
|
647
|
+
var _saveCurrentSchemeId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(gridId, schemeId) {
|
|
648
|
+
var url, requestKey;
|
|
649
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
650
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
651
|
+
case 0:
|
|
652
|
+
_context7.prev = 0;
|
|
653
|
+
url = this.buildUrl(this.config.saveCurrentSchemePath, gridId);
|
|
654
|
+
requestKey = "saveCurrentSchemeId-".concat(gridId);
|
|
655
|
+
_context7.next = 5;
|
|
656
|
+
return this.requestWithRetry(url, {
|
|
657
|
+
method: 'POST',
|
|
658
|
+
body: JSON.stringify({
|
|
659
|
+
schemeId: schemeId
|
|
660
|
+
})
|
|
661
|
+
}, requestKey);
|
|
662
|
+
case 5:
|
|
663
|
+
// 更新缓存
|
|
664
|
+
if (this.config.enableCache) {
|
|
665
|
+
this.currentSchemeCache.set(gridId, {
|
|
666
|
+
data: schemeId,
|
|
667
|
+
timestamp: Date.now()
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
console.log("[RemoteStorageAdapter] \u4FDD\u5B58\u5F53\u524D\u65B9\u6848ID\u6210\u529F: ".concat(gridId, ", schemeId: ").concat(schemeId));
|
|
671
|
+
_context7.next = 13;
|
|
672
|
+
break;
|
|
673
|
+
case 9:
|
|
674
|
+
_context7.prev = 9;
|
|
675
|
+
_context7.t0 = _context7["catch"](0);
|
|
676
|
+
console.error('[RemoteStorageAdapter] 保存当前方案ID失败:', _context7.t0);
|
|
677
|
+
throw _context7.t0;
|
|
678
|
+
case 13:
|
|
679
|
+
case "end":
|
|
680
|
+
return _context7.stop();
|
|
681
|
+
}
|
|
682
|
+
}, _callee7, this, [[0, 9]]);
|
|
683
|
+
}));
|
|
684
|
+
function saveCurrentSchemeId(_x8, _x9) {
|
|
685
|
+
return _saveCurrentSchemeId.apply(this, arguments);
|
|
686
|
+
}
|
|
687
|
+
return saveCurrentSchemeId;
|
|
688
|
+
}()
|
|
689
|
+
/**
|
|
690
|
+
* 批量使缓存失效(例如用户登出时)
|
|
691
|
+
*/
|
|
692
|
+
)
|
|
693
|
+
}, {
|
|
694
|
+
key: "invalidateAllCache",
|
|
695
|
+
value: function invalidateAllCache() {
|
|
696
|
+
var _this2 = this;
|
|
697
|
+
var reason = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '手动失效';
|
|
698
|
+
var gridIds = Array.from(this.schemeCache.keys());
|
|
699
|
+
gridIds.forEach(function (gridId) {
|
|
700
|
+
_this2.invalidateCache(gridId, reason);
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* 清除所有缓存
|
|
706
|
+
*/
|
|
707
|
+
}, {
|
|
708
|
+
key: "clearCache",
|
|
709
|
+
value: function clearCache() {
|
|
710
|
+
this.invalidateAllCache('清除所有缓存');
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* 清除指定 gridId 的缓存
|
|
715
|
+
*/
|
|
716
|
+
}, {
|
|
717
|
+
key: "clearCacheForGrid",
|
|
718
|
+
value: function clearCacheForGrid(gridId) {
|
|
719
|
+
this.invalidateCache(gridId, '手动清除');
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* 清理资源
|
|
724
|
+
*/
|
|
725
|
+
}, {
|
|
726
|
+
key: "dispose",
|
|
727
|
+
value: function dispose() {
|
|
728
|
+
// 取消所有进行中的请求
|
|
729
|
+
this.requestControllers.forEach(function (controller) {
|
|
730
|
+
return controller.abort();
|
|
731
|
+
});
|
|
732
|
+
this.requestControllers.clear();
|
|
733
|
+
|
|
734
|
+
// 清除所有防抖定时器
|
|
735
|
+
this.saveDebouncers.forEach(function (timer) {
|
|
736
|
+
return clearTimeout(timer);
|
|
737
|
+
});
|
|
738
|
+
this.saveDebouncers.clear();
|
|
739
|
+
|
|
740
|
+
// 清除缓存
|
|
741
|
+
this.clearCache();
|
|
742
|
+
console.log('[RemoteStorageAdapter] 资源已清理');
|
|
743
|
+
}
|
|
744
|
+
}]);
|
|
745
|
+
return RemoteStorageAdapter;
|
|
746
|
+
}();
|