mirror of
https://github.com/blacktunes/sr-ghostly-grove.git
synced 2025-01-07 03:07:03 +08:00
fix: 修复数据库回调异常
This commit is contained in:
parent
7cd7111fbf
commit
ae8e315f14
@ -84,6 +84,7 @@ export class IndexedDB {
|
||||
console.log(`正在加${this.alias}数据库...`)
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
this.cb = () => resolve()
|
||||
try {
|
||||
const _db = window.indexedDB.open(this.name)
|
||||
_db.onsuccess = (event) => {
|
||||
@ -93,14 +94,11 @@ export class IndexedDB {
|
||||
this.db.transaction('data', 'readonly').objectStore('data').get(key).onsuccess = (
|
||||
res
|
||||
) => {
|
||||
try {
|
||||
const data = (res.target as IDBRequest).result
|
||||
if (data) {
|
||||
this.DBList[key].data[this.DBList[key].key] = data
|
||||
}
|
||||
} finally {
|
||||
this.setWatch(key)
|
||||
const data = (res.target as IDBRequest).result
|
||||
if (data) {
|
||||
this.DBList[key].data[this.DBList[key].key] = data
|
||||
}
|
||||
this.setWatch(key)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -109,7 +107,6 @@ export class IndexedDB {
|
||||
this.setWatch(key)
|
||||
}
|
||||
}
|
||||
this.cb = () => resolve()
|
||||
}
|
||||
|
||||
_db.onupgradeneeded = (event) => {
|
||||
|
Loading…
Reference in New Issue
Block a user