From 71d47ebbb47a2753e3339cee0faa1e9b20eb7e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A7=89?= Date: Wed, 4 Oct 2023 06:59:24 +0800 Subject: [PATCH] like --- README.md | 3 +++ public/index.html | 2 +- public/music.js | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2caf7a5..e8c1906 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,9 @@ webrtc 实现的 p2p 信道 - [x] 分片请求时立即播放 - [ ] 上锁防止连续重复加载同一个造成分片混乱 - [x] 使用单独的状态标识音乐是否缓存 + - [x] 取消本地存储时不直接移除列表 + - [ ] 取消本地存储时检查是否移除(其它成员可能有同一曲) + - [ ] 成员列表刷新时播放被重置BUG - [ ] 集群分发 - [ ] 下载加速 - [ ] 即时通讯 diff --git a/public/index.html b/public/index.html index 22e9907..3357dde 100644 --- a/public/index.html +++ b/public/index.html @@ -72,7 +72,7 @@ onlike: (item, list) => { console.log('喜欢音乐', item.name) if (item.arrayBuffer) { - database.add({ save:true, ...item }) + database.add(item) clientList.send('base', JSON.stringify({ type: 'set_music_list', list: list.map(({ id, name, size, type }) => ({ id, name, size, type })) diff --git a/public/music.js b/public/music.js index 68d9e19..433312a 100644 --- a/public/music.js +++ b/public/music.js @@ -115,8 +115,10 @@ export default class MusicList { event.stopPropagation() if (item.save) { event.target.textContent = '缓存' + this.ul.querySelector(`#${item.id}`).classList.remove('cache') this.unlike(item) } else { + item.save = true event.target.textContent = '移除' this.ul.querySelector(`#${item.id}`).classList.add('cache') this.like(item) @@ -170,7 +172,6 @@ export default class MusicList { this.event.onlike(item, this.list) } async unlike(item) { - this.remove(item) this.event.onunlike(item, this.list) } async ban(item) {