用户离开时从移除其音乐
This commit is contained in:
		@@ -44,17 +44,19 @@
 | 
				
			|||||||
                console.log(client.name, '离开频道', client)
 | 
					                console.log(client.name, '离开频道', client)
 | 
				
			||||||
                // 从列表中移除未缓存的此用户的音乐, 但可能多人都有此音乐且未缓存
 | 
					                // 从列表中移除未缓存的此用户的音乐, 但可能多人都有此音乐且未缓存
 | 
				
			||||||
                // 因此每条音乐都要检查是否有其他用户也有此音乐, 如果有则不移除
 | 
					                // 因此每条音乐都要检查是否有其他用户也有此音乐, 如果有则不移除
 | 
				
			||||||
                //musicList.list.filter(item => !item.arrayBuffer).forEach(item => {
 | 
					                const 此用户音乐 = client.musicList.map(item => item.id)
 | 
				
			||||||
                //    const client = clientList.clientlist.find(client => {
 | 
					                const 无数据音乐 = musicList.list.filter(item => !item.arrayBuffer)
 | 
				
			||||||
                //        return client.musicList.find(x => x.id === item.id)
 | 
					                无数据音乐.forEach(item => {
 | 
				
			||||||
                //    })
 | 
					                    const client = clientList.clientlist.find(client => {
 | 
				
			||||||
                //    if (!client) {
 | 
					                        return client.musicList.find(x => x.id === item.id)
 | 
				
			||||||
                //        console.log('没有用户存留此音乐了, 移除记录', item.name)
 | 
					                    })
 | 
				
			||||||
                //        musicList.remove(item)
 | 
					                    if (!client) {
 | 
				
			||||||
                //    } else {
 | 
					                        console.log('没有用户存留此音乐了, 移除记录', item.name)
 | 
				
			||||||
                //        console.log(client.name, '中还有此音乐, 保留记录', item.name)
 | 
					                        musicList.remove(item)
 | 
				
			||||||
                //    }
 | 
					                    } else {
 | 
				
			||||||
                //})
 | 
					                        console.log(client.name, '中还有此音乐, 保留记录', item.name)
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -126,6 +126,7 @@ export default class MusicList {
 | 
				
			|||||||
    async remove(item) {
 | 
					    async remove(item) {
 | 
				
			||||||
        this.ul.querySelector(`#${item.id}`)?.remove()
 | 
					        this.ul.querySelector(`#${item.id}`)?.remove()
 | 
				
			||||||
        if (!this.audio.paused) this.stop() // 停止播放
 | 
					        if (!this.audio.paused) this.stop() // 停止播放
 | 
				
			||||||
 | 
					        this.list = this.list.filter(i => i.id !== item.id)
 | 
				
			||||||
        this.event.onremove(item)
 | 
					        this.event.onremove(item)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    async load(item) {
 | 
					    async load(item) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user