DEBUG (离谱
This commit is contained in:
parent
1051fa5669
commit
eea4e71414
@ -48,6 +48,34 @@ export default class IndexedDB {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add(name, data) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const transaction = this.db.transaction([name], 'readwrite')
|
||||||
|
const objectStore = transaction.objectStore(name)
|
||||||
|
const request = objectStore.add(data)
|
||||||
|
request.onerror = (event) => {
|
||||||
|
reject(event.target.error)
|
||||||
|
}
|
||||||
|
request.onsuccess = (event) => {
|
||||||
|
resolve(event.target.result)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
put(name, data) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const transaction = this.db.transaction([name], 'readwrite')
|
||||||
|
const objectStore = transaction.objectStore(name)
|
||||||
|
const request = objectStore.put(data)
|
||||||
|
request.onerror = (event) => {
|
||||||
|
reject(event.target.error)
|
||||||
|
}
|
||||||
|
request.onsuccess = (event) => {
|
||||||
|
resolve(event.target.result)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
delete(name, id) {
|
delete(name, id) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const transaction = this.db.transaction([name], 'readwrite')
|
const transaction = this.db.transaction([name], 'readwrite')
|
||||||
|
@ -69,7 +69,8 @@ const musicList = new MusicList({
|
|||||||
onlike: (item, list) => {
|
onlike: (item, list) => {
|
||||||
console.log('喜欢音乐', item.name)
|
console.log('喜欢音乐', item.name)
|
||||||
if (item.arrayBuffer) {
|
if (item.arrayBuffer) {
|
||||||
musicStore.add(item)
|
//musicStore.add(item)
|
||||||
|
database.add('musicObjectStore', item)
|
||||||
clientList.send('base', JSON.stringify({
|
clientList.send('base', JSON.stringify({
|
||||||
type: 'set_music_list',
|
type: 'set_music_list',
|
||||||
list: list.map(({ id, name, size, type }) => ({ id, name, size, type }))
|
list: list.map(({ id, name, size, type }) => ({ id, name, size, type }))
|
||||||
|
Loading…
Reference in New Issue
Block a user