@vxe-ui/core 4.5.0 → 4.5.1
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/all.esm.js +248 -17
- package/dist/all.esm.min.js +1 -0
- package/es/index.d.ts +3 -0
- package/es/index.esm.js +3 -0
- package/es/index.js +3 -0
- package/es/src/core.js +1 -1
- package/es/src/db-utils.d.ts +2 -0
- package/es/src/db-utils.js +234 -0
- package/es/src/log.js +1 -1
- package/lib/index.common.js +3 -0
- package/lib/index.js +3 -0
- package/lib/index.umd.js +248 -17
- package/lib/index.umd.min.js +1 -1
- package/lib/src/core.js +1 -1
- package/lib/src/db-utils.js +263 -0
- package/lib/src/log.js +1 -1
- package/package.json +1 -1
- package/packages/index.ts +3 -0
- package/packages/src/db-utils.ts +267 -0
- package/types/core/db-utils.d.ts +44 -0
- package/types/core/global-config.d.ts +4 -5
- package/types/core/index.d.ts +7 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import XEUtils from "xe-utils";
|
|
5
|
+
import { globalConfigStore } from "./configStore";
|
|
6
|
+
class IdbStore {
|
|
7
|
+
constructor(key, version) {
|
|
8
|
+
__publicField(this, "storeName", "Storage");
|
|
9
|
+
__publicField(this, "key");
|
|
10
|
+
__publicField(this, "version");
|
|
11
|
+
__publicField(this, "dbPromise", null);
|
|
12
|
+
__publicField(this, "dbName", "");
|
|
13
|
+
this.key = key;
|
|
14
|
+
this.version = version;
|
|
15
|
+
}
|
|
16
|
+
getDBName() {
|
|
17
|
+
return `${this.key}_${this.version}`;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 重置连接缓存,下次调用 openDB 会重新建立连接
|
|
21
|
+
*/
|
|
22
|
+
resetDB() {
|
|
23
|
+
this.dbPromise = null;
|
|
24
|
+
this.dbName = "";
|
|
25
|
+
}
|
|
26
|
+
openDB() {
|
|
27
|
+
const name = this.getDBName();
|
|
28
|
+
if (this.dbPromise && this.dbName === name) {
|
|
29
|
+
return this.dbPromise;
|
|
30
|
+
}
|
|
31
|
+
this.dbName = name;
|
|
32
|
+
this.dbPromise = new Promise((resolve, reject) => {
|
|
33
|
+
const request = indexedDB.open(name, 1);
|
|
34
|
+
request.onupgradeneeded = () => {
|
|
35
|
+
const db = request.result;
|
|
36
|
+
if (!db.objectStoreNames.contains(this.storeName)) {
|
|
37
|
+
db.createObjectStore(this.storeName, { keyPath: "id" });
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
request.onsuccess = () => {
|
|
41
|
+
const db = request.result;
|
|
42
|
+
db.onversionchange = () => {
|
|
43
|
+
db.close();
|
|
44
|
+
this.resetDB();
|
|
45
|
+
};
|
|
46
|
+
db.onclose = () => {
|
|
47
|
+
this.resetDB();
|
|
48
|
+
};
|
|
49
|
+
resolve(db);
|
|
50
|
+
};
|
|
51
|
+
request.onerror = () => {
|
|
52
|
+
reject(request.error || new Error(`IdbStore open failed: ${name}`));
|
|
53
|
+
};
|
|
54
|
+
request.onblocked = () => {
|
|
55
|
+
console.warn(`[IdbStore] open blocked: ${name}`);
|
|
56
|
+
};
|
|
57
|
+
}).catch((err) => {
|
|
58
|
+
this.resetDB();
|
|
59
|
+
throw err;
|
|
60
|
+
});
|
|
61
|
+
return this.dbPromise;
|
|
62
|
+
}
|
|
63
|
+
getById(id) {
|
|
64
|
+
return this.openDB().then(
|
|
65
|
+
(db) => new Promise((resolve, reject) => {
|
|
66
|
+
const req = db.transaction(this.storeName, "readonly").objectStore(this.storeName).get(id);
|
|
67
|
+
req.onsuccess = () => resolve(req.result);
|
|
68
|
+
req.onerror = () => reject(req.error);
|
|
69
|
+
})
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
getAll() {
|
|
73
|
+
return this.openDB().then(
|
|
74
|
+
(db) => new Promise((resolve, reject) => {
|
|
75
|
+
const store = db.transaction(this.storeName, "readonly").objectStore(this.storeName);
|
|
76
|
+
if (XEUtils.isFunction(store.getAll)) {
|
|
77
|
+
const req2 = store.getAll();
|
|
78
|
+
req2.onsuccess = () => resolve(req2.result || []);
|
|
79
|
+
req2.onerror = () => reject(req2.error);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const list = [];
|
|
83
|
+
const req = store.openCursor();
|
|
84
|
+
req.onsuccess = () => {
|
|
85
|
+
const cursor = req.result;
|
|
86
|
+
if (cursor) {
|
|
87
|
+
list.push(cursor.value);
|
|
88
|
+
cursor.continue();
|
|
89
|
+
} else {
|
|
90
|
+
resolve(list);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
req.onerror = () => reject(req.error);
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
updateById(id, data) {
|
|
98
|
+
if (data == null) {
|
|
99
|
+
return this.deleteById(id);
|
|
100
|
+
}
|
|
101
|
+
return this.openDB().then(
|
|
102
|
+
(db) => new Promise((resolve, reject) => {
|
|
103
|
+
const tx = db.transaction(this.storeName, "readwrite");
|
|
104
|
+
tx.objectStore(this.storeName).put({ id, data });
|
|
105
|
+
tx.oncomplete = () => resolve();
|
|
106
|
+
tx.onerror = () => reject(tx.error);
|
|
107
|
+
})
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
deleteById(id) {
|
|
111
|
+
return this.openDB().then(
|
|
112
|
+
(db) => new Promise((resolve, reject) => {
|
|
113
|
+
const tx = db.transaction(this.storeName, "readwrite");
|
|
114
|
+
tx.objectStore(this.storeName).delete(id);
|
|
115
|
+
tx.oncomplete = () => resolve();
|
|
116
|
+
tx.onerror = () => reject(tx.error);
|
|
117
|
+
})
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* 清空当前库的数据
|
|
122
|
+
*/
|
|
123
|
+
clear() {
|
|
124
|
+
return this.openDB().then(
|
|
125
|
+
(db) => new Promise((resolve, reject) => {
|
|
126
|
+
const tx = db.transaction(this.storeName, "readwrite");
|
|
127
|
+
tx.objectStore(this.storeName).clear();
|
|
128
|
+
tx.oncomplete = () => resolve();
|
|
129
|
+
tx.onerror = () => reject(tx.error);
|
|
130
|
+
})
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* 清理非当前版本的旧库
|
|
135
|
+
*/
|
|
136
|
+
cleanupOldDBs() {
|
|
137
|
+
if (!indexedDB.databases) {
|
|
138
|
+
return Promise.resolve();
|
|
139
|
+
}
|
|
140
|
+
const current = this.getDBName();
|
|
141
|
+
const prefix = `${this.key}_`;
|
|
142
|
+
return indexedDB.databases().then((dbs) => {
|
|
143
|
+
dbs.forEach((db) => {
|
|
144
|
+
const n = db.name;
|
|
145
|
+
if (!n || n === current || !n.startsWith(prefix)) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const rest = n.slice(prefix.length);
|
|
149
|
+
if (!rest.includes("_")) {
|
|
150
|
+
indexedDB.deleteDatabase(n);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
class LocalStorageStore {
|
|
157
|
+
constructor(key, version) {
|
|
158
|
+
__publicField(this, "key");
|
|
159
|
+
__publicField(this, "version");
|
|
160
|
+
this.key = key;
|
|
161
|
+
this.version = version;
|
|
162
|
+
}
|
|
163
|
+
readAll() {
|
|
164
|
+
const storageData = XEUtils.toStringJSON(localStorage.getItem(this.key) || "");
|
|
165
|
+
return storageData && String(storageData._v) === String(this.version) ? storageData : { _v: this.version };
|
|
166
|
+
}
|
|
167
|
+
writeAll(map) {
|
|
168
|
+
localStorage.setItem(this.key, XEUtils.toJSONString(map));
|
|
169
|
+
}
|
|
170
|
+
getById(id) {
|
|
171
|
+
const map = this.readAll();
|
|
172
|
+
const has = Object.prototype.hasOwnProperty.call(map, id);
|
|
173
|
+
return Promise.resolve(has && map[id] != null ? { id, data: map[id] } : void 0);
|
|
174
|
+
}
|
|
175
|
+
getAll() {
|
|
176
|
+
const map = this.readAll();
|
|
177
|
+
const list = [];
|
|
178
|
+
Object.keys(map).forEach((k) => {
|
|
179
|
+
if (k !== "_v" && map[k] != null) {
|
|
180
|
+
list.push({ id: k, data: map[k] });
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
return Promise.resolve(list);
|
|
184
|
+
}
|
|
185
|
+
updateById(id, data) {
|
|
186
|
+
if (data == null) {
|
|
187
|
+
return this.deleteById(id);
|
|
188
|
+
}
|
|
189
|
+
const map = this.readAll();
|
|
190
|
+
map[id] = data;
|
|
191
|
+
this.writeAll(map);
|
|
192
|
+
return Promise.resolve();
|
|
193
|
+
}
|
|
194
|
+
deleteById(id) {
|
|
195
|
+
const map = this.readAll();
|
|
196
|
+
delete map[id];
|
|
197
|
+
this.writeAll(map);
|
|
198
|
+
return Promise.resolve();
|
|
199
|
+
}
|
|
200
|
+
clear() {
|
|
201
|
+
this.writeAll({ _v: this.version });
|
|
202
|
+
return Promise.resolve();
|
|
203
|
+
}
|
|
204
|
+
cleanupOldDBs() {
|
|
205
|
+
const raw = localStorage.getItem(this.key);
|
|
206
|
+
if (!raw) {
|
|
207
|
+
return Promise.resolve();
|
|
208
|
+
}
|
|
209
|
+
const storageData = XEUtils.toStringJSON(raw);
|
|
210
|
+
if (!storageData || String(storageData._v) !== String(this.version)) {
|
|
211
|
+
localStorage.removeItem(this.key);
|
|
212
|
+
}
|
|
213
|
+
return Promise.resolve();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const dbUtils = {
|
|
217
|
+
/**
|
|
218
|
+
* 创建存储实例
|
|
219
|
+
* - driver = 'indexedDB' 且环境支持 => IdbStore
|
|
220
|
+
* - 其余情况(未传 / 不支持)=> LocalStorageStore
|
|
221
|
+
*/
|
|
222
|
+
createStore(key, options) {
|
|
223
|
+
const opts = Object.assign({}, options);
|
|
224
|
+
const version = opts.version || globalConfigStore.version || 0;
|
|
225
|
+
const driver = opts.driver;
|
|
226
|
+
if ((!driver || driver === "indexedDB") && typeof indexedDB !== "undefined") {
|
|
227
|
+
return new IdbStore(key, version);
|
|
228
|
+
}
|
|
229
|
+
return new LocalStorageStore(key, version);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
export {
|
|
233
|
+
dbUtils
|
|
234
|
+
};
|
package/es/src/log.js
CHANGED
package/lib/index.common.js
CHANGED
|
@@ -58,6 +58,7 @@ var import_clipboard = require("./src/clipboard");
|
|
|
58
58
|
var import_permission = require("./src/permission");
|
|
59
59
|
var import_z_index = require("./src/z-index");
|
|
60
60
|
var import_base_utils = require("./src/base-utils");
|
|
61
|
+
var import_db_utils = require("./src/db-utils");
|
|
61
62
|
var import_dom_utils = require("./src/dom-utils");
|
|
62
63
|
var import_scrollbar_utils = require("./src/scrollbar-utils");
|
|
63
64
|
var import_popper_utils = require("./src/popper-utils");
|
|
@@ -83,6 +84,7 @@ __reExport(index_exports, require("./src/clipboard"), module.exports);
|
|
|
83
84
|
__reExport(index_exports, require("./src/permission"), module.exports);
|
|
84
85
|
__reExport(index_exports, require("./src/z-index"), module.exports);
|
|
85
86
|
__reExport(index_exports, require("./src/base-utils"), module.exports);
|
|
87
|
+
__reExport(index_exports, require("./src/db-utils"), module.exports);
|
|
86
88
|
__reExport(index_exports, require("./src/dom-utils"), module.exports);
|
|
87
89
|
__reExport(index_exports, require("./src/scrollbar-utils"), module.exports);
|
|
88
90
|
__reExport(index_exports, require("./src/popper-utils"), module.exports);
|
|
@@ -161,6 +163,7 @@ const VxeUI = Object.assign(import_core.VxeCore, {
|
|
|
161
163
|
permission: import_permission.permission,
|
|
162
164
|
zIndex: import_z_index.zIndex,
|
|
163
165
|
baseUtils: import_base_utils.baseUtils,
|
|
166
|
+
dbUtils: import_db_utils.dbUtils,
|
|
164
167
|
domUtils: import_dom_utils.domUtils,
|
|
165
168
|
scrollbarUtils: import_scrollbar_utils.scrollbarUtils,
|
|
166
169
|
popperUtils: import_popper_utils.popperUtils,
|
package/lib/index.js
CHANGED
|
@@ -58,6 +58,7 @@ var import_clipboard = require("./src/clipboard");
|
|
|
58
58
|
var import_permission = require("./src/permission");
|
|
59
59
|
var import_z_index = require("./src/z-index");
|
|
60
60
|
var import_base_utils = require("./src/base-utils");
|
|
61
|
+
var import_db_utils = require("./src/db-utils");
|
|
61
62
|
var import_dom_utils = require("./src/dom-utils");
|
|
62
63
|
var import_scrollbar_utils = require("./src/scrollbar-utils");
|
|
63
64
|
var import_popper_utils = require("./src/popper-utils");
|
|
@@ -83,6 +84,7 @@ __reExport(index_exports, require("./src/clipboard"), module.exports);
|
|
|
83
84
|
__reExport(index_exports, require("./src/permission"), module.exports);
|
|
84
85
|
__reExport(index_exports, require("./src/z-index"), module.exports);
|
|
85
86
|
__reExport(index_exports, require("./src/base-utils"), module.exports);
|
|
87
|
+
__reExport(index_exports, require("./src/db-utils"), module.exports);
|
|
86
88
|
__reExport(index_exports, require("./src/dom-utils"), module.exports);
|
|
87
89
|
__reExport(index_exports, require("./src/scrollbar-utils"), module.exports);
|
|
88
90
|
__reExport(index_exports, require("./src/popper-utils"), module.exports);
|
|
@@ -161,6 +163,7 @@ const VxeUI = Object.assign(import_core.VxeCore, {
|
|
|
161
163
|
permission: import_permission.permission,
|
|
162
164
|
zIndex: import_z_index.zIndex,
|
|
163
165
|
baseUtils: import_base_utils.baseUtils,
|
|
166
|
+
dbUtils: import_db_utils.dbUtils,
|
|
164
167
|
domUtils: import_dom_utils.domUtils,
|
|
165
168
|
scrollbarUtils: import_scrollbar_utils.scrollbarUtils,
|
|
166
169
|
popperUtils: import_popper_utils.popperUtils,
|
package/lib/index.umd.js
CHANGED
|
@@ -67,6 +67,7 @@ __export(index_exports, {
|
|
|
67
67
|
component: () => component,
|
|
68
68
|
coreVersion: () => coreVersion,
|
|
69
69
|
createEvent: () => createEvent,
|
|
70
|
+
dbUtils: () => dbUtils,
|
|
70
71
|
default: () => index_default,
|
|
71
72
|
domUtils: () => domUtils,
|
|
72
73
|
formats: () => formats,
|
|
@@ -111,7 +112,7 @@ __export(index_exports, {
|
|
|
111
112
|
module.exports = __toCommonJS(index_exports);
|
|
112
113
|
|
|
113
114
|
// packages_temp/src/core.ts
|
|
114
|
-
var coreVersion = "4.5.
|
|
115
|
+
var coreVersion = "4.5.1";
|
|
115
116
|
var VxeCore = {
|
|
116
117
|
coreVersion,
|
|
117
118
|
uiVersion: "",
|
|
@@ -655,7 +656,7 @@ function createLog(type, name) {
|
|
|
655
656
|
return msg;
|
|
656
657
|
};
|
|
657
658
|
}
|
|
658
|
-
var version = "4.5.
|
|
659
|
+
var version = "4.5.1";
|
|
659
660
|
var log = {
|
|
660
661
|
create: createLog,
|
|
661
662
|
warn: createLog("warn", `v${version}`),
|
|
@@ -1110,8 +1111,237 @@ var baseUtils = {
|
|
|
1110
1111
|
}
|
|
1111
1112
|
};
|
|
1112
1113
|
|
|
1113
|
-
// packages_temp/src/
|
|
1114
|
+
// packages_temp/src/db-utils.ts
|
|
1114
1115
|
var import_xe_utils16 = __toESM(require("xe-utils"));
|
|
1116
|
+
var IdbStore = class {
|
|
1117
|
+
constructor(key, version2) {
|
|
1118
|
+
__publicField(this, "storeName", "Storage");
|
|
1119
|
+
__publicField(this, "key");
|
|
1120
|
+
__publicField(this, "version");
|
|
1121
|
+
__publicField(this, "dbPromise", null);
|
|
1122
|
+
__publicField(this, "dbName", "");
|
|
1123
|
+
this.key = key;
|
|
1124
|
+
this.version = version2;
|
|
1125
|
+
}
|
|
1126
|
+
getDBName() {
|
|
1127
|
+
return `${this.key}_${this.version}`;
|
|
1128
|
+
}
|
|
1129
|
+
/**
|
|
1130
|
+
* 重置连接缓存,下次调用 openDB 会重新建立连接
|
|
1131
|
+
*/
|
|
1132
|
+
resetDB() {
|
|
1133
|
+
this.dbPromise = null;
|
|
1134
|
+
this.dbName = "";
|
|
1135
|
+
}
|
|
1136
|
+
openDB() {
|
|
1137
|
+
const name = this.getDBName();
|
|
1138
|
+
if (this.dbPromise && this.dbName === name) {
|
|
1139
|
+
return this.dbPromise;
|
|
1140
|
+
}
|
|
1141
|
+
this.dbName = name;
|
|
1142
|
+
this.dbPromise = new Promise((resolve, reject) => {
|
|
1143
|
+
const request = indexedDB.open(name, 1);
|
|
1144
|
+
request.onupgradeneeded = () => {
|
|
1145
|
+
const db = request.result;
|
|
1146
|
+
if (!db.objectStoreNames.contains(this.storeName)) {
|
|
1147
|
+
db.createObjectStore(this.storeName, { keyPath: "id" });
|
|
1148
|
+
}
|
|
1149
|
+
};
|
|
1150
|
+
request.onsuccess = () => {
|
|
1151
|
+
const db = request.result;
|
|
1152
|
+
db.onversionchange = () => {
|
|
1153
|
+
db.close();
|
|
1154
|
+
this.resetDB();
|
|
1155
|
+
};
|
|
1156
|
+
db.onclose = () => {
|
|
1157
|
+
this.resetDB();
|
|
1158
|
+
};
|
|
1159
|
+
resolve(db);
|
|
1160
|
+
};
|
|
1161
|
+
request.onerror = () => {
|
|
1162
|
+
reject(request.error || new Error(`IdbStore open failed: ${name}`));
|
|
1163
|
+
};
|
|
1164
|
+
request.onblocked = () => {
|
|
1165
|
+
console.warn(`[IdbStore] open blocked: ${name}`);
|
|
1166
|
+
};
|
|
1167
|
+
}).catch((err) => {
|
|
1168
|
+
this.resetDB();
|
|
1169
|
+
throw err;
|
|
1170
|
+
});
|
|
1171
|
+
return this.dbPromise;
|
|
1172
|
+
}
|
|
1173
|
+
getById(id) {
|
|
1174
|
+
return this.openDB().then(
|
|
1175
|
+
(db) => new Promise((resolve, reject) => {
|
|
1176
|
+
const req = db.transaction(this.storeName, "readonly").objectStore(this.storeName).get(id);
|
|
1177
|
+
req.onsuccess = () => resolve(req.result);
|
|
1178
|
+
req.onerror = () => reject(req.error);
|
|
1179
|
+
})
|
|
1180
|
+
);
|
|
1181
|
+
}
|
|
1182
|
+
getAll() {
|
|
1183
|
+
return this.openDB().then(
|
|
1184
|
+
(db) => new Promise((resolve, reject) => {
|
|
1185
|
+
const store = db.transaction(this.storeName, "readonly").objectStore(this.storeName);
|
|
1186
|
+
if (import_xe_utils16.default.isFunction(store.getAll)) {
|
|
1187
|
+
const req2 = store.getAll();
|
|
1188
|
+
req2.onsuccess = () => resolve(req2.result || []);
|
|
1189
|
+
req2.onerror = () => reject(req2.error);
|
|
1190
|
+
return;
|
|
1191
|
+
}
|
|
1192
|
+
const list = [];
|
|
1193
|
+
const req = store.openCursor();
|
|
1194
|
+
req.onsuccess = () => {
|
|
1195
|
+
const cursor = req.result;
|
|
1196
|
+
if (cursor) {
|
|
1197
|
+
list.push(cursor.value);
|
|
1198
|
+
cursor.continue();
|
|
1199
|
+
} else {
|
|
1200
|
+
resolve(list);
|
|
1201
|
+
}
|
|
1202
|
+
};
|
|
1203
|
+
req.onerror = () => reject(req.error);
|
|
1204
|
+
})
|
|
1205
|
+
);
|
|
1206
|
+
}
|
|
1207
|
+
updateById(id, data) {
|
|
1208
|
+
if (data == null) {
|
|
1209
|
+
return this.deleteById(id);
|
|
1210
|
+
}
|
|
1211
|
+
return this.openDB().then(
|
|
1212
|
+
(db) => new Promise((resolve, reject) => {
|
|
1213
|
+
const tx = db.transaction(this.storeName, "readwrite");
|
|
1214
|
+
tx.objectStore(this.storeName).put({ id, data });
|
|
1215
|
+
tx.oncomplete = () => resolve();
|
|
1216
|
+
tx.onerror = () => reject(tx.error);
|
|
1217
|
+
})
|
|
1218
|
+
);
|
|
1219
|
+
}
|
|
1220
|
+
deleteById(id) {
|
|
1221
|
+
return this.openDB().then(
|
|
1222
|
+
(db) => new Promise((resolve, reject) => {
|
|
1223
|
+
const tx = db.transaction(this.storeName, "readwrite");
|
|
1224
|
+
tx.objectStore(this.storeName).delete(id);
|
|
1225
|
+
tx.oncomplete = () => resolve();
|
|
1226
|
+
tx.onerror = () => reject(tx.error);
|
|
1227
|
+
})
|
|
1228
|
+
);
|
|
1229
|
+
}
|
|
1230
|
+
/**
|
|
1231
|
+
* 清空当前库的数据
|
|
1232
|
+
*/
|
|
1233
|
+
clear() {
|
|
1234
|
+
return this.openDB().then(
|
|
1235
|
+
(db) => new Promise((resolve, reject) => {
|
|
1236
|
+
const tx = db.transaction(this.storeName, "readwrite");
|
|
1237
|
+
tx.objectStore(this.storeName).clear();
|
|
1238
|
+
tx.oncomplete = () => resolve();
|
|
1239
|
+
tx.onerror = () => reject(tx.error);
|
|
1240
|
+
})
|
|
1241
|
+
);
|
|
1242
|
+
}
|
|
1243
|
+
/**
|
|
1244
|
+
* 清理非当前版本的旧库
|
|
1245
|
+
*/
|
|
1246
|
+
cleanupOldDBs() {
|
|
1247
|
+
if (!indexedDB.databases) {
|
|
1248
|
+
return Promise.resolve();
|
|
1249
|
+
}
|
|
1250
|
+
const current = this.getDBName();
|
|
1251
|
+
const prefix = `${this.key}_`;
|
|
1252
|
+
return indexedDB.databases().then((dbs) => {
|
|
1253
|
+
dbs.forEach((db) => {
|
|
1254
|
+
const n = db.name;
|
|
1255
|
+
if (!n || n === current || !n.startsWith(prefix)) {
|
|
1256
|
+
return;
|
|
1257
|
+
}
|
|
1258
|
+
const rest = n.slice(prefix.length);
|
|
1259
|
+
if (!rest.includes("_")) {
|
|
1260
|
+
indexedDB.deleteDatabase(n);
|
|
1261
|
+
}
|
|
1262
|
+
});
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
};
|
|
1266
|
+
var LocalStorageStore = class {
|
|
1267
|
+
constructor(key, version2) {
|
|
1268
|
+
__publicField(this, "key");
|
|
1269
|
+
__publicField(this, "version");
|
|
1270
|
+
this.key = key;
|
|
1271
|
+
this.version = version2;
|
|
1272
|
+
}
|
|
1273
|
+
readAll() {
|
|
1274
|
+
const storageData = import_xe_utils16.default.toStringJSON(localStorage.getItem(this.key) || "");
|
|
1275
|
+
return storageData && String(storageData._v) === String(this.version) ? storageData : { _v: this.version };
|
|
1276
|
+
}
|
|
1277
|
+
writeAll(map) {
|
|
1278
|
+
localStorage.setItem(this.key, import_xe_utils16.default.toJSONString(map));
|
|
1279
|
+
}
|
|
1280
|
+
getById(id) {
|
|
1281
|
+
const map = this.readAll();
|
|
1282
|
+
const has = Object.prototype.hasOwnProperty.call(map, id);
|
|
1283
|
+
return Promise.resolve(has && map[id] != null ? { id, data: map[id] } : void 0);
|
|
1284
|
+
}
|
|
1285
|
+
getAll() {
|
|
1286
|
+
const map = this.readAll();
|
|
1287
|
+
const list = [];
|
|
1288
|
+
Object.keys(map).forEach((k) => {
|
|
1289
|
+
if (k !== "_v" && map[k] != null) {
|
|
1290
|
+
list.push({ id: k, data: map[k] });
|
|
1291
|
+
}
|
|
1292
|
+
});
|
|
1293
|
+
return Promise.resolve(list);
|
|
1294
|
+
}
|
|
1295
|
+
updateById(id, data) {
|
|
1296
|
+
if (data == null) {
|
|
1297
|
+
return this.deleteById(id);
|
|
1298
|
+
}
|
|
1299
|
+
const map = this.readAll();
|
|
1300
|
+
map[id] = data;
|
|
1301
|
+
this.writeAll(map);
|
|
1302
|
+
return Promise.resolve();
|
|
1303
|
+
}
|
|
1304
|
+
deleteById(id) {
|
|
1305
|
+
const map = this.readAll();
|
|
1306
|
+
delete map[id];
|
|
1307
|
+
this.writeAll(map);
|
|
1308
|
+
return Promise.resolve();
|
|
1309
|
+
}
|
|
1310
|
+
clear() {
|
|
1311
|
+
this.writeAll({ _v: this.version });
|
|
1312
|
+
return Promise.resolve();
|
|
1313
|
+
}
|
|
1314
|
+
cleanupOldDBs() {
|
|
1315
|
+
const raw = localStorage.getItem(this.key);
|
|
1316
|
+
if (!raw) {
|
|
1317
|
+
return Promise.resolve();
|
|
1318
|
+
}
|
|
1319
|
+
const storageData = import_xe_utils16.default.toStringJSON(raw);
|
|
1320
|
+
if (!storageData || String(storageData._v) !== String(this.version)) {
|
|
1321
|
+
localStorage.removeItem(this.key);
|
|
1322
|
+
}
|
|
1323
|
+
return Promise.resolve();
|
|
1324
|
+
}
|
|
1325
|
+
};
|
|
1326
|
+
var dbUtils = {
|
|
1327
|
+
/**
|
|
1328
|
+
* 创建存储实例
|
|
1329
|
+
* - driver = 'indexedDB' 且环境支持 => IdbStore
|
|
1330
|
+
* - 其余情况(未传 / 不支持)=> LocalStorageStore
|
|
1331
|
+
*/
|
|
1332
|
+
createStore(key, options) {
|
|
1333
|
+
const opts = Object.assign({}, options);
|
|
1334
|
+
const version2 = opts.version || globalConfigStore.version || 0;
|
|
1335
|
+
const driver = opts.driver;
|
|
1336
|
+
if ((!driver || driver === "indexedDB") && typeof indexedDB !== "undefined") {
|
|
1337
|
+
return new IdbStore(key, version2);
|
|
1338
|
+
}
|
|
1339
|
+
return new LocalStorageStore(key, version2);
|
|
1340
|
+
}
|
|
1341
|
+
};
|
|
1342
|
+
|
|
1343
|
+
// packages_temp/src/dom-utils.ts
|
|
1344
|
+
var import_xe_utils17 = __toESM(require("xe-utils"));
|
|
1115
1345
|
var reClsMap = {};
|
|
1116
1346
|
function getClsRE(cls) {
|
|
1117
1347
|
if (!reClsMap[cls]) {
|
|
@@ -1176,7 +1406,7 @@ var domUtils = {
|
|
|
1176
1406
|
}
|
|
1177
1407
|
}
|
|
1178
1408
|
}
|
|
1179
|
-
|
|
1409
|
+
import_xe_utils17.default.each(mapClassName, (val, key) => {
|
|
1180
1410
|
if (val) {
|
|
1181
1411
|
parts.push(key);
|
|
1182
1412
|
}
|
|
@@ -1244,7 +1474,7 @@ var scrollbarUtils = {
|
|
|
1244
1474
|
};
|
|
1245
1475
|
|
|
1246
1476
|
// packages_temp/src/popper-utils.ts
|
|
1247
|
-
var
|
|
1477
|
+
var import_xe_utils18 = __toESM(require("xe-utils"));
|
|
1248
1478
|
function getWrapperElement(panelElem) {
|
|
1249
1479
|
if (!panelElem) {
|
|
1250
1480
|
return null;
|
|
@@ -1254,12 +1484,12 @@ function getWrapperElement(panelElem) {
|
|
|
1254
1484
|
return (parentEl === bodyEl2 ? document.documentElement : parentEl) || null;
|
|
1255
1485
|
}
|
|
1256
1486
|
function getAppendSelector(appendTo) {
|
|
1257
|
-
const selectElem = appendTo &&
|
|
1487
|
+
const selectElem = appendTo && import_xe_utils18.default.isFunction(appendTo) ? appendTo({}) : appendTo;
|
|
1258
1488
|
return selectElem || "body";
|
|
1259
1489
|
}
|
|
1260
1490
|
function getAppendElement(appendTo) {
|
|
1261
1491
|
const selectElem = getAppendSelector(appendTo);
|
|
1262
|
-
if (
|
|
1492
|
+
if (import_xe_utils18.default.isString(selectElem)) {
|
|
1263
1493
|
return document.querySelector(selectElem) || document.body;
|
|
1264
1494
|
}
|
|
1265
1495
|
return selectElem;
|
|
@@ -1362,16 +1592,16 @@ var popperUtils = {
|
|
|
1362
1592
|
left = -(panelRect.left + panelRect.width + marginSize - visibleWidth);
|
|
1363
1593
|
}
|
|
1364
1594
|
}
|
|
1365
|
-
if (
|
|
1595
|
+
if (import_xe_utils18.default.isNumber(top)) {
|
|
1366
1596
|
stys.top = top + "px";
|
|
1367
1597
|
}
|
|
1368
|
-
if (
|
|
1598
|
+
if (import_xe_utils18.default.isNumber(bottom)) {
|
|
1369
1599
|
stys.bottom = bottom + "px";
|
|
1370
1600
|
}
|
|
1371
|
-
if (
|
|
1601
|
+
if (import_xe_utils18.default.isNumber(left)) {
|
|
1372
1602
|
stys.left = left + "px";
|
|
1373
1603
|
}
|
|
1374
|
-
if (isMinWidth &&
|
|
1604
|
+
if (isMinWidth && import_xe_utils18.default.isNumber(minWidth)) {
|
|
1375
1605
|
stys.minWidth = minWidth + "px";
|
|
1376
1606
|
}
|
|
1377
1607
|
if (left === targetLeft) {
|
|
@@ -1414,7 +1644,7 @@ var popperUtils = {
|
|
|
1414
1644
|
var hooks = new store_default();
|
|
1415
1645
|
|
|
1416
1646
|
// packages_temp/src/useFns.ts
|
|
1417
|
-
var
|
|
1647
|
+
var import_xe_utils19 = __toESM(require("xe-utils"));
|
|
1418
1648
|
var import_vue3 = require("vue");
|
|
1419
1649
|
var { getThumbOffsetSize, getThumbSize, getScrollFromClick, getScrollFromDrag } = scrollbarUtils;
|
|
1420
1650
|
function useSize(props) {
|
|
@@ -1438,7 +1668,7 @@ function useVScrollbar(props) {
|
|
|
1438
1668
|
const xeScrollbarInfo = (0, import_vue3.inject)("xeScrollbarInfo", null);
|
|
1439
1669
|
const computeIsVScrollbar = (0, import_vue3.computed)(() => {
|
|
1440
1670
|
const { useScrollbar } = props;
|
|
1441
|
-
return
|
|
1671
|
+
return import_xe_utils19.default.isBoolean(useScrollbar) ? useScrollbar : xeScrollbarInfo ? xeScrollbarInfo.value : null;
|
|
1442
1672
|
});
|
|
1443
1673
|
(0, import_vue3.provide)("xeScrollbarInfo", computeIsVScrollbar);
|
|
1444
1674
|
return { computeIsVScrollbar };
|
|
@@ -1625,7 +1855,7 @@ var useFns = {
|
|
|
1625
1855
|
};
|
|
1626
1856
|
|
|
1627
1857
|
// packages_temp/index.ts
|
|
1628
|
-
var
|
|
1858
|
+
var import_xe_utils20 = __toESM(require("xe-utils"));
|
|
1629
1859
|
var installedPlugins = [];
|
|
1630
1860
|
function use(Plugin, options) {
|
|
1631
1861
|
if (Plugin && Plugin.install) {
|
|
@@ -1646,7 +1876,7 @@ function hasComponent(name) {
|
|
|
1646
1876
|
function component(comp) {
|
|
1647
1877
|
if (comp && comp.name) {
|
|
1648
1878
|
components[comp.name] = comp;
|
|
1649
|
-
components[
|
|
1879
|
+
components[import_xe_utils20.default.kebabCase(comp.name)] = comp;
|
|
1650
1880
|
}
|
|
1651
1881
|
}
|
|
1652
1882
|
function renderEmptyElement() {
|
|
@@ -1656,9 +1886,9 @@ function checkVersion(version2, pVersion, sVersion) {
|
|
|
1656
1886
|
if (version2) {
|
|
1657
1887
|
const vRest = `${version2}`.match(/(\d+).(\d+).(\d+)/);
|
|
1658
1888
|
if (vRest) {
|
|
1659
|
-
const pV =
|
|
1889
|
+
const pV = import_xe_utils20.default.toNumber(vRest[1]);
|
|
1660
1890
|
if (sVersion) {
|
|
1661
|
-
const sV =
|
|
1891
|
+
const sV = import_xe_utils20.default.toNumber(vRest[2]);
|
|
1662
1892
|
return pV >= pVersion && sV >= sVersion;
|
|
1663
1893
|
}
|
|
1664
1894
|
return pV >= pVersion;
|
|
@@ -1696,6 +1926,7 @@ var VxeUI = Object.assign(VxeCore, {
|
|
|
1696
1926
|
permission,
|
|
1697
1927
|
zIndex,
|
|
1698
1928
|
baseUtils,
|
|
1929
|
+
dbUtils,
|
|
1699
1930
|
domUtils,
|
|
1700
1931
|
scrollbarUtils,
|
|
1701
1932
|
popperUtils,
|