feat(playlist): 优化歌单收藏功能

- 新增 collectPlaylist 和 uncollectPlaylist 函数,分别用于收藏和取消收藏歌单- 重构 toggleCollectPlaylist 函数,使用新增的两个函数实现收藏和取消收藏
- 在 Playlist组件中实现批量更新歌单收藏状态的功能
- 优化收藏按钮点击逻辑,根据歌单的 collected 属性决定是收藏还是取消收藏
This commit is contained in:
ikmkj
2025-07-26 14:27:42 +08:00
parent 5b30905577
commit 285238cf5f
3 changed files with 61 additions and 14 deletions

View File

@@ -195,7 +195,13 @@ const toggleCollect = async () => {
}
try {
const res = await toggleCollectSinger(singerId.value, isCollected.value)
let res
if (isCollected.value) {
res = await uncollectSinger(singerId.value)
} else {
res = await collectSinger(singerId.value)
}
if (res.code === 200) {
isCollected.value = !isCollected.value
// 更新收藏数