@nokecy/qc-ui 1.0.93 → 1.0.95
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 +262 -177
- package/dist/cjs/ag-grid-plus/context/gridContext.d.ts +79 -15
- package/dist/cjs/ag-grid-plus/context/gridContext.js +0 -4
- package/dist/cjs/ag-grid-plus/context/useSchemeDataFlow.d.ts +88 -0
- package/dist/cjs/ag-grid-plus/context/useSchemeDataFlow.js +173 -0
- package/dist/cjs/ag-grid-plus/context/useSchemeManager.d.ts +78 -0
- package/dist/cjs/ag-grid-plus/{querySchemes/hooks/useQuerySchemes.js → context/useSchemeManager.js} +421 -449
- package/dist/cjs/ag-grid-plus/hooks/useAgGridCalculation.d.ts +1 -1
- package/dist/cjs/ag-grid-plus/hooks/useAgGridData.d.ts +2 -2
- package/dist/cjs/ag-grid-plus/index.d.ts +7 -4
- package/dist/cjs/ag-grid-plus/index.js +11 -154
- package/dist/cjs/ag-grid-plus/interface.d.ts +0 -31
- package/dist/cjs/ag-grid-plus/interface.js +3 -0
- package/dist/cjs/ag-grid-plus/setting/ColumnSetting.d.ts +0 -3
- package/dist/cjs/ag-grid-plus/setting/ColumnSetting.js +430 -412
- package/dist/cjs/ag-grid-plus/setting/QuerySchemeManager.d.ts +11 -0
- package/dist/cjs/ag-grid-plus/{querySchemes/components/QuerySchemesManager.js → setting/QuerySchemeManager.js} +304 -202
- package/dist/cjs/ag-grid-plus/setting/index.d.ts +2 -2
- package/dist/cjs/ag-grid-plus/setting/index.js +33 -48
- package/dist/cjs/ag-grid-plus/shared/storage/backendApiAdapter.d.ts +58 -0
- package/dist/cjs/ag-grid-plus/shared/storage/backendApiAdapter.js +446 -0
- package/dist/cjs/ag-grid-plus/shared/storage/localStorageAdapter.d.ts +57 -0
- package/dist/cjs/ag-grid-plus/{storage/MemoryStorageAdapter.js → shared/storage/localStorageAdapter.js} +264 -184
- package/dist/cjs/ag-grid-plus/shared/storage/schemeStorageAdapter.d.ts +132 -0
- package/dist/cjs/array-table/index.js +172 -48
- 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 +3 -4
- package/dist/cjs/index.js +16 -160
- package/dist/esm/ag-grid-plus/ag-gridPlus.js +262 -177
- package/dist/esm/ag-grid-plus/context/gridContext.d.ts +79 -15
- package/dist/esm/ag-grid-plus/context/gridContext.js +0 -4
- package/dist/esm/ag-grid-plus/context/useSchemeDataFlow.d.ts +88 -0
- package/dist/esm/ag-grid-plus/context/useSchemeDataFlow.js +165 -0
- package/dist/esm/ag-grid-plus/context/useSchemeManager.d.ts +78 -0
- package/dist/esm/ag-grid-plus/{querySchemes/hooks/useQuerySchemes.js → context/useSchemeManager.js} +420 -449
- package/dist/esm/ag-grid-plus/errors/ErrorBoundary.d.ts +1 -1
- package/dist/esm/ag-grid-plus/hooks/useAgGridCalculation.d.ts +1 -1
- package/dist/esm/ag-grid-plus/hooks/useAgGridData.d.ts +2 -2
- package/dist/esm/ag-grid-plus/index.d.ts +7 -4
- package/dist/esm/ag-grid-plus/index.js +10 -4
- package/dist/esm/ag-grid-plus/interface.d.ts +0 -31
- package/dist/esm/ag-grid-plus/interface.js +2 -0
- package/dist/esm/ag-grid-plus/setting/ColumnSetting.d.ts +0 -3
- package/dist/esm/ag-grid-plus/setting/ColumnSetting.js +434 -416
- package/dist/esm/ag-grid-plus/setting/QuerySchemeManager.d.ts +11 -0
- package/dist/esm/ag-grid-plus/{querySchemes/components/QuerySchemesManager.js → setting/QuerySchemeManager.js} +304 -202
- package/dist/esm/ag-grid-plus/setting/index.d.ts +2 -2
- package/dist/esm/ag-grid-plus/setting/index.js +33 -48
- package/dist/esm/ag-grid-plus/shared/storage/backendApiAdapter.d.ts +58 -0
- package/dist/esm/ag-grid-plus/shared/storage/backendApiAdapter.js +444 -0
- package/dist/esm/ag-grid-plus/shared/storage/localStorageAdapter.d.ts +57 -0
- package/dist/esm/ag-grid-plus/{storage/MemoryStorageAdapter.js → shared/storage/localStorageAdapter.js} +263 -184
- package/dist/esm/ag-grid-plus/shared/storage/schemeStorageAdapter.d.ts +132 -0
- package/dist/esm/array-table/index.js +174 -48
- 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 +3 -4
- package/dist/esm/index.js +13 -10
- 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/querySchemes/components/QuerySchemesManager.d.ts +0 -21
- package/dist/cjs/ag-grid-plus/querySchemes/components/QuerySchemesManager.less +0 -86
- package/dist/cjs/ag-grid-plus/querySchemes/components/index.d.ts +0 -5
- package/dist/cjs/ag-grid-plus/querySchemes/components/index.js +0 -12
- package/dist/cjs/ag-grid-plus/querySchemes/constants.d.ts +0 -17
- package/dist/cjs/ag-grid-plus/querySchemes/constants.js +0 -30
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.d.ts +0 -10
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.js +0 -65
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQuerySchemes.d.ts +0 -6
- package/dist/cjs/ag-grid-plus/querySchemes/index.d.ts +0 -11
- package/dist/cjs/ag-grid-plus/querySchemes/index.js +0 -113
- package/dist/cjs/ag-grid-plus/querySchemes/storage/localStorageAdapter.d.ts +0 -44
- package/dist/cjs/ag-grid-plus/querySchemes/storage/localStorageAdapter.js +0 -261
- package/dist/cjs/ag-grid-plus/querySchemes/types.d.ts +0 -143
- package/dist/cjs/ag-grid-plus/querySchemes/utils/validator.d.ts +0 -36
- package/dist/cjs/ag-grid-plus/querySchemes/utils/validator.js +0 -155
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeManager.d.ts +0 -16
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeManager.js +0 -342
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeManager.less +0 -35
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeSelector.d.ts +0 -20
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeSelector.js +0 -289
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeSelector.less +0 -39
- package/dist/cjs/ag-grid-plus/schemes/components/index.d.ts +0 -4
- package/dist/cjs/ag-grid-plus/schemes/components/index.js +0 -19
- package/dist/cjs/ag-grid-plus/schemes/constants.d.ts +0 -23
- package/dist/cjs/ag-grid-plus/schemes/constants.js +0 -39
- package/dist/cjs/ag-grid-plus/schemes/hooks/useColumnSchemes.d.ts +0 -6
- package/dist/cjs/ag-grid-plus/schemes/hooks/useColumnSchemes.js +0 -617
- package/dist/cjs/ag-grid-plus/schemes/index.d.ts +0 -16
- package/dist/cjs/ag-grid-plus/schemes/index.js +0 -124
- package/dist/cjs/ag-grid-plus/schemes/storage/localStorageAdapter.d.ts +0 -64
- package/dist/cjs/ag-grid-plus/schemes/storage/localStorageAdapter.js +0 -354
- package/dist/cjs/ag-grid-plus/schemes/types.d.ts +0 -131
- package/dist/cjs/ag-grid-plus/schemes/types.js +0 -5
- package/dist/cjs/ag-grid-plus/schemes/utils/validator.d.ts +0 -27
- package/dist/cjs/ag-grid-plus/schemes/utils/validator.js +0 -109
- package/dist/cjs/ag-grid-plus/storage/MemoryStorageAdapter.d.ts +0 -76
- 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/index.d.ts +0 -8
- package/dist/cjs/ag-grid-plus/storage/index.js +0 -49
- 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/querySchemes/components/QuerySchemesManager.d.ts +0 -21
- package/dist/esm/ag-grid-plus/querySchemes/components/QuerySchemesManager.less +0 -86
- package/dist/esm/ag-grid-plus/querySchemes/components/index.d.ts +0 -5
- package/dist/esm/ag-grid-plus/querySchemes/components/index.js +0 -5
- package/dist/esm/ag-grid-plus/querySchemes/constants.d.ts +0 -17
- package/dist/esm/ag-grid-plus/querySchemes/constants.js +0 -24
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.d.ts +0 -10
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.js +0 -60
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQuerySchemes.d.ts +0 -6
- package/dist/esm/ag-grid-plus/querySchemes/index.d.ts +0 -11
- package/dist/esm/ag-grid-plus/querySchemes/index.js +0 -20
- package/dist/esm/ag-grid-plus/querySchemes/storage/localStorageAdapter.d.ts +0 -44
- package/dist/esm/ag-grid-plus/querySchemes/storage/localStorageAdapter.js +0 -256
- package/dist/esm/ag-grid-plus/querySchemes/types.d.ts +0 -143
- package/dist/esm/ag-grid-plus/querySchemes/utils/validator.d.ts +0 -36
- package/dist/esm/ag-grid-plus/querySchemes/utils/validator.js +0 -144
- package/dist/esm/ag-grid-plus/schemes/components/SchemeManager.d.ts +0 -16
- package/dist/esm/ag-grid-plus/schemes/components/SchemeManager.js +0 -334
- package/dist/esm/ag-grid-plus/schemes/components/SchemeManager.less +0 -35
- package/dist/esm/ag-grid-plus/schemes/components/SchemeSelector.d.ts +0 -20
- package/dist/esm/ag-grid-plus/schemes/components/SchemeSelector.js +0 -281
- package/dist/esm/ag-grid-plus/schemes/components/SchemeSelector.less +0 -39
- package/dist/esm/ag-grid-plus/schemes/components/index.d.ts +0 -4
- package/dist/esm/ag-grid-plus/schemes/components/index.js +0 -2
- package/dist/esm/ag-grid-plus/schemes/constants.d.ts +0 -23
- package/dist/esm/ag-grid-plus/schemes/constants.js +0 -33
- package/dist/esm/ag-grid-plus/schemes/hooks/useColumnSchemes.d.ts +0 -6
- package/dist/esm/ag-grid-plus/schemes/hooks/useColumnSchemes.js +0 -612
- package/dist/esm/ag-grid-plus/schemes/index.d.ts +0 -16
- package/dist/esm/ag-grid-plus/schemes/index.js +0 -25
- package/dist/esm/ag-grid-plus/schemes/storage/localStorageAdapter.d.ts +0 -64
- package/dist/esm/ag-grid-plus/schemes/storage/localStorageAdapter.js +0 -349
- package/dist/esm/ag-grid-plus/schemes/types.d.ts +0 -131
- package/dist/esm/ag-grid-plus/schemes/types.js +0 -1
- package/dist/esm/ag-grid-plus/schemes/utils/validator.d.ts +0 -27
- package/dist/esm/ag-grid-plus/schemes/utils/validator.js +0 -100
- package/dist/esm/ag-grid-plus/storage/MemoryStorageAdapter.d.ts +0 -76
- 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/index.d.ts +0 -8
- package/dist/esm/ag-grid-plus/storage/index.js +0 -9
- package/dist/esm/ag-grid-plus/storage/types.d.ts +0 -150
- package/dist/esm/ag-grid-plus/storage/types.js +0 -1
- /package/dist/cjs/ag-grid-plus/{querySchemes/types.js → shared/storage/schemeStorageAdapter.js} +0 -0
- /package/dist/esm/ag-grid-plus/{querySchemes/types.js → shared/storage/schemeStorageAdapter.js} +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { SchemeStorageAdapter, SchemeSyncDataDto, SchemeStorageConfig, ColumnScheme, QueryScheme } from './schemeStorageAdapter';
|
|
2
|
+
/**
|
|
3
|
+
* LocalStorage 适配器配置
|
|
4
|
+
*/
|
|
5
|
+
export interface LocalStorageAdapterConfig extends SchemeStorageConfig {
|
|
6
|
+
/** 存储键名前缀,默认 'ag-grid-plus-schemes' */
|
|
7
|
+
storageKey?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* LocalStorage 方案存储适配器
|
|
11
|
+
*
|
|
12
|
+
* 特点:
|
|
13
|
+
* - 所有数据存储在单个 localStorage key 中
|
|
14
|
+
* - 支持细粒度的 CRUD 操作
|
|
15
|
+
* - 操作立即生效
|
|
16
|
+
* - 适用于离线或无后端场景
|
|
17
|
+
*
|
|
18
|
+
* 数据格式:
|
|
19
|
+
* - 使用扩展的列配置格式 (columnConfig: FlatColumnItem[])
|
|
20
|
+
* - 包含列分组层级结构
|
|
21
|
+
* - 完整保存在 localStorage 中
|
|
22
|
+
*/
|
|
23
|
+
export declare class LocalStorageSchemeAdapter implements SchemeStorageAdapter {
|
|
24
|
+
private readonly STORAGE_KEY;
|
|
25
|
+
private readonly enableDebugLog;
|
|
26
|
+
constructor(config?: LocalStorageAdapterConfig);
|
|
27
|
+
/**
|
|
28
|
+
* 日志输出
|
|
29
|
+
*/
|
|
30
|
+
private log;
|
|
31
|
+
/**
|
|
32
|
+
* 从 localStorage 读取所有数据
|
|
33
|
+
*/
|
|
34
|
+
private readData;
|
|
35
|
+
/**
|
|
36
|
+
* 写入数据到 localStorage
|
|
37
|
+
*/
|
|
38
|
+
private writeData;
|
|
39
|
+
loadAllSchemes(): Promise<SchemeSyncDataDto>;
|
|
40
|
+
saveColumnScheme(gridId: string, scheme: ColumnScheme): Promise<ColumnScheme>;
|
|
41
|
+
deleteColumnScheme(gridId: string, schemeId: string): Promise<void>;
|
|
42
|
+
saveQueryScheme(gridId: string, scheme: QueryScheme): Promise<QueryScheme>;
|
|
43
|
+
deleteQueryScheme(gridId: string, schemeId: string): Promise<void>;
|
|
44
|
+
setCurrentScheme(gridId: string, columnSchemeId: string | null, querySchemeId: string | null): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* 清除所有数据
|
|
47
|
+
*/
|
|
48
|
+
clearAll(): void;
|
|
49
|
+
/**
|
|
50
|
+
* 获取存储大小(字节)
|
|
51
|
+
*/
|
|
52
|
+
getStorageSize(): number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 默认的 LocalStorage 适配器实例
|
|
56
|
+
*/
|
|
57
|
+
export declare const defaultLocalStorageAdapter: LocalStorageSchemeAdapter;
|
|
@@ -1,4 +1,6 @@
|
|
|
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; }
|
|
2
4
|
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
5
|
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
6
|
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); }); }; }
|
|
@@ -9,265 +11,342 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
9
11
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
12
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
13
|
/**
|
|
12
|
-
*
|
|
13
|
-
* 实现 StorageAdapter 接口,数据存储在内存中,通过 SchemeSyncManager 同步到服务器
|
|
14
|
+
* LocalStorage 适配器配置
|
|
14
15
|
*/
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
+
* LocalStorage 方案存储适配器
|
|
19
|
+
*
|
|
20
|
+
* 特点:
|
|
21
|
+
* - 所有数据存储在单个 localStorage key 中
|
|
22
|
+
* - 支持细粒度的 CRUD 操作
|
|
23
|
+
* - 操作立即生效
|
|
24
|
+
* - 适用于离线或无后端场景
|
|
25
|
+
*
|
|
26
|
+
* 数据格式:
|
|
27
|
+
* - 使用扩展的列配置格式 (columnConfig: FlatColumnItem[])
|
|
28
|
+
* - 包含列分组层级结构
|
|
29
|
+
* - 完整保存在 localStorage 中
|
|
18
30
|
*/
|
|
19
|
-
export var
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this
|
|
31
|
+
export var LocalStorageSchemeAdapter = /*#__PURE__*/function () {
|
|
32
|
+
function LocalStorageSchemeAdapter() {
|
|
33
|
+
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
34
|
+
_classCallCheck(this, LocalStorageSchemeAdapter);
|
|
35
|
+
_defineProperty(this, "STORAGE_KEY", void 0);
|
|
36
|
+
_defineProperty(this, "enableDebugLog", void 0);
|
|
37
|
+
this.STORAGE_KEY = config.storageKey || 'ag-grid-plus-schemes';
|
|
38
|
+
this.enableDebugLog = config.enableDebugLog || false;
|
|
24
39
|
}
|
|
25
40
|
|
|
26
41
|
/**
|
|
27
|
-
*
|
|
42
|
+
* 日志输出
|
|
28
43
|
*/
|
|
29
|
-
_createClass(
|
|
30
|
-
key: "
|
|
31
|
-
value:
|
|
32
|
-
|
|
44
|
+
_createClass(LocalStorageSchemeAdapter, [{
|
|
45
|
+
key: "log",
|
|
46
|
+
value: function log(message) {
|
|
47
|
+
if (this.enableDebugLog) {
|
|
48
|
+
var _console;
|
|
49
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
50
|
+
args[_key - 1] = arguments[_key];
|
|
51
|
+
}
|
|
52
|
+
(_console = console).log.apply(_console, ["[LocalStorageAdapter] ".concat(message)].concat(args));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 从 localStorage 读取所有数据
|
|
58
|
+
*/
|
|
59
|
+
}, {
|
|
60
|
+
key: "readData",
|
|
61
|
+
value: function readData() {
|
|
62
|
+
var data = localStorage.getItem(this.STORAGE_KEY);
|
|
63
|
+
if (!data) {
|
|
64
|
+
return {
|
|
65
|
+
columnSchemes: {},
|
|
66
|
+
querySchemes: {},
|
|
67
|
+
currentSchemes: {},
|
|
68
|
+
syncTime: Date.now(),
|
|
69
|
+
version: 1
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
return JSON.parse(data);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.error('[LocalStorageAdapter] 解析数据失败:', error);
|
|
76
|
+
return {
|
|
77
|
+
columnSchemes: {},
|
|
78
|
+
querySchemes: {},
|
|
79
|
+
currentSchemes: {},
|
|
80
|
+
syncTime: Date.now(),
|
|
81
|
+
version: 1
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 写入数据到 localStorage
|
|
88
|
+
*/
|
|
89
|
+
}, {
|
|
90
|
+
key: "writeData",
|
|
91
|
+
value: function writeData(data) {
|
|
92
|
+
data.syncTime = Date.now();
|
|
93
|
+
data.version = (data.version || 0) + 1;
|
|
94
|
+
try {
|
|
95
|
+
localStorage.setItem(this.STORAGE_KEY, JSON.stringify(data));
|
|
96
|
+
this.log('数据已保存', {
|
|
97
|
+
version: data.version
|
|
98
|
+
});
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.error('[LocalStorageAdapter] 保存数据失败:', error);
|
|
101
|
+
throw new Error('LocalStorage 存储失败,可能超出配额限制');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ========== 初始化加载 ==========
|
|
106
|
+
}, {
|
|
107
|
+
key: "loadAllSchemes",
|
|
108
|
+
value: function () {
|
|
109
|
+
var _loadAllSchemes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
110
|
+
var data;
|
|
33
111
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
34
112
|
while (1) switch (_context.prev = _context.next) {
|
|
35
113
|
case 0:
|
|
36
|
-
|
|
37
|
-
|
|
114
|
+
this.log('加载所有方案数据');
|
|
115
|
+
data = this.readData();
|
|
116
|
+
this.log('加载完成', {
|
|
117
|
+
columnSchemes: Object.keys(data.columnSchemes).length,
|
|
118
|
+
querySchemes: Object.keys(data.querySchemes).length
|
|
119
|
+
});
|
|
120
|
+
return _context.abrupt("return", data);
|
|
121
|
+
case 4:
|
|
38
122
|
case "end":
|
|
39
123
|
return _context.stop();
|
|
40
124
|
}
|
|
41
125
|
}, _callee, this);
|
|
42
126
|
}));
|
|
43
|
-
function
|
|
44
|
-
return
|
|
127
|
+
function loadAllSchemes() {
|
|
128
|
+
return _loadAllSchemes.apply(this, arguments);
|
|
45
129
|
}
|
|
46
|
-
return
|
|
47
|
-
}()
|
|
48
|
-
/**
|
|
49
|
-
* 保存方案列表
|
|
50
|
-
*/
|
|
51
|
-
)
|
|
130
|
+
return loadAllSchemes;
|
|
131
|
+
}() // ========== 列方案操作 ==========
|
|
52
132
|
}, {
|
|
53
|
-
key: "
|
|
54
|
-
value:
|
|
55
|
-
var
|
|
133
|
+
key: "saveColumnScheme",
|
|
134
|
+
value: function () {
|
|
135
|
+
var _saveColumnScheme = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(gridId, scheme) {
|
|
136
|
+
var data, index, newScheme;
|
|
56
137
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
57
138
|
while (1) switch (_context2.prev = _context2.next) {
|
|
58
139
|
case 0:
|
|
59
|
-
this.
|
|
60
|
-
|
|
140
|
+
data = this.readData();
|
|
141
|
+
if (!data.columnSchemes[gridId]) {
|
|
142
|
+
data.columnSchemes[gridId] = [];
|
|
143
|
+
}
|
|
144
|
+
index = data.columnSchemes[gridId].findIndex(function (s) {
|
|
145
|
+
return s.id === scheme.id;
|
|
146
|
+
});
|
|
147
|
+
if (index >= 0) {
|
|
148
|
+
// 更新现有方案
|
|
149
|
+
data.columnSchemes[gridId][index] = _objectSpread(_objectSpread({}, scheme), {}, {
|
|
150
|
+
updatedAt: Date.now()
|
|
151
|
+
});
|
|
152
|
+
this.log("\u66F4\u65B0\u5217\u65B9\u6848: ".concat(gridId, " - ").concat(scheme.name));
|
|
153
|
+
} else {
|
|
154
|
+
// 新增方案
|
|
155
|
+
newScheme = _objectSpread(_objectSpread({}, scheme), {}, {
|
|
156
|
+
createdAt: scheme.createdAt || Date.now(),
|
|
157
|
+
updatedAt: Date.now()
|
|
158
|
+
});
|
|
159
|
+
data.columnSchemes[gridId].push(newScheme);
|
|
160
|
+
this.log("\u65B0\u589E\u5217\u65B9\u6848: ".concat(gridId, " - ").concat(scheme.name));
|
|
161
|
+
}
|
|
162
|
+
this.writeData(data);
|
|
163
|
+
return _context2.abrupt("return", data.columnSchemes[gridId][index >= 0 ? index : data.columnSchemes[gridId].length - 1]);
|
|
164
|
+
case 6:
|
|
61
165
|
case "end":
|
|
62
166
|
return _context2.stop();
|
|
63
167
|
}
|
|
64
168
|
}, _callee2, this);
|
|
65
169
|
}));
|
|
66
|
-
function
|
|
67
|
-
return
|
|
170
|
+
function saveColumnScheme(_x, _x2) {
|
|
171
|
+
return _saveColumnScheme.apply(this, arguments);
|
|
68
172
|
}
|
|
69
|
-
return
|
|
173
|
+
return saveColumnScheme;
|
|
70
174
|
}()
|
|
71
|
-
/**
|
|
72
|
-
* 获取当前方案ID
|
|
73
|
-
*/
|
|
74
|
-
)
|
|
75
175
|
}, {
|
|
76
|
-
key: "
|
|
77
|
-
value:
|
|
78
|
-
var
|
|
176
|
+
key: "deleteColumnScheme",
|
|
177
|
+
value: function () {
|
|
178
|
+
var _deleteColumnScheme = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(gridId, schemeId) {
|
|
179
|
+
var data, beforeCount, afterCount, _data$currentSchemes$;
|
|
79
180
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
80
181
|
while (1) switch (_context3.prev = _context3.next) {
|
|
81
182
|
case 0:
|
|
82
|
-
|
|
83
|
-
|
|
183
|
+
data = this.readData();
|
|
184
|
+
if (data.columnSchemes[gridId]) {
|
|
185
|
+
beforeCount = data.columnSchemes[gridId].length;
|
|
186
|
+
data.columnSchemes[gridId] = data.columnSchemes[gridId].filter(function (s) {
|
|
187
|
+
return s.id !== schemeId;
|
|
188
|
+
});
|
|
189
|
+
afterCount = data.columnSchemes[gridId].length;
|
|
190
|
+
if (beforeCount > afterCount) {
|
|
191
|
+
this.log("\u5220\u9664\u5217\u65B9\u6848: ".concat(gridId, " - ").concat(schemeId));
|
|
192
|
+
|
|
193
|
+
// 如果删除的是当前方案,清除当前方案ID
|
|
194
|
+
if (((_data$currentSchemes$ = data.currentSchemes[gridId]) === null || _data$currentSchemes$ === void 0 ? void 0 : _data$currentSchemes$.columnSchemeId) === schemeId) {
|
|
195
|
+
data.currentSchemes[gridId].columnSchemeId = null;
|
|
196
|
+
this.log("\u6E05\u9664\u5F53\u524D\u5217\u65B9\u6848: ".concat(gridId));
|
|
197
|
+
}
|
|
198
|
+
this.writeData(data);
|
|
199
|
+
} else {
|
|
200
|
+
this.log("\u5217\u65B9\u6848\u4E0D\u5B58\u5728: ".concat(gridId, " - ").concat(schemeId));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
case 2:
|
|
84
204
|
case "end":
|
|
85
205
|
return _context3.stop();
|
|
86
206
|
}
|
|
87
207
|
}, _callee3, this);
|
|
88
208
|
}));
|
|
89
|
-
function
|
|
90
|
-
return
|
|
209
|
+
function deleteColumnScheme(_x3, _x4) {
|
|
210
|
+
return _deleteColumnScheme.apply(this, arguments);
|
|
91
211
|
}
|
|
92
|
-
return
|
|
93
|
-
}()
|
|
94
|
-
/**
|
|
95
|
-
* 保存当前方案ID
|
|
96
|
-
*/
|
|
97
|
-
)
|
|
212
|
+
return deleteColumnScheme;
|
|
213
|
+
}() // ========== 查询方案操作 ==========
|
|
98
214
|
}, {
|
|
99
|
-
key: "
|
|
100
|
-
value:
|
|
101
|
-
var
|
|
215
|
+
key: "saveQueryScheme",
|
|
216
|
+
value: function () {
|
|
217
|
+
var _saveQueryScheme = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(gridId, scheme) {
|
|
218
|
+
var data, index, newScheme;
|
|
102
219
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
103
220
|
while (1) switch (_context4.prev = _context4.next) {
|
|
104
221
|
case 0:
|
|
105
|
-
this.
|
|
106
|
-
|
|
222
|
+
data = this.readData();
|
|
223
|
+
if (!data.querySchemes[gridId]) {
|
|
224
|
+
data.querySchemes[gridId] = [];
|
|
225
|
+
}
|
|
226
|
+
index = data.querySchemes[gridId].findIndex(function (s) {
|
|
227
|
+
return s.id === scheme.id;
|
|
228
|
+
});
|
|
229
|
+
if (index >= 0) {
|
|
230
|
+
// 更新现有方案
|
|
231
|
+
data.querySchemes[gridId][index] = _objectSpread(_objectSpread({}, scheme), {}, {
|
|
232
|
+
updatedAt: Date.now()
|
|
233
|
+
});
|
|
234
|
+
this.log("\u66F4\u65B0\u67E5\u8BE2\u65B9\u6848: ".concat(gridId, " - ").concat(scheme.name));
|
|
235
|
+
} else {
|
|
236
|
+
// 新增方案
|
|
237
|
+
newScheme = _objectSpread(_objectSpread({}, scheme), {}, {
|
|
238
|
+
createdAt: scheme.createdAt || Date.now(),
|
|
239
|
+
updatedAt: Date.now()
|
|
240
|
+
});
|
|
241
|
+
data.querySchemes[gridId].push(newScheme);
|
|
242
|
+
this.log("\u65B0\u589E\u67E5\u8BE2\u65B9\u6848: ".concat(gridId, " - ").concat(scheme.name));
|
|
243
|
+
}
|
|
244
|
+
this.writeData(data);
|
|
245
|
+
return _context4.abrupt("return", data.querySchemes[gridId][index >= 0 ? index : data.querySchemes[gridId].length - 1]);
|
|
246
|
+
case 6:
|
|
107
247
|
case "end":
|
|
108
248
|
return _context4.stop();
|
|
109
249
|
}
|
|
110
250
|
}, _callee4, this);
|
|
111
251
|
}));
|
|
112
|
-
function
|
|
113
|
-
return
|
|
252
|
+
function saveQueryScheme(_x5, _x6) {
|
|
253
|
+
return _saveQueryScheme.apply(this, arguments);
|
|
114
254
|
}
|
|
115
|
-
return
|
|
116
|
-
}()
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
* 查询方案内存存储适配器
|
|
123
|
-
*/
|
|
124
|
-
export var QueryMemoryStorageAdapter = /*#__PURE__*/function () {
|
|
125
|
-
function QueryMemoryStorageAdapter(syncManager) {
|
|
126
|
-
_classCallCheck(this, QueryMemoryStorageAdapter);
|
|
127
|
-
_defineProperty(this, "syncManager", void 0);
|
|
128
|
-
this.syncManager = syncManager;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* 获取方案列表
|
|
133
|
-
*/
|
|
134
|
-
_createClass(QueryMemoryStorageAdapter, [{
|
|
135
|
-
key: "getSchemes",
|
|
136
|
-
value: (function () {
|
|
137
|
-
var _getSchemes2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(gridId) {
|
|
255
|
+
return saveQueryScheme;
|
|
256
|
+
}()
|
|
257
|
+
}, {
|
|
258
|
+
key: "deleteQueryScheme",
|
|
259
|
+
value: function () {
|
|
260
|
+
var _deleteQueryScheme = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(gridId, schemeId) {
|
|
261
|
+
var data, beforeCount, afterCount, _data$currentSchemes$2;
|
|
138
262
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
139
263
|
while (1) switch (_context5.prev = _context5.next) {
|
|
140
264
|
case 0:
|
|
141
|
-
|
|
142
|
-
|
|
265
|
+
data = this.readData();
|
|
266
|
+
if (data.querySchemes[gridId]) {
|
|
267
|
+
beforeCount = data.querySchemes[gridId].length;
|
|
268
|
+
data.querySchemes[gridId] = data.querySchemes[gridId].filter(function (s) {
|
|
269
|
+
return s.id !== schemeId;
|
|
270
|
+
});
|
|
271
|
+
afterCount = data.querySchemes[gridId].length;
|
|
272
|
+
if (beforeCount > afterCount) {
|
|
273
|
+
this.log("\u5220\u9664\u67E5\u8BE2\u65B9\u6848: ".concat(gridId, " - ").concat(schemeId));
|
|
274
|
+
|
|
275
|
+
// 如果删除的是当前方案,清除当前方案ID
|
|
276
|
+
if (((_data$currentSchemes$2 = data.currentSchemes[gridId]) === null || _data$currentSchemes$2 === void 0 ? void 0 : _data$currentSchemes$2.querySchemeId) === schemeId) {
|
|
277
|
+
data.currentSchemes[gridId].querySchemeId = null;
|
|
278
|
+
this.log("\u6E05\u9664\u5F53\u524D\u67E5\u8BE2\u65B9\u6848: ".concat(gridId));
|
|
279
|
+
}
|
|
280
|
+
this.writeData(data);
|
|
281
|
+
} else {
|
|
282
|
+
this.log("\u67E5\u8BE2\u65B9\u6848\u4E0D\u5B58\u5728: ".concat(gridId, " - ").concat(schemeId));
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
case 2:
|
|
143
286
|
case "end":
|
|
144
287
|
return _context5.stop();
|
|
145
288
|
}
|
|
146
289
|
}, _callee5, this);
|
|
147
290
|
}));
|
|
148
|
-
function
|
|
149
|
-
return
|
|
291
|
+
function deleteQueryScheme(_x7, _x8) {
|
|
292
|
+
return _deleteQueryScheme.apply(this, arguments);
|
|
150
293
|
}
|
|
151
|
-
return
|
|
152
|
-
}()
|
|
153
|
-
/**
|
|
154
|
-
* 保存方案列表
|
|
155
|
-
*/
|
|
156
|
-
)
|
|
294
|
+
return deleteQueryScheme;
|
|
295
|
+
}() // ========== 当前方案操作 ==========
|
|
157
296
|
}, {
|
|
158
|
-
key: "
|
|
159
|
-
value:
|
|
160
|
-
var
|
|
297
|
+
key: "setCurrentScheme",
|
|
298
|
+
value: function () {
|
|
299
|
+
var _setCurrentScheme = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(gridId, columnSchemeId, querySchemeId) {
|
|
300
|
+
var data;
|
|
161
301
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
162
302
|
while (1) switch (_context6.prev = _context6.next) {
|
|
163
303
|
case 0:
|
|
164
|
-
this.
|
|
165
|
-
|
|
304
|
+
data = this.readData();
|
|
305
|
+
if (!data.currentSchemes[gridId]) {
|
|
306
|
+
data.currentSchemes[gridId] = {};
|
|
307
|
+
}
|
|
308
|
+
data.currentSchemes[gridId].columnSchemeId = columnSchemeId;
|
|
309
|
+
data.currentSchemes[gridId].querySchemeId = querySchemeId;
|
|
310
|
+
this.log("\u8BBE\u7F6E\u5F53\u524D\u65B9\u6848: ".concat(gridId), {
|
|
311
|
+
columnSchemeId: columnSchemeId,
|
|
312
|
+
querySchemeId: querySchemeId
|
|
313
|
+
});
|
|
314
|
+
this.writeData(data);
|
|
315
|
+
case 6:
|
|
166
316
|
case "end":
|
|
167
317
|
return _context6.stop();
|
|
168
318
|
}
|
|
169
319
|
}, _callee6, this);
|
|
170
320
|
}));
|
|
171
|
-
function
|
|
172
|
-
return
|
|
321
|
+
function setCurrentScheme(_x9, _x10, _x11) {
|
|
322
|
+
return _setCurrentScheme.apply(this, arguments);
|
|
173
323
|
}
|
|
174
|
-
return
|
|
175
|
-
}()
|
|
324
|
+
return setCurrentScheme;
|
|
325
|
+
}() // ========== 工具方法 ==========
|
|
176
326
|
/**
|
|
177
|
-
*
|
|
327
|
+
* 清除所有数据
|
|
178
328
|
*/
|
|
179
|
-
)
|
|
180
329
|
}, {
|
|
181
|
-
key: "
|
|
182
|
-
value:
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
return _context7.abrupt("return", this.syncManager.getCurrentSchemeId(gridId, 'query'));
|
|
188
|
-
case 1:
|
|
189
|
-
case "end":
|
|
190
|
-
return _context7.stop();
|
|
191
|
-
}
|
|
192
|
-
}, _callee7, this);
|
|
193
|
-
}));
|
|
194
|
-
function getCurrentSchemeId(_x10) {
|
|
195
|
-
return _getCurrentSchemeId2.apply(this, arguments);
|
|
196
|
-
}
|
|
197
|
-
return getCurrentSchemeId;
|
|
198
|
-
}()
|
|
330
|
+
key: "clearAll",
|
|
331
|
+
value: function clearAll() {
|
|
332
|
+
localStorage.removeItem(this.STORAGE_KEY);
|
|
333
|
+
this.log('已清除所有数据');
|
|
334
|
+
}
|
|
335
|
+
|
|
199
336
|
/**
|
|
200
|
-
*
|
|
337
|
+
* 获取存储大小(字节)
|
|
201
338
|
*/
|
|
202
|
-
)
|
|
203
339
|
}, {
|
|
204
|
-
key: "
|
|
205
|
-
value:
|
|
206
|
-
var
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
case 0:
|
|
210
|
-
this.syncManager.saveCurrentSchemeId(gridId, 'query', schemeId);
|
|
211
|
-
case 1:
|
|
212
|
-
case "end":
|
|
213
|
-
return _context8.stop();
|
|
214
|
-
}
|
|
215
|
-
}, _callee8, this);
|
|
216
|
-
}));
|
|
217
|
-
function saveCurrentSchemeId(_x11, _x12) {
|
|
218
|
-
return _saveCurrentSchemeId2.apply(this, arguments);
|
|
219
|
-
}
|
|
220
|
-
return saveCurrentSchemeId;
|
|
221
|
-
}())
|
|
340
|
+
key: "getStorageSize",
|
|
341
|
+
value: function getStorageSize() {
|
|
342
|
+
var data = localStorage.getItem(this.STORAGE_KEY);
|
|
343
|
+
return data ? new Blob([data]).size : 0;
|
|
344
|
+
}
|
|
222
345
|
}]);
|
|
223
|
-
return
|
|
346
|
+
return LocalStorageSchemeAdapter;
|
|
224
347
|
}();
|
|
225
348
|
|
|
226
349
|
/**
|
|
227
|
-
*
|
|
228
|
-
* 根据方案类型创建对应的内存存储适配器
|
|
350
|
+
* 默认的 LocalStorage 适配器实例
|
|
229
351
|
*/
|
|
230
|
-
export var
|
|
231
|
-
function MemoryStorageAdapterFactory(syncManager) {
|
|
232
|
-
_classCallCheck(this, MemoryStorageAdapterFactory);
|
|
233
|
-
_defineProperty(this, "syncManager", void 0);
|
|
234
|
-
_defineProperty(this, "columnAdapter", void 0);
|
|
235
|
-
_defineProperty(this, "queryAdapter", void 0);
|
|
236
|
-
this.syncManager = syncManager;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* 获取列方案存储适配器
|
|
241
|
-
*/
|
|
242
|
-
_createClass(MemoryStorageAdapterFactory, [{
|
|
243
|
-
key: "getColumnAdapter",
|
|
244
|
-
value: function getColumnAdapter() {
|
|
245
|
-
if (!this.columnAdapter) {
|
|
246
|
-
this.columnAdapter = new ColumnMemoryStorageAdapter(this.syncManager);
|
|
247
|
-
}
|
|
248
|
-
return this.columnAdapter;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* 获取查询方案存储适配器
|
|
253
|
-
*/
|
|
254
|
-
}, {
|
|
255
|
-
key: "getQueryAdapter",
|
|
256
|
-
value: function getQueryAdapter() {
|
|
257
|
-
if (!this.queryAdapter) {
|
|
258
|
-
this.queryAdapter = new QueryMemoryStorageAdapter(this.syncManager);
|
|
259
|
-
}
|
|
260
|
-
return this.queryAdapter;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* 获取同步管理器
|
|
265
|
-
*/
|
|
266
|
-
}, {
|
|
267
|
-
key: "getSyncManager",
|
|
268
|
-
value: function getSyncManager() {
|
|
269
|
-
return this.syncManager;
|
|
270
|
-
}
|
|
271
|
-
}]);
|
|
272
|
-
return MemoryStorageAdapterFactory;
|
|
273
|
-
}();
|
|
352
|
+
export var defaultLocalStorageAdapter = new LocalStorageSchemeAdapter();
|