-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
104 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,27 @@ | ||
const localforage = require("localforage"); | ||
class IDB { | ||
|
||
// 初始化数据库 | ||
constructor(dbName,storeName) { | ||
|
||
if(!window.indexedDB){ | ||
console.log('不支持IndexedDB') | ||
return | ||
constructor(dbName, storeName) { | ||
if (!window.indexedDB) { | ||
console.log("不支持IndexedDB"); | ||
return; | ||
} | ||
|
||
this.dbName = dbName || "jx3box"; | ||
this.storeName = storeName || "posts" | ||
console.log( | ||
'%c[IDB] Use Database - ', | ||
'color:#ff3399;', | ||
`${this.dbName} > ${this.storeName}`, | ||
) | ||
this.storeName = storeName || "posts"; | ||
console.log("%c[IDB] Use Database - ", "color:#ff3399;", `${this.dbName} > ${this.storeName}`); | ||
this.db = localforage.createInstance({ | ||
name: this.dbName, | ||
storeName : this.storeName, | ||
driver : localforage.INDEXEDDB | ||
storeName: this.storeName, | ||
driver: localforage.INDEXEDDB, | ||
}); | ||
return this.db | ||
return this.db; | ||
} | ||
} | ||
|
||
export default IDB | ||
export default IDB; | ||
|
||
// const DB = new IDB(); | ||
// DB.ready().then(() => { | ||
// DB.setItem('key','val') | ||
// }) | ||
// }) |
Oops, something went wrong.