diff --git a/public/index.html b/public/index.html
index 4dd7559..5c3bd73 100644
--- a/public/index.html
+++ b/public/index.html
@@ -36,18 +36,25 @@
onstop: item => {
console.log('停止音乐', item.name)
},
- onlike: item => {
+ onlike: (item, list) => {
console.log('喜欢音乐', item)
if (item.arrayBuffer) {
database.add(item)
- // clientList.send('base', JSON.stringify({
- // type: 'set_music_list',
- // list: list.map(({ id, name, size, type }) => ({ id, name, size, type }))
- // }))
+ clientList.send('base', JSON.stringify({
+ type: 'set_music_list',
+ list: list.map(({ id, name, size, type }) => ({ id, name, size, type }))
+ }))
}
},
- onunlike: item => {
+ onunlike: (item, list) => {
console.log('取消喜欢', item)
+ if (item.arrayBuffer) {
+ database.delete(item.id)
+ clientList.send('base', JSON.stringify({
+ type: 'set_music_list',
+ list: list.map(({ id, name, size, type }) => ({ id, name, size, type }))
+ }))
+ }
},
onban: item => {
console.log('禁止音乐', item)
diff --git a/public/music.js b/public/music.js
index c72b1bc..c341597 100644
--- a/public/music.js
+++ b/public/music.js
@@ -154,10 +154,10 @@ export default class MusicList {
if (!item.arrayBuffer) {
await this.load(item)
}
- this.event.onlike(item)
+ this.event.onlike(item, this.list)
}
async unlike(item) {
- this.event.onunlike(item)
+ this.event.onunlike(item, this.list)
}
async ban(item) {
this.event.onban(item)