From 5d423aedb40da31954e0ecd2a84fb56fb62a1a45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A7=89?= Date: Mon, 2 Oct 2023 00:53:17 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=95=E8=BF=87=E5=B7=B2=E7=BB=8F=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E7=9A=84=E6=9B=B2=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/client.js | 2 +- public/music.js | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/public/client.js b/public/client.js index 90ac681..0297556 100644 --- a/public/client.js +++ b/public/client.js @@ -43,7 +43,7 @@ export default class ClientList { } } channel.onmessage = event => { - console.log('对方发送', channel.label, '数据消息') + //console.log('对方发送', channel.label, '数据消息') if (option && option.onmessage) { option.onmessage(event, client) } diff --git a/public/music.js b/public/music.js index 2a6a341..050ca65 100644 --- a/public/music.js +++ b/public/music.js @@ -61,11 +61,11 @@ export default class MusicList { document.head.appendChild(style) document.body.appendChild(input) } - // 添加回调函数 - on(name, callback) { - this.EventListeners[name] = callback - } add(item) { + // 如果ID已存在则不添加 + if (this.list.find(i => i.id === item.id)) { + return + } // 将字节转换为可读的单位 const bytesToSize = bytes => { if (bytes === 0) return '0 B' @@ -163,10 +163,6 @@ export default class MusicList { async ban(item) { this.event.onban(item) } - //like(user_id, item_id) { - // //if (!item.like) item.like = [] - // //item.like.push(user_id) - //} next() { } prev() { } }