From c2fda44512ec0cb0aed2d8c17b95b21f73393999 Mon Sep 17 00:00:00 2001 From: ikmkj <1@qq,com> Date: Fri, 25 Jul 2025 19:18:09 +0800 Subject: [PATCH] =?UTF-8?q?feat(comment):=20=E6=B7=BB=E5=8A=A0=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD-=20=E5=9C=A8=20Si?= =?UTF-8?q?ngerDetail=20=E7=BB=84=E4=BB=B6=E4=B8=AD=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E8=AF=84=E8=AE=BA=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD=20-=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A0=E9=99=A4=E8=AF=84=E8=AE=BA=E7=9A=84?= =?UTF-8?q?=20API=20=E8=B0=83=E7=94=A8=E5=92=8C=E7=9B=B8=E5=85=B3=E9=80=BB?= =?UTF-8?q?=E8=BE=91=20-=20=E5=9C=A8=E8=AF=84=E8=AE=BA=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E4=B8=AD=E5=A2=9E=E5=8A=A0=E5=88=A0=E9=99=A4=E6=8C=89=E9=92=AE?= =?UTF-8?q?=EF=BC=8C=E4=BB=85=E7=AE=A1=E7=90=86=E5=91=98=E5=92=8C=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E4=BD=9C=E8=80=85=E5=8F=AF=E8=A7=81=20-=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E8=AF=84=E8=AE=BA=E5=88=97=E8=A1=A8=E7=9A=84=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=EF=BC=8C=E5=A2=9E=E5=8A=A0=E8=AF=84=E8=AE=BA=E5=A4=B4?= =?UTF-8?q?=E9=83=A8=E5=8C=BA=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- music-qianduan/src/views/SingerDetail.vue | 51 +++++++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/music-qianduan/src/views/SingerDetail.vue b/music-qianduan/src/views/SingerDetail.vue index cf519bf..10da0d2 100644 --- a/music-qianduan/src/views/SingerDetail.vue +++ b/music-qianduan/src/views/SingerDetail.vue @@ -3,9 +3,9 @@ import { ref, onMounted, computed, onUnmounted } from 'vue' // 添加 onUnmounte import { useRoute, useRouter } from 'vue-router' import { usePlayerStore } from '../stores/player' import { useUserStore } from '../stores/user' -import { ElMessage } from 'element-plus' +import { ElMessage, ElMessageBox } from 'element-plus' import { getSingerById, toggleCollectSinger } from '../api/singer' -import { getCommentList, addComment } from '../api/comment' +import { getCommentList, addComment, deleteComment as apiDeleteComment } from '../api/comment' import { processImageUrl } from '../utils/imageUtils' import { processMusicUrl, getMusicBySinger } from '../api/music' import { connect, subscribe, unsubscribe, disconnect } from '../utils/websocket' // 导入 WebSocket 工具 @@ -212,6 +212,30 @@ const submitComment = async () => { } } +// 删除评论 +const deleteComment = async (commentId) => { + try { + await ElMessageBox.confirm('确定要删除这条评论吗?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }) + + const res = await apiDeleteComment(commentId) + if (res.code === 200) { + comments.value = comments.value.filter(c => c.id !== commentId) + ElMessage.success('评论已删除') + } else { + ElMessage.error(res.message || '删除失败') + } + } catch (error) { + if (error !== 'cancel') { + console.error('删除评论失败:', error) + ElMessage.error('删除失败,请稍后重试') + } + } +} + // 格式化时间 @@ -410,6 +434,7 @@ onUnmounted(() => { 发表评论 +
@@ -417,7 +442,19 @@ onUnmounted(() => {
-
{{ comment.user.username }}
+
+
{{ comment.user.username }}
+
+ + 删除 + +
+
{{ comment.content }}
{{ comment.createTime }}
@@ -563,9 +600,15 @@ onUnmounted(() => { flex: 1; } +.comment-header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 5px; +} + .comment-user { font-weight: bold; - margin-bottom: 5px; } .comment-text {