防止加载不存在的封面

This commit is contained in:
2023-10-26 03:09:06 +08:00
parent 253a4b7134
commit a232ece058
1 changed files with 4 additions and 2 deletions

View File

@ -379,8 +379,10 @@ export default class MusicList {
}) })
} }
} else { } else {
this.标题.textContent = item.name // 替换标题 this.标题.textContent = item.name
this.封面.style.backgroundImage = `url(${item.picture})` // 替换封面图像 if (item.picture) {
this.封面.style.backgroundImage = `url(${item.picture})`
}
// 替换浏览器媒体信息(使系统通知栏显示歌曲信息) // 替换浏览器媒体信息(使系统通知栏显示歌曲信息)
if ('mediaSession' in navigator) { if ('mediaSession' in navigator) {
navigator.mediaSession.metadata = new MediaMetadata({ navigator.mediaSession.metadata = new MediaMetadata({