This commit is contained in:
Zyronon
2025-11-18 00:56:50 +08:00
parent b4cf3b3c62
commit d9340f8e04
2 changed files with 12 additions and 13 deletions

View File

@@ -35,6 +35,12 @@
let dbReadyPromise = null;
let name = 'keyval-store';
let keys = [
'type-words-app-version',
'typing-word-dict',
'typing-word-setting',
'typing-word-files'
]
function openDB(dbName, keys) {
if (dbReadyPromise) return dbReadyPromise;
@@ -59,7 +65,7 @@
return dbReadyPromise;
}
openDB(name)
openDB(name, keys)
// --- localStorage 读取 ---
function readLocalStorageKeys(keys) {
@@ -71,12 +77,7 @@
}
// --- IndexedDB兼容 idb-keyval读取 ---
function readIndexedDBCompatible(dbName, keys = [
'type-words-app-version',
'typing-word-dict',
'typing-word-setting',
'typing-word-files'
]) {
function readIndexedDBCompatible(dbName, keys) {
return new Promise(async (resolve) => {
const db = await openDB(dbName, keys);
const stores = Array.from(db.objectStoreNames);