refactor(player): 重构播放器组件并优化音乐状态管理

- 优化了音乐收藏和点赞状态的管理逻辑
- 重构了播放器组件中的多个函数,提高了代码可读性和维护性
- 添加了 MusicStatusDTO 类,用于封装音乐状态信息
- 优化了歌词显示和滚动逻辑
- 简化了部分代码结构,提高了执行效率
This commit is contained in:
ikmkj
2025-07-26 00:08:07 +08:00
parent 439d4b7588
commit a37a47bdab
3 changed files with 96 additions and 203 deletions

View File

@@ -280,6 +280,18 @@ export const usePlayerStore = defineStore('player', {
if (index !== -1) {
this.playlist[index].cover = cover
}
},
// 更新当前音乐的状态(如收藏、点赞)
updateCurrentMusicStatus(status) {
if (this.currentMusic) {
this.currentMusic = { ...this.currentMusic, ...status };
const index = this.playlist.findIndex(item => item.id === this.currentMusic.id);
if (index !== -1) {
this.playlist[index] = { ...this.playlist[index], ...status };
}
}
}
}
})