@nokecy/qc-ui 1.0.69 → 1.0.71
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 +394 -206
- package/dist/cjs/ag-grid-plus/context/gridContext.d.ts +30 -5
- package/dist/cjs/ag-grid-plus/context/gridContext.js +6 -1
- package/dist/cjs/ag-grid-plus/errors/ErrorBoundary.d.ts +36 -0
- package/dist/cjs/ag-grid-plus/errors/ErrorBoundary.js +143 -0
- package/dist/cjs/ag-grid-plus/errors/index.d.ts +3 -0
- package/dist/cjs/ag-grid-plus/errors/index.js +31 -0
- package/dist/cjs/ag-grid-plus/errors/types.d.ts +71 -0
- package/dist/cjs/ag-grid-plus/errors/types.js +137 -0
- package/dist/cjs/ag-grid-plus/hooks/index.d.ts +7 -0
- package/dist/cjs/ag-grid-plus/hooks/index.js +51 -0
- package/dist/cjs/ag-grid-plus/hooks/useAgGridCalculation.d.ts +88 -0
- package/dist/cjs/ag-grid-plus/hooks/useAgGridCalculation.js +224 -0
- package/dist/cjs/ag-grid-plus/hooks/useAgGridData.d.ts +91 -0
- package/dist/cjs/ag-grid-plus/hooks/useAgGridData.js +230 -0
- package/dist/cjs/ag-grid-plus/hooks/useGridPlusColumnState.d.ts +1 -8
- package/dist/cjs/ag-grid-plus/hooks/useGridState.d.ts +153 -0
- package/dist/cjs/ag-grid-plus/hooks/useGridState.js +258 -0
- package/dist/cjs/ag-grid-plus/index.d.ts +3 -0
- package/dist/cjs/ag-grid-plus/index.js +85 -0
- package/dist/cjs/ag-grid-plus/interface.d.ts +27 -0
- package/dist/cjs/ag-grid-plus/queryForm/index.js +18 -7
- package/dist/cjs/ag-grid-plus/queryForm/index.less +24 -0
- package/dist/cjs/ag-grid-plus/querySchemes/components/QuerySchemesManager.d.ts +21 -0
- package/dist/cjs/ag-grid-plus/querySchemes/components/QuerySchemesManager.js +580 -0
- package/dist/cjs/ag-grid-plus/querySchemes/components/QuerySchemesManager.less +86 -0
- package/dist/cjs/ag-grid-plus/querySchemes/components/index.d.ts +5 -0
- package/dist/cjs/ag-grid-plus/querySchemes/components/index.js +12 -0
- package/dist/cjs/ag-grid-plus/querySchemes/constants.d.ts +17 -0
- package/dist/cjs/ag-grid-plus/querySchemes/constants.js +30 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.d.ts +10 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.js +65 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQuerySchemes.d.ts +6 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQuerySchemes.js +542 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQuerySchemes.refactored.d.ts +7 -0
- package/dist/cjs/ag-grid-plus/querySchemes/hooks/useQuerySchemes.refactored.js +32 -0
- package/dist/cjs/ag-grid-plus/querySchemes/index.d.ts +11 -0
- package/dist/cjs/ag-grid-plus/querySchemes/index.js +113 -0
- package/dist/cjs/ag-grid-plus/querySchemes/storage/localStorageAdapter.d.ts +44 -0
- package/dist/cjs/ag-grid-plus/querySchemes/storage/localStorageAdapter.js +261 -0
- package/dist/cjs/ag-grid-plus/querySchemes/types.d.ts +143 -0
- package/dist/cjs/ag-grid-plus/querySchemes/types.js +5 -0
- package/dist/cjs/ag-grid-plus/querySchemes/utils/validator.d.ts +36 -0
- package/dist/cjs/ag-grid-plus/querySchemes/utils/validator.js +155 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeManager.d.ts +16 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeManager.js +342 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeManager.less +35 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeSelector.d.ts +20 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeSelector.js +289 -0
- package/dist/cjs/ag-grid-plus/schemes/components/SchemeSelector.less +39 -0
- package/dist/cjs/ag-grid-plus/schemes/components/index.d.ts +4 -0
- package/dist/cjs/ag-grid-plus/schemes/components/index.js +19 -0
- package/dist/cjs/ag-grid-plus/schemes/constants.d.ts +23 -0
- package/dist/cjs/ag-grid-plus/schemes/constants.js +39 -0
- package/dist/cjs/ag-grid-plus/schemes/hooks/useColumnSchemes.d.ts +6 -0
- package/dist/cjs/ag-grid-plus/schemes/hooks/useColumnSchemes.js +542 -0
- package/dist/cjs/ag-grid-plus/schemes/hooks/useColumnSchemes.refactored.d.ts +7 -0
- package/dist/cjs/ag-grid-plus/schemes/hooks/useColumnSchemes.refactored.js +32 -0
- package/dist/cjs/ag-grid-plus/schemes/index.d.ts +16 -0
- package/dist/cjs/ag-grid-plus/schemes/index.js +124 -0
- package/dist/cjs/ag-grid-plus/schemes/storage/localStorageAdapter.d.ts +64 -0
- package/dist/cjs/ag-grid-plus/schemes/storage/localStorageAdapter.js +368 -0
- package/dist/cjs/ag-grid-plus/schemes/types.d.ts +126 -0
- package/dist/cjs/ag-grid-plus/schemes/types.js +5 -0
- package/dist/cjs/ag-grid-plus/schemes/utils/validator.d.ts +27 -0
- package/dist/cjs/ag-grid-plus/schemes/utils/validator.js +113 -0
- package/dist/cjs/ag-grid-plus/setting/ColumnSetting.d.ts +17 -0
- package/dist/cjs/ag-grid-plus/setting/ColumnSetting.js +955 -0
- package/dist/cjs/ag-grid-plus/setting/index.d.ts +1 -1
- package/dist/cjs/ag-grid-plus/setting/index.js +74 -111
- package/dist/cjs/ag-grid-plus/shared/hooks/useSchemeManager.d.ts +66 -0
- package/dist/cjs/ag-grid-plus/shared/hooks/useSchemeManager.js +648 -0
- package/dist/cjs/ag-grid-plus/storage/MemoryStorageAdapter.d.ts +76 -0
- package/dist/cjs/ag-grid-plus/storage/MemoryStorageAdapter.js +276 -0
- package/dist/cjs/ag-grid-plus/storage/SchemeSyncManager.d.ts +104 -0
- package/dist/cjs/ag-grid-plus/storage/SchemeSyncManager.js +593 -0
- package/dist/cjs/ag-grid-plus/storage/globalSyncManager.d.ts +74 -0
- package/dist/cjs/ag-grid-plus/storage/globalSyncManager.js +287 -0
- package/dist/cjs/ag-grid-plus/storage/index.d.ts +8 -0
- package/dist/cjs/ag-grid-plus/storage/index.js +49 -0
- package/dist/cjs/ag-grid-plus/storage/types.d.ts +113 -0
- package/dist/cjs/ag-grid-plus/storage/types.js +5 -0
- package/dist/cjs/ag-grid-plus/types.d.ts +310 -0
- package/dist/cjs/ag-grid-plus/types.js +5 -0
- package/dist/cjs/ag-grid-plus/utils/columnProcessors.d.ts +95 -0
- package/dist/cjs/ag-grid-plus/utils/columnProcessors.js +265 -0
- package/dist/cjs/ag-grid-plus/utils/constants.d.ts +41 -0
- package/dist/cjs/ag-grid-plus/utils/constants.js +56 -0
- package/dist/cjs/ag-grid-plus/utils/logger.d.ts +34 -0
- package/dist/cjs/ag-grid-plus/utils/logger.js +119 -0
- package/dist/cjs/ag-grid-plus/utils/sanitize.d.ts +15 -0
- package/dist/cjs/ag-grid-plus/utils/sanitize.js +39 -0
- package/dist/cjs/index.d.ts +3 -2
- package/dist/cjs/index.js +84 -0
- package/dist/esm/ag-grid-plus/ag-gridPlus.js +395 -206
- package/dist/esm/ag-grid-plus/context/gridContext.d.ts +30 -5
- package/dist/esm/ag-grid-plus/context/gridContext.js +6 -1
- package/dist/esm/ag-grid-plus/errors/ErrorBoundary.d.ts +36 -0
- package/dist/esm/ag-grid-plus/errors/ErrorBoundary.js +137 -0
- package/dist/esm/ag-grid-plus/errors/index.d.ts +3 -0
- package/dist/esm/ag-grid-plus/errors/index.js +2 -0
- package/dist/esm/ag-grid-plus/errors/types.d.ts +71 -0
- package/dist/esm/ag-grid-plus/errors/types.js +135 -0
- package/dist/esm/ag-grid-plus/hooks/index.d.ts +7 -0
- package/dist/esm/ag-grid-plus/hooks/index.js +10 -0
- package/dist/esm/ag-grid-plus/hooks/useAgGridCalculation.d.ts +88 -0
- package/dist/esm/ag-grid-plus/hooks/useAgGridCalculation.js +217 -0
- package/dist/esm/ag-grid-plus/hooks/useAgGridData.d.ts +91 -0
- package/dist/esm/ag-grid-plus/hooks/useAgGridData.js +225 -0
- package/dist/esm/ag-grid-plus/hooks/useGridPlusColumnState.d.ts +1 -8
- package/dist/esm/ag-grid-plus/hooks/useGridState.d.ts +153 -0
- package/dist/esm/ag-grid-plus/hooks/useGridState.js +258 -0
- package/dist/esm/ag-grid-plus/index.d.ts +3 -0
- package/dist/esm/ag-grid-plus/index.js +4 -1
- package/dist/esm/ag-grid-plus/interface.d.ts +27 -0
- package/dist/esm/ag-grid-plus/queryForm/index.less +7 -2
- package/dist/esm/ag-grid-plus/querySchemes/components/QuerySchemesManager.d.ts +21 -0
- package/dist/esm/ag-grid-plus/querySchemes/components/QuerySchemesManager.js +572 -0
- package/dist/esm/ag-grid-plus/querySchemes/components/QuerySchemesManager.less +86 -0
- package/dist/esm/ag-grid-plus/querySchemes/components/index.d.ts +5 -0
- package/dist/esm/ag-grid-plus/querySchemes/components/index.js +5 -0
- package/dist/esm/ag-grid-plus/querySchemes/constants.d.ts +17 -0
- package/dist/esm/ag-grid-plus/querySchemes/constants.js +24 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.d.ts +10 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQueryOrderManager.js +60 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQuerySchemes.d.ts +6 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQuerySchemes.js +537 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQuerySchemes.refactored.d.ts +7 -0
- package/dist/esm/ag-grid-plus/querySchemes/hooks/useQuerySchemes.refactored.js +27 -0
- package/dist/esm/ag-grid-plus/querySchemes/index.d.ts +11 -0
- package/dist/esm/ag-grid-plus/querySchemes/index.js +20 -0
- package/dist/esm/ag-grid-plus/querySchemes/storage/localStorageAdapter.d.ts +44 -0
- package/dist/esm/ag-grid-plus/querySchemes/storage/localStorageAdapter.js +256 -0
- package/dist/esm/ag-grid-plus/querySchemes/types.d.ts +143 -0
- package/dist/esm/ag-grid-plus/querySchemes/types.js +1 -0
- package/dist/esm/ag-grid-plus/querySchemes/utils/validator.d.ts +36 -0
- package/dist/esm/ag-grid-plus/querySchemes/utils/validator.js +144 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeManager.d.ts +16 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeManager.js +334 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeManager.less +35 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeSelector.d.ts +20 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeSelector.js +281 -0
- package/dist/esm/ag-grid-plus/schemes/components/SchemeSelector.less +39 -0
- package/dist/esm/ag-grid-plus/schemes/components/index.d.ts +4 -0
- package/dist/esm/ag-grid-plus/schemes/components/index.js +2 -0
- package/dist/esm/ag-grid-plus/schemes/constants.d.ts +23 -0
- package/dist/esm/ag-grid-plus/schemes/constants.js +33 -0
- package/dist/esm/ag-grid-plus/schemes/hooks/useColumnSchemes.d.ts +6 -0
- package/dist/esm/ag-grid-plus/schemes/hooks/useColumnSchemes.js +537 -0
- package/dist/esm/ag-grid-plus/schemes/hooks/useColumnSchemes.refactored.d.ts +7 -0
- package/dist/esm/ag-grid-plus/schemes/hooks/useColumnSchemes.refactored.js +27 -0
- package/dist/esm/ag-grid-plus/schemes/index.d.ts +16 -0
- package/dist/esm/ag-grid-plus/schemes/index.js +25 -0
- package/dist/esm/ag-grid-plus/schemes/storage/localStorageAdapter.d.ts +64 -0
- package/dist/esm/ag-grid-plus/schemes/storage/localStorageAdapter.js +363 -0
- package/dist/esm/ag-grid-plus/schemes/types.d.ts +126 -0
- package/dist/esm/ag-grid-plus/schemes/types.js +1 -0
- package/dist/esm/ag-grid-plus/schemes/utils/validator.d.ts +27 -0
- package/dist/esm/ag-grid-plus/schemes/utils/validator.js +104 -0
- package/dist/esm/ag-grid-plus/setting/ColumnSetting.d.ts +17 -0
- package/dist/esm/ag-grid-plus/setting/ColumnSetting.js +946 -0
- package/dist/esm/ag-grid-plus/setting/index.d.ts +1 -1
- package/dist/esm/ag-grid-plus/setting/index.js +69 -107
- package/dist/esm/ag-grid-plus/shared/hooks/useSchemeManager.d.ts +66 -0
- package/dist/esm/ag-grid-plus/shared/hooks/useSchemeManager.js +643 -0
- package/dist/esm/ag-grid-plus/storage/MemoryStorageAdapter.d.ts +76 -0
- package/dist/esm/ag-grid-plus/storage/MemoryStorageAdapter.js +273 -0
- package/dist/esm/ag-grid-plus/storage/SchemeSyncManager.d.ts +104 -0
- package/dist/esm/ag-grid-plus/storage/SchemeSyncManager.js +587 -0
- package/dist/esm/ag-grid-plus/storage/globalSyncManager.d.ts +74 -0
- package/dist/esm/ag-grid-plus/storage/globalSyncManager.js +275 -0
- package/dist/esm/ag-grid-plus/storage/index.d.ts +8 -0
- package/dist/esm/ag-grid-plus/storage/index.js +9 -0
- package/dist/esm/ag-grid-plus/storage/types.d.ts +113 -0
- package/dist/esm/ag-grid-plus/storage/types.js +1 -0
- package/dist/esm/ag-grid-plus/types.d.ts +310 -0
- package/dist/esm/ag-grid-plus/types.js +1 -0
- package/dist/esm/ag-grid-plus/utils/columnProcessors.d.ts +95 -0
- package/dist/esm/ag-grid-plus/utils/columnProcessors.js +251 -0
- package/dist/esm/ag-grid-plus/utils/constants.d.ts +41 -0
- package/dist/esm/ag-grid-plus/utils/constants.js +50 -0
- package/dist/esm/ag-grid-plus/utils/logger.d.ts +34 -0
- package/dist/esm/ag-grid-plus/utils/logger.js +114 -0
- package/dist/esm/ag-grid-plus/utils/sanitize.d.ts +15 -0
- package/dist/esm/ag-grid-plus/utils/sanitize.js +32 -0
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.js +8 -2
- package/dist/esm/standardFormDialog/withStandardForm.d.ts +2 -2
- package/dist/umd/qc-ui.min.css +1 -1
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ColumnScheme, StorageAdapter } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* LocalStorage 存储适配器实现
|
|
4
|
+
* 默认的方案存储方式,支持自动迁移旧数据
|
|
5
|
+
*/
|
|
6
|
+
export declare class LocalStorageAdapter implements StorageAdapter {
|
|
7
|
+
/**
|
|
8
|
+
* 生成存储键名
|
|
9
|
+
*/
|
|
10
|
+
private getStorageKey;
|
|
11
|
+
/**
|
|
12
|
+
* 生成旧版本存储键名
|
|
13
|
+
*/
|
|
14
|
+
private getLegacyStorageKey;
|
|
15
|
+
/**
|
|
16
|
+
* 检查是否需要迁移旧数据
|
|
17
|
+
*/
|
|
18
|
+
private needsMigration;
|
|
19
|
+
/**
|
|
20
|
+
* 迁移旧数据到新格式
|
|
21
|
+
*/
|
|
22
|
+
private migrateOldData;
|
|
23
|
+
/**
|
|
24
|
+
* 检查存储空间是否足够
|
|
25
|
+
*/
|
|
26
|
+
private checkStorageQuota;
|
|
27
|
+
/**
|
|
28
|
+
* 获取指定表格的所有方案
|
|
29
|
+
*/
|
|
30
|
+
getSchemes(gridId: string): Promise<ColumnScheme[]>;
|
|
31
|
+
/**
|
|
32
|
+
* 保存方案列表到 LocalStorage
|
|
33
|
+
*/
|
|
34
|
+
saveSchemes(gridId: string, schemes: ColumnScheme[]): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* 清除指定表格的所有方案
|
|
37
|
+
*/
|
|
38
|
+
clearSchemes(gridId: string): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* 获取存储使用情况统计
|
|
41
|
+
*/
|
|
42
|
+
getStorageStats(): {
|
|
43
|
+
totalSize: number;
|
|
44
|
+
usedSize: number;
|
|
45
|
+
usagePercentage: number;
|
|
46
|
+
itemCount: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* 生成当前方案ID存储键名
|
|
50
|
+
*/
|
|
51
|
+
private getCurrentSchemeKey;
|
|
52
|
+
/**
|
|
53
|
+
* 获取当前激活的方案ID
|
|
54
|
+
*/
|
|
55
|
+
getCurrentSchemeId(gridId: string): Promise<string | null>;
|
|
56
|
+
/**
|
|
57
|
+
* 保存当前激活的方案ID
|
|
58
|
+
*/
|
|
59
|
+
saveCurrentSchemeId(gridId: string, schemeId: string | null): Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 导出默认实例
|
|
63
|
+
*/
|
|
64
|
+
export declare const defaultStorageAdapter: LocalStorageAdapter;
|
|
@@ -0,0 +1,363 @@
|
|
|
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 _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
|
+
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); }
|
|
10
|
+
import { STORAGE_PREFIX, CURRENT_SCHEME_SUFFIX, LEGACY_STORAGE_PREFIX, MIGRATED_DEFAULT_SCHEME_ID, DEFAULT_SCHEME_NAME, STORAGE_MAX_SIZE } from "../constants";
|
|
11
|
+
/**
|
|
12
|
+
* LocalStorage 存储适配器实现
|
|
13
|
+
* 默认的方案存储方式,支持自动迁移旧数据
|
|
14
|
+
*/
|
|
15
|
+
export var LocalStorageAdapter = /*#__PURE__*/function () {
|
|
16
|
+
function LocalStorageAdapter() {
|
|
17
|
+
_classCallCheck(this, LocalStorageAdapter);
|
|
18
|
+
}
|
|
19
|
+
_createClass(LocalStorageAdapter, [{
|
|
20
|
+
key: "getStorageKey",
|
|
21
|
+
value:
|
|
22
|
+
/**
|
|
23
|
+
* 生成存储键名
|
|
24
|
+
*/
|
|
25
|
+
function getStorageKey(gridId) {
|
|
26
|
+
return "".concat(STORAGE_PREFIX, "-").concat(gridId);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 生成旧版本存储键名
|
|
31
|
+
*/
|
|
32
|
+
}, {
|
|
33
|
+
key: "getLegacyStorageKey",
|
|
34
|
+
value: function getLegacyStorageKey(gridId) {
|
|
35
|
+
return "".concat(LEGACY_STORAGE_PREFIX, "-").concat(gridId);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 检查是否需要迁移旧数据
|
|
40
|
+
*/
|
|
41
|
+
}, {
|
|
42
|
+
key: "needsMigration",
|
|
43
|
+
value: function needsMigration(gridId) {
|
|
44
|
+
var newKey = this.getStorageKey(gridId);
|
|
45
|
+
var oldKey = this.getLegacyStorageKey(gridId);
|
|
46
|
+
var hasNewData = localStorage.getItem(newKey) !== null;
|
|
47
|
+
var hasOldData = localStorage.getItem(oldKey) !== null;
|
|
48
|
+
return !hasNewData && hasOldData;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 迁移旧数据到新格式
|
|
53
|
+
*/
|
|
54
|
+
}, {
|
|
55
|
+
key: "migrateOldData",
|
|
56
|
+
value: (function () {
|
|
57
|
+
var _migrateOldData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(gridId) {
|
|
58
|
+
var oldKey, oldData, columnState, migratedScheme;
|
|
59
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
60
|
+
while (1) switch (_context.prev = _context.next) {
|
|
61
|
+
case 0:
|
|
62
|
+
oldKey = this.getLegacyStorageKey(gridId);
|
|
63
|
+
oldData = localStorage.getItem(oldKey);
|
|
64
|
+
if (oldData) {
|
|
65
|
+
_context.next = 4;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
return _context.abrupt("return", []);
|
|
69
|
+
case 4:
|
|
70
|
+
_context.prev = 4;
|
|
71
|
+
columnState = JSON.parse(oldData); // 创建默认方案
|
|
72
|
+
migratedScheme = {
|
|
73
|
+
id: MIGRATED_DEFAULT_SCHEME_ID,
|
|
74
|
+
name: DEFAULT_SCHEME_NAME,
|
|
75
|
+
isDefault: true,
|
|
76
|
+
isSystem: true,
|
|
77
|
+
createdAt: Date.now(),
|
|
78
|
+
updatedAt: Date.now(),
|
|
79
|
+
columnState: columnState,
|
|
80
|
+
description: '由旧版本列配置自动迁移'
|
|
81
|
+
}; // 保存到新格式
|
|
82
|
+
_context.next = 9;
|
|
83
|
+
return this.saveSchemes(gridId, [migratedScheme]);
|
|
84
|
+
case 9:
|
|
85
|
+
// 可选:保留旧数据作为备份或删除
|
|
86
|
+
// localStorage.removeItem(oldKey);
|
|
87
|
+
|
|
88
|
+
console.log("[SchemeManager] \u5DF2\u8FC1\u79FB\u65E7\u5217\u914D\u7F6E\u6570\u636E\u5230\u65B9\u6848\u7CFB\u7EDF: ".concat(gridId));
|
|
89
|
+
return _context.abrupt("return", [migratedScheme]);
|
|
90
|
+
case 13:
|
|
91
|
+
_context.prev = 13;
|
|
92
|
+
_context.t0 = _context["catch"](4);
|
|
93
|
+
console.error('[SchemeManager] 迁移旧数据失败:', _context.t0);
|
|
94
|
+
return _context.abrupt("return", []);
|
|
95
|
+
case 17:
|
|
96
|
+
case "end":
|
|
97
|
+
return _context.stop();
|
|
98
|
+
}
|
|
99
|
+
}, _callee, this, [[4, 13]]);
|
|
100
|
+
}));
|
|
101
|
+
function migrateOldData(_x) {
|
|
102
|
+
return _migrateOldData.apply(this, arguments);
|
|
103
|
+
}
|
|
104
|
+
return migrateOldData;
|
|
105
|
+
}()
|
|
106
|
+
/**
|
|
107
|
+
* 检查存储空间是否足够
|
|
108
|
+
*/
|
|
109
|
+
)
|
|
110
|
+
}, {
|
|
111
|
+
key: "checkStorageQuota",
|
|
112
|
+
value: function checkStorageQuota(data) {
|
|
113
|
+
try {
|
|
114
|
+
// 估算当前使用量
|
|
115
|
+
var totalSize = 0;
|
|
116
|
+
for (var key in localStorage) {
|
|
117
|
+
if (localStorage.hasOwnProperty(key)) {
|
|
118
|
+
totalSize += localStorage[key].length + key.length;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
var newDataSize = data.length;
|
|
122
|
+
if (totalSize + newDataSize > STORAGE_MAX_SIZE) {
|
|
123
|
+
console.warn('[SchemeManager] LocalStorage 接近容量限制');
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
return true;
|
|
127
|
+
} catch (error) {
|
|
128
|
+
console.error('[SchemeManager] 检查存储空间失败:', error);
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* 获取指定表格的所有方案
|
|
135
|
+
*/
|
|
136
|
+
}, {
|
|
137
|
+
key: "getSchemes",
|
|
138
|
+
value: (function () {
|
|
139
|
+
var _getSchemes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(gridId) {
|
|
140
|
+
var key, data, schemes;
|
|
141
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
142
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
143
|
+
case 0:
|
|
144
|
+
_context2.prev = 0;
|
|
145
|
+
if (!this.needsMigration(gridId)) {
|
|
146
|
+
_context2.next = 5;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
_context2.next = 4;
|
|
150
|
+
return this.migrateOldData(gridId);
|
|
151
|
+
case 4:
|
|
152
|
+
return _context2.abrupt("return", _context2.sent);
|
|
153
|
+
case 5:
|
|
154
|
+
key = this.getStorageKey(gridId);
|
|
155
|
+
data = localStorage.getItem(key);
|
|
156
|
+
if (data) {
|
|
157
|
+
_context2.next = 9;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
return _context2.abrupt("return", []);
|
|
161
|
+
case 9:
|
|
162
|
+
schemes = JSON.parse(data); // 验证数据完整性
|
|
163
|
+
return _context2.abrupt("return", schemes.filter(function (scheme) {
|
|
164
|
+
return scheme.id && scheme.name && scheme.columnState && Array.isArray(scheme.columnState);
|
|
165
|
+
}));
|
|
166
|
+
case 13:
|
|
167
|
+
_context2.prev = 13;
|
|
168
|
+
_context2.t0 = _context2["catch"](0);
|
|
169
|
+
console.error('[SchemeManager] 加载方案失败:', _context2.t0);
|
|
170
|
+
return _context2.abrupt("return", []);
|
|
171
|
+
case 17:
|
|
172
|
+
case "end":
|
|
173
|
+
return _context2.stop();
|
|
174
|
+
}
|
|
175
|
+
}, _callee2, this, [[0, 13]]);
|
|
176
|
+
}));
|
|
177
|
+
function getSchemes(_x2) {
|
|
178
|
+
return _getSchemes.apply(this, arguments);
|
|
179
|
+
}
|
|
180
|
+
return getSchemes;
|
|
181
|
+
}()
|
|
182
|
+
/**
|
|
183
|
+
* 保存方案列表到 LocalStorage
|
|
184
|
+
*/
|
|
185
|
+
)
|
|
186
|
+
}, {
|
|
187
|
+
key: "saveSchemes",
|
|
188
|
+
value: (function () {
|
|
189
|
+
var _saveSchemes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(gridId, schemes) {
|
|
190
|
+
var key, data;
|
|
191
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
192
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
193
|
+
case 0:
|
|
194
|
+
_context3.prev = 0;
|
|
195
|
+
key = this.getStorageKey(gridId);
|
|
196
|
+
data = JSON.stringify(schemes); // 检查存储空间
|
|
197
|
+
if (this.checkStorageQuota(data)) {
|
|
198
|
+
_context3.next = 5;
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
throw new Error('LocalStorage 空间不足,请删除一些方案');
|
|
202
|
+
case 5:
|
|
203
|
+
localStorage.setItem(key, data);
|
|
204
|
+
_context3.next = 12;
|
|
205
|
+
break;
|
|
206
|
+
case 8:
|
|
207
|
+
_context3.prev = 8;
|
|
208
|
+
_context3.t0 = _context3["catch"](0);
|
|
209
|
+
console.error('[SchemeManager] 保存方案失败:', _context3.t0);
|
|
210
|
+
throw _context3.t0;
|
|
211
|
+
case 12:
|
|
212
|
+
case "end":
|
|
213
|
+
return _context3.stop();
|
|
214
|
+
}
|
|
215
|
+
}, _callee3, this, [[0, 8]]);
|
|
216
|
+
}));
|
|
217
|
+
function saveSchemes(_x3, _x4) {
|
|
218
|
+
return _saveSchemes.apply(this, arguments);
|
|
219
|
+
}
|
|
220
|
+
return saveSchemes;
|
|
221
|
+
}()
|
|
222
|
+
/**
|
|
223
|
+
* 清除指定表格的所有方案
|
|
224
|
+
*/
|
|
225
|
+
)
|
|
226
|
+
}, {
|
|
227
|
+
key: "clearSchemes",
|
|
228
|
+
value: (function () {
|
|
229
|
+
var _clearSchemes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(gridId) {
|
|
230
|
+
var key;
|
|
231
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
232
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
233
|
+
case 0:
|
|
234
|
+
_context4.prev = 0;
|
|
235
|
+
key = this.getStorageKey(gridId);
|
|
236
|
+
localStorage.removeItem(key);
|
|
237
|
+
console.log("[SchemeManager] \u5DF2\u6E05\u9664\u8868\u683C ".concat(gridId, " \u7684\u6240\u6709\u65B9\u6848"));
|
|
238
|
+
_context4.next = 10;
|
|
239
|
+
break;
|
|
240
|
+
case 6:
|
|
241
|
+
_context4.prev = 6;
|
|
242
|
+
_context4.t0 = _context4["catch"](0);
|
|
243
|
+
console.error('[SchemeManager] 清除方案失败:', _context4.t0);
|
|
244
|
+
throw _context4.t0;
|
|
245
|
+
case 10:
|
|
246
|
+
case "end":
|
|
247
|
+
return _context4.stop();
|
|
248
|
+
}
|
|
249
|
+
}, _callee4, this, [[0, 6]]);
|
|
250
|
+
}));
|
|
251
|
+
function clearSchemes(_x5) {
|
|
252
|
+
return _clearSchemes.apply(this, arguments);
|
|
253
|
+
}
|
|
254
|
+
return clearSchemes;
|
|
255
|
+
}()
|
|
256
|
+
/**
|
|
257
|
+
* 获取存储使用情况统计
|
|
258
|
+
*/
|
|
259
|
+
)
|
|
260
|
+
}, {
|
|
261
|
+
key: "getStorageStats",
|
|
262
|
+
value: function getStorageStats() {
|
|
263
|
+
var totalSize = 0;
|
|
264
|
+
var itemCount = 0;
|
|
265
|
+
for (var key in localStorage) {
|
|
266
|
+
if (localStorage.hasOwnProperty(key) && key.startsWith(STORAGE_PREFIX)) {
|
|
267
|
+
totalSize += localStorage[key].length + key.length;
|
|
268
|
+
itemCount++;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return {
|
|
272
|
+
totalSize: STORAGE_MAX_SIZE,
|
|
273
|
+
usedSize: totalSize,
|
|
274
|
+
usagePercentage: totalSize / STORAGE_MAX_SIZE * 100,
|
|
275
|
+
itemCount: itemCount
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* 生成当前方案ID存储键名
|
|
281
|
+
*/
|
|
282
|
+
}, {
|
|
283
|
+
key: "getCurrentSchemeKey",
|
|
284
|
+
value: function getCurrentSchemeKey(gridId) {
|
|
285
|
+
return "".concat(STORAGE_PREFIX, "-").concat(gridId).concat(CURRENT_SCHEME_SUFFIX);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* 获取当前激活的方案ID
|
|
290
|
+
*/
|
|
291
|
+
}, {
|
|
292
|
+
key: "getCurrentSchemeId",
|
|
293
|
+
value: (function () {
|
|
294
|
+
var _getCurrentSchemeId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(gridId) {
|
|
295
|
+
var key, schemeId;
|
|
296
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
297
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
298
|
+
case 0:
|
|
299
|
+
_context5.prev = 0;
|
|
300
|
+
key = this.getCurrentSchemeKey(gridId);
|
|
301
|
+
schemeId = localStorage.getItem(key);
|
|
302
|
+
return _context5.abrupt("return", schemeId || null);
|
|
303
|
+
case 6:
|
|
304
|
+
_context5.prev = 6;
|
|
305
|
+
_context5.t0 = _context5["catch"](0);
|
|
306
|
+
console.error('[SchemeManager] 获取当前方案ID失败:', _context5.t0);
|
|
307
|
+
return _context5.abrupt("return", null);
|
|
308
|
+
case 10:
|
|
309
|
+
case "end":
|
|
310
|
+
return _context5.stop();
|
|
311
|
+
}
|
|
312
|
+
}, _callee5, this, [[0, 6]]);
|
|
313
|
+
}));
|
|
314
|
+
function getCurrentSchemeId(_x6) {
|
|
315
|
+
return _getCurrentSchemeId.apply(this, arguments);
|
|
316
|
+
}
|
|
317
|
+
return getCurrentSchemeId;
|
|
318
|
+
}()
|
|
319
|
+
/**
|
|
320
|
+
* 保存当前激活的方案ID
|
|
321
|
+
*/
|
|
322
|
+
)
|
|
323
|
+
}, {
|
|
324
|
+
key: "saveCurrentSchemeId",
|
|
325
|
+
value: (function () {
|
|
326
|
+
var _saveCurrentSchemeId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(gridId, schemeId) {
|
|
327
|
+
var key;
|
|
328
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
329
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
330
|
+
case 0:
|
|
331
|
+
_context6.prev = 0;
|
|
332
|
+
key = this.getCurrentSchemeKey(gridId);
|
|
333
|
+
if (schemeId === null) {
|
|
334
|
+
localStorage.removeItem(key);
|
|
335
|
+
} else {
|
|
336
|
+
localStorage.setItem(key, schemeId);
|
|
337
|
+
}
|
|
338
|
+
_context6.next = 9;
|
|
339
|
+
break;
|
|
340
|
+
case 5:
|
|
341
|
+
_context6.prev = 5;
|
|
342
|
+
_context6.t0 = _context6["catch"](0);
|
|
343
|
+
console.error('[SchemeManager] 保存当前方案ID失败:', _context6.t0);
|
|
344
|
+
throw _context6.t0;
|
|
345
|
+
case 9:
|
|
346
|
+
case "end":
|
|
347
|
+
return _context6.stop();
|
|
348
|
+
}
|
|
349
|
+
}, _callee6, this, [[0, 5]]);
|
|
350
|
+
}));
|
|
351
|
+
function saveCurrentSchemeId(_x7, _x8) {
|
|
352
|
+
return _saveCurrentSchemeId.apply(this, arguments);
|
|
353
|
+
}
|
|
354
|
+
return saveCurrentSchemeId;
|
|
355
|
+
}())
|
|
356
|
+
}]);
|
|
357
|
+
return LocalStorageAdapter;
|
|
358
|
+
}();
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* 导出默认实例
|
|
362
|
+
*/
|
|
363
|
+
export var defaultStorageAdapter = new LocalStorageAdapter();
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { ColumnState } from 'ag-grid-community';
|
|
2
|
+
/**
|
|
3
|
+
* 列配置方案数据结构
|
|
4
|
+
*/
|
|
5
|
+
export interface ColumnScheme {
|
|
6
|
+
/** 方案唯一标识(UUID) */
|
|
7
|
+
id: string;
|
|
8
|
+
/** 方案名称(用户可编辑) */
|
|
9
|
+
name: string;
|
|
10
|
+
/** 是否为默认方案(首次加载自动应用) */
|
|
11
|
+
isDefault?: boolean;
|
|
12
|
+
/** 是否为系统预设方案(不可删除) */
|
|
13
|
+
isSystem?: boolean;
|
|
14
|
+
/** 创建时间戳 */
|
|
15
|
+
createdAt: number;
|
|
16
|
+
/** 更新时间戳 */
|
|
17
|
+
updatedAt: number;
|
|
18
|
+
/** AG-Grid 列状态数据 */
|
|
19
|
+
columnState: ColumnState[];
|
|
20
|
+
/** 方案描述(可选) */
|
|
21
|
+
description?: string;
|
|
22
|
+
/** 标签分类(可选,扩展功能) */
|
|
23
|
+
tags?: string[];
|
|
24
|
+
/** 共享级别(可选,扩展功能) */
|
|
25
|
+
shareLevel?: 'private' | 'team' | 'public';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 方案管理器配置
|
|
29
|
+
*/
|
|
30
|
+
export interface SchemeManagerConfig {
|
|
31
|
+
/** 表格唯一标识 */
|
|
32
|
+
gridId: string;
|
|
33
|
+
/** 自定义存储适配器(可选) */
|
|
34
|
+
storageAdapter?: StorageAdapter;
|
|
35
|
+
/** 是否启用自动保存到当前方案(默认 true) */
|
|
36
|
+
enableAutoSave?: boolean;
|
|
37
|
+
/** 方案切换回调 */
|
|
38
|
+
onSchemeChange?: (scheme: ColumnScheme | null) => void;
|
|
39
|
+
/** 方案保存回调 */
|
|
40
|
+
onSchemeSave?: (scheme: ColumnScheme) => void;
|
|
41
|
+
/** 方案删除回调 */
|
|
42
|
+
onSchemeDelete?: (schemeId: string) => void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 存储适配器接口
|
|
46
|
+
* 允许自定义存储实现(LocalStorage / IndexedDB / 后端API等)
|
|
47
|
+
*/
|
|
48
|
+
export interface StorageAdapter {
|
|
49
|
+
/**
|
|
50
|
+
* 获取指定表格的所有方案
|
|
51
|
+
* @param gridId 表格唯一标识
|
|
52
|
+
* @returns 方案列表
|
|
53
|
+
*/
|
|
54
|
+
getSchemes(gridId: string): Promise<ColumnScheme[]>;
|
|
55
|
+
/**
|
|
56
|
+
* 保存方案列表到存储
|
|
57
|
+
* @param gridId 表格唯一标识
|
|
58
|
+
* @param schemes 方案列表
|
|
59
|
+
*/
|
|
60
|
+
saveSchemes(gridId: string, schemes: ColumnScheme[]): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* 清除指定表格的所有方案
|
|
63
|
+
* @param gridId 表格唯一标识
|
|
64
|
+
*/
|
|
65
|
+
clearSchemes?(gridId: string): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* 获取当前激活的方案ID(用于刷新后恢复)
|
|
68
|
+
* @param gridId 表格唯一标识
|
|
69
|
+
* @returns 方案ID,如果没有则返回 null
|
|
70
|
+
*/
|
|
71
|
+
getCurrentSchemeId?(gridId: string): Promise<string | null>;
|
|
72
|
+
/**
|
|
73
|
+
* 保存当前激活的方案ID
|
|
74
|
+
* @param gridId 表格唯一标识
|
|
75
|
+
* @param schemeId 方案ID,null 表示清除
|
|
76
|
+
*/
|
|
77
|
+
saveCurrentSchemeId?(gridId: string, schemeId: string | null): Promise<void>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 方案验证结果
|
|
81
|
+
*/
|
|
82
|
+
export interface SchemeValidationResult {
|
|
83
|
+
/** 是否有效 */
|
|
84
|
+
valid: boolean;
|
|
85
|
+
/** 无效的列 ID 列表 */
|
|
86
|
+
invalidColumns: string[];
|
|
87
|
+
/** 验证后的有效列状态 */
|
|
88
|
+
validatedState: ColumnState[];
|
|
89
|
+
/** 警告信息 */
|
|
90
|
+
warnings?: string[];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* 方案管理器 Hook 返回值
|
|
94
|
+
*/
|
|
95
|
+
export interface UseColumnSchemesReturn {
|
|
96
|
+
/** 当前激活的方案 */
|
|
97
|
+
currentScheme: ColumnScheme | null;
|
|
98
|
+
/** 所有可用方案列表 */
|
|
99
|
+
schemes: ColumnScheme[];
|
|
100
|
+
/** 当前配置是否有未保存的修改 */
|
|
101
|
+
isDirty: boolean;
|
|
102
|
+
/** 是否正在加载 */
|
|
103
|
+
loading: boolean;
|
|
104
|
+
/** 加载指定方案 */
|
|
105
|
+
loadScheme: (schemeId: string) => Promise<void>;
|
|
106
|
+
/** 保存当前方案(更新现有方案) */
|
|
107
|
+
saveScheme: (updates?: Partial<ColumnScheme>) => Promise<void>;
|
|
108
|
+
/** 创建新方案 */
|
|
109
|
+
createScheme: (name: string, columnState: ColumnState[], options?: Partial<ColumnScheme>) => Promise<ColumnScheme>;
|
|
110
|
+
/** 更新方案信息(不影响 columnState) */
|
|
111
|
+
updateScheme: (schemeId: string, updates: Partial<Omit<ColumnScheme, 'id' | 'columnState'>>) => Promise<void>;
|
|
112
|
+
/** 删除方案 */
|
|
113
|
+
deleteScheme: (schemeId: string) => Promise<void>;
|
|
114
|
+
/** 重置到方案原始状态 */
|
|
115
|
+
resetToScheme: () => void;
|
|
116
|
+
/** 设置默认方案 */
|
|
117
|
+
setDefaultScheme: (schemeId: string) => Promise<void>;
|
|
118
|
+
/** 验证方案有效性 */
|
|
119
|
+
validateScheme: (scheme: ColumnScheme, currentColumnDefs: any[]) => SchemeValidationResult;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* 旧格式列状态数据(用于迁移)
|
|
123
|
+
*/
|
|
124
|
+
export interface LegacyColumnState {
|
|
125
|
+
[gridKey: string]: ColumnState[];
|
|
126
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ColumnScheme, SchemeValidationResult } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* 验证方案有效性
|
|
4
|
+
*/
|
|
5
|
+
export declare function validateScheme(scheme: ColumnScheme, currentColumnDefs: any[]): SchemeValidationResult;
|
|
6
|
+
/**
|
|
7
|
+
* 验证方案名称
|
|
8
|
+
*/
|
|
9
|
+
export declare function validateSchemeName(name: string): {
|
|
10
|
+
valid: boolean;
|
|
11
|
+
error?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* 验证方案描述
|
|
15
|
+
*/
|
|
16
|
+
export declare function validateSchemeDescription(description: string): {
|
|
17
|
+
valid: boolean;
|
|
18
|
+
error?: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* 检查方案名称是否重复
|
|
22
|
+
*/
|
|
23
|
+
export declare function checkDuplicateName(name: string, schemes: ColumnScheme[], excludeId?: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* 生成唯一的方案名称(处理重名情况)
|
|
26
|
+
*/
|
|
27
|
+
export declare function generateUniqueName(baseName: string, schemes: ColumnScheme[]): string;
|