refactor(user): 更新收藏歌手页面的取消收藏功能
- 将 toggleCollectSinger API 调用替换为 uncollectSinger API - 优化了取消收藏歌手的逻辑,提高了代码的可读性和维护性
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { getCollectedSinger, toggleCollectSinger } from '../../api/singer'
|
||||
import { getCollectedSinger, uncollectSinger } from '../../api/singer'
|
||||
import { processImageUrl } from '../../utils/imageUtils'
|
||||
|
||||
const router = useRouter()
|
||||
@@ -59,7 +59,7 @@ const cancelCollect = (id, event) => {
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
try {
|
||||
const res = await toggleCollectSinger(id)
|
||||
const res = await uncollectSinger(id)
|
||||
if (res.code === 200) {
|
||||
// 从列表中移除该歌手
|
||||
collectSingers.value = collectSingers.value.filter(item => item.id !== id)
|
||||
|
||||
Reference in New Issue
Block a user