diff --git a/music-qianduan/src/views/PlaylistDetail.vue b/music-qianduan/src/views/PlaylistDetail.vue index 7762538..1c11f1a 100644 --- a/music-qianduan/src/views/PlaylistDetail.vue +++ b/music-qianduan/src/views/PlaylistDetail.vue @@ -117,6 +117,9 @@ const fetchComments = async () => { const res = await getCommentList(playlistId.value, 2, 1, 20) // targetType 2 表示歌单 if (res.code === 200) { comments.value = res.data.list || res.data.records || [] + if (playlist.value && res.data.total !== undefined) { + playlist.value.commentCount = res.data.total + } } else { ElMessage.error(res.message || '获取评论列表失败') } @@ -396,6 +399,17 @@ const formatTime = (seconds) => { return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}` } +// 格式化评论数 +const formattedCommentCount = computed(() => { + if (!playlist.value || playlist.value.commentCount === undefined) { + return 0; + } + if (playlist.value.commentCount > 99) { + return '99+'; + } + return playlist.value.commentCount; +}); + // 格式化播放次数 const formatPlayCount = (count) => { if (count < 10000) { @@ -525,7 +539,7 @@ onUnmounted(() => {
收藏数:{{ playlist.collectCount }} - 评论数:{{ playlist.commentCount }} + 评论数:{{ formattedCommentCount }}
{{ playlist.description }}
@@ -569,7 +583,7 @@ onUnmounted(() => { /> - +