@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,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "DEFAULT_SCHEME_NAME", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _constants.DEFAULT_SCHEME_NAME;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "LEGACY_STORAGE_PREFIX", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _constants.LEGACY_STORAGE_PREFIX;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "LocalStorageAdapter", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _localStorageAdapter.LocalStorageAdapter;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "MAX_SCHEMES_PER_GRID", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _constants.MAX_SCHEMES_PER_GRID;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "MAX_SCHEME_DESCRIPTION_LENGTH", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _constants.MAX_SCHEME_DESCRIPTION_LENGTH;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "MAX_SCHEME_NAME_LENGTH", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _constants.MAX_SCHEME_NAME_LENGTH;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "MIGRATED_DEFAULT_SCHEME_ID", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function get() {
|
|
45
|
+
return _constants.MIGRATED_DEFAULT_SCHEME_ID;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "STORAGE_MAX_SIZE", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return _constants.STORAGE_MAX_SIZE;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "STORAGE_PREFIX", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function get() {
|
|
57
|
+
return _constants.STORAGE_PREFIX;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "SYSTEM_SCHEME_PREFIX", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function get() {
|
|
63
|
+
return _constants.SYSTEM_SCHEME_PREFIX;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "SchemeManager", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function get() {
|
|
69
|
+
return _components.SchemeManager;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "SchemeSelector", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function get() {
|
|
75
|
+
return _components.SchemeSelector;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "checkDuplicateName", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function get() {
|
|
81
|
+
return _validator.checkDuplicateName;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(exports, "defaultStorageAdapter", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function get() {
|
|
87
|
+
return _localStorageAdapter.defaultStorageAdapter;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(exports, "generateUniqueName", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function get() {
|
|
93
|
+
return _validator.generateUniqueName;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
Object.defineProperty(exports, "useColumnSchemes", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function get() {
|
|
99
|
+
return _useColumnSchemes.useColumnSchemes;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
Object.defineProperty(exports, "validateScheme", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
get: function get() {
|
|
105
|
+
return _validator.validateScheme;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
Object.defineProperty(exports, "validateSchemeDescription", {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: function get() {
|
|
111
|
+
return _validator.validateSchemeDescription;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
Object.defineProperty(exports, "validateSchemeName", {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
get: function get() {
|
|
117
|
+
return _validator.validateSchemeName;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
var _useColumnSchemes = require("./hooks/useColumnSchemes");
|
|
121
|
+
var _components = require("./components");
|
|
122
|
+
var _localStorageAdapter = require("./storage/localStorageAdapter");
|
|
123
|
+
var _validator = require("./utils/validator");
|
|
124
|
+
var _constants = require("./constants");
|
|
@@ -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,368 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultStorageAdapter = exports.LocalStorageAdapter = void 0;
|
|
7
|
+
var _constants = require("../constants");
|
|
8
|
+
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); }
|
|
9
|
+
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; }
|
|
10
|
+
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); } }
|
|
11
|
+
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); }); }; }
|
|
12
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
13
|
+
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); } }
|
|
14
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
16
|
+
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); }
|
|
17
|
+
/**
|
|
18
|
+
* LocalStorage 存储适配器实现
|
|
19
|
+
* 默认的方案存储方式,支持自动迁移旧数据
|
|
20
|
+
*/
|
|
21
|
+
var LocalStorageAdapter = exports.LocalStorageAdapter = /*#__PURE__*/function () {
|
|
22
|
+
function LocalStorageAdapter() {
|
|
23
|
+
_classCallCheck(this, LocalStorageAdapter);
|
|
24
|
+
}
|
|
25
|
+
_createClass(LocalStorageAdapter, [{
|
|
26
|
+
key: "getStorageKey",
|
|
27
|
+
value:
|
|
28
|
+
/**
|
|
29
|
+
* 生成存储键名
|
|
30
|
+
*/
|
|
31
|
+
function getStorageKey(gridId) {
|
|
32
|
+
return "".concat(_constants.STORAGE_PREFIX, "-").concat(gridId);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 生成旧版本存储键名
|
|
37
|
+
*/
|
|
38
|
+
}, {
|
|
39
|
+
key: "getLegacyStorageKey",
|
|
40
|
+
value: function getLegacyStorageKey(gridId) {
|
|
41
|
+
return "".concat(_constants.LEGACY_STORAGE_PREFIX, "-").concat(gridId);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 检查是否需要迁移旧数据
|
|
46
|
+
*/
|
|
47
|
+
}, {
|
|
48
|
+
key: "needsMigration",
|
|
49
|
+
value: function needsMigration(gridId) {
|
|
50
|
+
var newKey = this.getStorageKey(gridId);
|
|
51
|
+
var oldKey = this.getLegacyStorageKey(gridId);
|
|
52
|
+
var hasNewData = localStorage.getItem(newKey) !== null;
|
|
53
|
+
var hasOldData = localStorage.getItem(oldKey) !== null;
|
|
54
|
+
return !hasNewData && hasOldData;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 迁移旧数据到新格式
|
|
59
|
+
*/
|
|
60
|
+
}, {
|
|
61
|
+
key: "migrateOldData",
|
|
62
|
+
value: (function () {
|
|
63
|
+
var _migrateOldData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(gridId) {
|
|
64
|
+
var oldKey, oldData, columnState, migratedScheme;
|
|
65
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
66
|
+
while (1) switch (_context.prev = _context.next) {
|
|
67
|
+
case 0:
|
|
68
|
+
oldKey = this.getLegacyStorageKey(gridId);
|
|
69
|
+
oldData = localStorage.getItem(oldKey);
|
|
70
|
+
if (oldData) {
|
|
71
|
+
_context.next = 4;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
return _context.abrupt("return", []);
|
|
75
|
+
case 4:
|
|
76
|
+
_context.prev = 4;
|
|
77
|
+
columnState = JSON.parse(oldData); // 创建默认方案
|
|
78
|
+
migratedScheme = {
|
|
79
|
+
id: _constants.MIGRATED_DEFAULT_SCHEME_ID,
|
|
80
|
+
name: _constants.DEFAULT_SCHEME_NAME,
|
|
81
|
+
isDefault: true,
|
|
82
|
+
isSystem: true,
|
|
83
|
+
createdAt: Date.now(),
|
|
84
|
+
updatedAt: Date.now(),
|
|
85
|
+
columnState: columnState,
|
|
86
|
+
description: '由旧版本列配置自动迁移'
|
|
87
|
+
}; // 保存到新格式
|
|
88
|
+
_context.next = 9;
|
|
89
|
+
return this.saveSchemes(gridId, [migratedScheme]);
|
|
90
|
+
case 9:
|
|
91
|
+
// 可选:保留旧数据作为备份或删除
|
|
92
|
+
// localStorage.removeItem(oldKey);
|
|
93
|
+
|
|
94
|
+
console.log("[SchemeManager] \u5DF2\u8FC1\u79FB\u65E7\u5217\u914D\u7F6E\u6570\u636E\u5230\u65B9\u6848\u7CFB\u7EDF: ".concat(gridId));
|
|
95
|
+
return _context.abrupt("return", [migratedScheme]);
|
|
96
|
+
case 13:
|
|
97
|
+
_context.prev = 13;
|
|
98
|
+
_context.t0 = _context["catch"](4);
|
|
99
|
+
console.error('[SchemeManager] 迁移旧数据失败:', _context.t0);
|
|
100
|
+
return _context.abrupt("return", []);
|
|
101
|
+
case 17:
|
|
102
|
+
case "end":
|
|
103
|
+
return _context.stop();
|
|
104
|
+
}
|
|
105
|
+
}, _callee, this, [[4, 13]]);
|
|
106
|
+
}));
|
|
107
|
+
function migrateOldData(_x) {
|
|
108
|
+
return _migrateOldData.apply(this, arguments);
|
|
109
|
+
}
|
|
110
|
+
return migrateOldData;
|
|
111
|
+
}()
|
|
112
|
+
/**
|
|
113
|
+
* 检查存储空间是否足够
|
|
114
|
+
*/
|
|
115
|
+
)
|
|
116
|
+
}, {
|
|
117
|
+
key: "checkStorageQuota",
|
|
118
|
+
value: function checkStorageQuota(data) {
|
|
119
|
+
try {
|
|
120
|
+
// 估算当前使用量
|
|
121
|
+
var totalSize = 0;
|
|
122
|
+
for (var key in localStorage) {
|
|
123
|
+
if (localStorage.hasOwnProperty(key)) {
|
|
124
|
+
totalSize += localStorage[key].length + key.length;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
var newDataSize = data.length;
|
|
128
|
+
if (totalSize + newDataSize > _constants.STORAGE_MAX_SIZE) {
|
|
129
|
+
console.warn('[SchemeManager] LocalStorage 接近容量限制');
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
return true;
|
|
133
|
+
} catch (error) {
|
|
134
|
+
console.error('[SchemeManager] 检查存储空间失败:', error);
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* 获取指定表格的所有方案
|
|
141
|
+
*/
|
|
142
|
+
}, {
|
|
143
|
+
key: "getSchemes",
|
|
144
|
+
value: (function () {
|
|
145
|
+
var _getSchemes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(gridId) {
|
|
146
|
+
var key, data, schemes;
|
|
147
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
148
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
149
|
+
case 0:
|
|
150
|
+
_context2.prev = 0;
|
|
151
|
+
if (!this.needsMigration(gridId)) {
|
|
152
|
+
_context2.next = 5;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
_context2.next = 4;
|
|
156
|
+
return this.migrateOldData(gridId);
|
|
157
|
+
case 4:
|
|
158
|
+
return _context2.abrupt("return", _context2.sent);
|
|
159
|
+
case 5:
|
|
160
|
+
key = this.getStorageKey(gridId);
|
|
161
|
+
data = localStorage.getItem(key);
|
|
162
|
+
if (data) {
|
|
163
|
+
_context2.next = 9;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
return _context2.abrupt("return", []);
|
|
167
|
+
case 9:
|
|
168
|
+
schemes = JSON.parse(data); // 验证数据完整性
|
|
169
|
+
return _context2.abrupt("return", schemes.filter(function (scheme) {
|
|
170
|
+
return scheme.id && scheme.name && scheme.columnState && Array.isArray(scheme.columnState);
|
|
171
|
+
}));
|
|
172
|
+
case 13:
|
|
173
|
+
_context2.prev = 13;
|
|
174
|
+
_context2.t0 = _context2["catch"](0);
|
|
175
|
+
console.error('[SchemeManager] 加载方案失败:', _context2.t0);
|
|
176
|
+
return _context2.abrupt("return", []);
|
|
177
|
+
case 17:
|
|
178
|
+
case "end":
|
|
179
|
+
return _context2.stop();
|
|
180
|
+
}
|
|
181
|
+
}, _callee2, this, [[0, 13]]);
|
|
182
|
+
}));
|
|
183
|
+
function getSchemes(_x2) {
|
|
184
|
+
return _getSchemes.apply(this, arguments);
|
|
185
|
+
}
|
|
186
|
+
return getSchemes;
|
|
187
|
+
}()
|
|
188
|
+
/**
|
|
189
|
+
* 保存方案列表到 LocalStorage
|
|
190
|
+
*/
|
|
191
|
+
)
|
|
192
|
+
}, {
|
|
193
|
+
key: "saveSchemes",
|
|
194
|
+
value: (function () {
|
|
195
|
+
var _saveSchemes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(gridId, schemes) {
|
|
196
|
+
var key, data;
|
|
197
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
198
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
199
|
+
case 0:
|
|
200
|
+
_context3.prev = 0;
|
|
201
|
+
key = this.getStorageKey(gridId);
|
|
202
|
+
data = JSON.stringify(schemes); // 检查存储空间
|
|
203
|
+
if (this.checkStorageQuota(data)) {
|
|
204
|
+
_context3.next = 5;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
throw new Error('LocalStorage 空间不足,请删除一些方案');
|
|
208
|
+
case 5:
|
|
209
|
+
localStorage.setItem(key, data);
|
|
210
|
+
_context3.next = 12;
|
|
211
|
+
break;
|
|
212
|
+
case 8:
|
|
213
|
+
_context3.prev = 8;
|
|
214
|
+
_context3.t0 = _context3["catch"](0);
|
|
215
|
+
console.error('[SchemeManager] 保存方案失败:', _context3.t0);
|
|
216
|
+
throw _context3.t0;
|
|
217
|
+
case 12:
|
|
218
|
+
case "end":
|
|
219
|
+
return _context3.stop();
|
|
220
|
+
}
|
|
221
|
+
}, _callee3, this, [[0, 8]]);
|
|
222
|
+
}));
|
|
223
|
+
function saveSchemes(_x3, _x4) {
|
|
224
|
+
return _saveSchemes.apply(this, arguments);
|
|
225
|
+
}
|
|
226
|
+
return saveSchemes;
|
|
227
|
+
}()
|
|
228
|
+
/**
|
|
229
|
+
* 清除指定表格的所有方案
|
|
230
|
+
*/
|
|
231
|
+
)
|
|
232
|
+
}, {
|
|
233
|
+
key: "clearSchemes",
|
|
234
|
+
value: (function () {
|
|
235
|
+
var _clearSchemes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(gridId) {
|
|
236
|
+
var key;
|
|
237
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
238
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
239
|
+
case 0:
|
|
240
|
+
_context4.prev = 0;
|
|
241
|
+
key = this.getStorageKey(gridId);
|
|
242
|
+
localStorage.removeItem(key);
|
|
243
|
+
console.log("[SchemeManager] \u5DF2\u6E05\u9664\u8868\u683C ".concat(gridId, " \u7684\u6240\u6709\u65B9\u6848"));
|
|
244
|
+
_context4.next = 10;
|
|
245
|
+
break;
|
|
246
|
+
case 6:
|
|
247
|
+
_context4.prev = 6;
|
|
248
|
+
_context4.t0 = _context4["catch"](0);
|
|
249
|
+
console.error('[SchemeManager] 清除方案失败:', _context4.t0);
|
|
250
|
+
throw _context4.t0;
|
|
251
|
+
case 10:
|
|
252
|
+
case "end":
|
|
253
|
+
return _context4.stop();
|
|
254
|
+
}
|
|
255
|
+
}, _callee4, this, [[0, 6]]);
|
|
256
|
+
}));
|
|
257
|
+
function clearSchemes(_x5) {
|
|
258
|
+
return _clearSchemes.apply(this, arguments);
|
|
259
|
+
}
|
|
260
|
+
return clearSchemes;
|
|
261
|
+
}()
|
|
262
|
+
/**
|
|
263
|
+
* 获取存储使用情况统计
|
|
264
|
+
*/
|
|
265
|
+
)
|
|
266
|
+
}, {
|
|
267
|
+
key: "getStorageStats",
|
|
268
|
+
value: function getStorageStats() {
|
|
269
|
+
var totalSize = 0;
|
|
270
|
+
var itemCount = 0;
|
|
271
|
+
for (var key in localStorage) {
|
|
272
|
+
if (localStorage.hasOwnProperty(key) && key.startsWith(_constants.STORAGE_PREFIX)) {
|
|
273
|
+
totalSize += localStorage[key].length + key.length;
|
|
274
|
+
itemCount++;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return {
|
|
278
|
+
totalSize: _constants.STORAGE_MAX_SIZE,
|
|
279
|
+
usedSize: totalSize,
|
|
280
|
+
usagePercentage: totalSize / _constants.STORAGE_MAX_SIZE * 100,
|
|
281
|
+
itemCount: itemCount
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* 生成当前方案ID存储键名
|
|
287
|
+
*/
|
|
288
|
+
}, {
|
|
289
|
+
key: "getCurrentSchemeKey",
|
|
290
|
+
value: function getCurrentSchemeKey(gridId) {
|
|
291
|
+
return "".concat(_constants.STORAGE_PREFIX, "-").concat(gridId).concat(_constants.CURRENT_SCHEME_SUFFIX);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* 获取当前激活的方案ID
|
|
296
|
+
*/
|
|
297
|
+
}, {
|
|
298
|
+
key: "getCurrentSchemeId",
|
|
299
|
+
value: (function () {
|
|
300
|
+
var _getCurrentSchemeId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(gridId) {
|
|
301
|
+
var key, schemeId;
|
|
302
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
303
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
304
|
+
case 0:
|
|
305
|
+
_context5.prev = 0;
|
|
306
|
+
key = this.getCurrentSchemeKey(gridId);
|
|
307
|
+
schemeId = localStorage.getItem(key);
|
|
308
|
+
return _context5.abrupt("return", schemeId || null);
|
|
309
|
+
case 6:
|
|
310
|
+
_context5.prev = 6;
|
|
311
|
+
_context5.t0 = _context5["catch"](0);
|
|
312
|
+
console.error('[SchemeManager] 获取当前方案ID失败:', _context5.t0);
|
|
313
|
+
return _context5.abrupt("return", null);
|
|
314
|
+
case 10:
|
|
315
|
+
case "end":
|
|
316
|
+
return _context5.stop();
|
|
317
|
+
}
|
|
318
|
+
}, _callee5, this, [[0, 6]]);
|
|
319
|
+
}));
|
|
320
|
+
function getCurrentSchemeId(_x6) {
|
|
321
|
+
return _getCurrentSchemeId.apply(this, arguments);
|
|
322
|
+
}
|
|
323
|
+
return getCurrentSchemeId;
|
|
324
|
+
}()
|
|
325
|
+
/**
|
|
326
|
+
* 保存当前激活的方案ID
|
|
327
|
+
*/
|
|
328
|
+
)
|
|
329
|
+
}, {
|
|
330
|
+
key: "saveCurrentSchemeId",
|
|
331
|
+
value: (function () {
|
|
332
|
+
var _saveCurrentSchemeId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(gridId, schemeId) {
|
|
333
|
+
var key;
|
|
334
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
335
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
336
|
+
case 0:
|
|
337
|
+
_context6.prev = 0;
|
|
338
|
+
key = this.getCurrentSchemeKey(gridId);
|
|
339
|
+
if (schemeId === null) {
|
|
340
|
+
localStorage.removeItem(key);
|
|
341
|
+
} else {
|
|
342
|
+
localStorage.setItem(key, schemeId);
|
|
343
|
+
}
|
|
344
|
+
_context6.next = 9;
|
|
345
|
+
break;
|
|
346
|
+
case 5:
|
|
347
|
+
_context6.prev = 5;
|
|
348
|
+
_context6.t0 = _context6["catch"](0);
|
|
349
|
+
console.error('[SchemeManager] 保存当前方案ID失败:', _context6.t0);
|
|
350
|
+
throw _context6.t0;
|
|
351
|
+
case 9:
|
|
352
|
+
case "end":
|
|
353
|
+
return _context6.stop();
|
|
354
|
+
}
|
|
355
|
+
}, _callee6, this, [[0, 5]]);
|
|
356
|
+
}));
|
|
357
|
+
function saveCurrentSchemeId(_x7, _x8) {
|
|
358
|
+
return _saveCurrentSchemeId.apply(this, arguments);
|
|
359
|
+
}
|
|
360
|
+
return saveCurrentSchemeId;
|
|
361
|
+
}())
|
|
362
|
+
}]);
|
|
363
|
+
return LocalStorageAdapter;
|
|
364
|
+
}();
|
|
365
|
+
/**
|
|
366
|
+
* 导出默认实例
|
|
367
|
+
*/
|
|
368
|
+
var defaultStorageAdapter = exports.defaultStorageAdapter = new LocalStorageAdapter();
|