按钮功能合并

This commit is contained in:
2023-10-02 06:30:20 +08:00
parent 6b986de6d6
commit 0fc8dc3f67
1 changed files with 12 additions and 10 deletions

View File

@ -97,18 +97,19 @@ export default class MusicList {
}
}),
Button({
innerText: '移除',
innerText: item.arrayBuffer ? '移除' : '喜欢',
onclick: event => {
event.stopPropagation()
if (item.arrayBuffer) {
event.target.innerText = '喜欢'
this.unlike(item)
this.remove(item)
}
}),
Button({
innerText: '喜欢',
onclick: event => {
event.stopPropagation()
} else {
event.target.innerText = '移除'
this.ul.querySelector(`#${item.id}`).classList.add('cache')
this.like(item)
}
}
}),
Button({
innerText: '禁止',
@ -130,7 +131,7 @@ export default class MusicList {
}
async remove(item) {
this.ul.querySelector(`#${item.id}`)?.remove()
this.stop() // 停止播放
if (this.playing) this.stop() // 停止播放
this.event.onremove(item)
}
async load(item) {
@ -149,6 +150,7 @@ export default class MusicList {
this.audio.pause()
this.audio.src = ''
this.event.onstop(this.playing)
this.playing = null
}
async like(item) {
if (!item.arrayBuffer) {