From e63f9498bd9d2bb54646dd12a60991ae2e4173fb Mon Sep 17 00:00:00 2001 From: kimdaae328 Date: Fri, 28 Feb 2025 14:31:36 +0900 Subject: [PATCH] =?UTF-8?q?isDeleted=20=EC=88=98=EC=A0=95=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/board/BoardComment.vue | 17 ++++++++++++++++- src/components/board/BoardCommentList.vue | 5 +++++ src/views/board/BoardView.vue | 14 ++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/components/board/BoardComment.vue b/src/components/board/BoardComment.vue index 205d5a6..616e583 100644 --- a/src/components/board/BoardComment.vue +++ b/src/components/board/BoardComment.vue @@ -37,6 +37,11 @@ + + + @@ -109,6 +114,10 @@ const props = defineProps({ type: Boolean, default: false }, + isDeleted: { + type: Boolean, + default: false + }, isCommentPassword: { type: Boolean, default: false, @@ -154,7 +163,6 @@ const handleUpdateReaction = (reactionData) => { // 비밀번호 확인 const logPasswordAndEmit = () => { - console.log('비밀번호 확인',props.password) emit('submitPassword', props.comment, props.password); }; @@ -164,6 +172,13 @@ watch(() => props.comment.isEditTextarea, (newVal) => { } }); +watch(() => props.comment.isDeleted, () => { + if (newVal) { + localEditedContent.value = "댓글이 삭제되었습니다."; // UI 반영 + props.comment.isEditTextarea = false; + } +}); + // 수정버튼 const submitEdit = () => { emit('submitEdit', props.comment, localEditedContent.value); diff --git a/src/components/board/BoardCommentList.vue b/src/components/board/BoardCommentList.vue index 1b47923..a33e464 100644 --- a/src/components/board/BoardCommentList.vue +++ b/src/components/board/BoardCommentList.vue @@ -10,6 +10,7 @@ :comment="comment" :isCommentAuthor="comment.isCommentAuthor" :isEditTextarea="comment.isEditTextarea" + :isDeleted="comment.isDeleted" :isCommentPassword="isCommentPassword" :passwordCommentAlert="passwordCommentAlert || ''" :currentPasswordCommentId="currentPasswordCommentId" @@ -53,6 +54,10 @@ const props = defineProps({ type: Boolean, default: false, }, + isDeleted: { + type: Boolean, + default: false, + }, passwordCommentAlert: { type: String, default: '' diff --git a/src/views/board/BoardView.vue b/src/views/board/BoardView.vue index eaa6dd5..2f5bb28 100644 --- a/src/views/board/BoardView.vue +++ b/src/views/board/BoardView.vue @@ -102,6 +102,7 @@ :comments="commentsWithAuthStatus" :isCommentPassword="isCommentPassword" :isEditTextarea="isEditTextarea" + :isDeleted="isDeleted" :passwordCommentAlert="passwordCommentAlert" :currentPasswordCommentId="currentPasswordCommentId" :password="password" @@ -183,6 +184,7 @@ const currentPasswordCommentId = ref(null); const lastClickedButton = ref(""); const lastCommentClickedButton = ref(""); const isEditTextarea = ref(false); +const isDeleted = ref(true); const commentAlert = ref(''); const updatePassword = (newPassword) => { @@ -671,6 +673,10 @@ const deletePost = async () => { const deleteReplyComment = async (comment) => { if (!confirm("정말 이 댓글을 삭제하시겠습니까?")) return; + const targetComment = findCommentById(comment.commentId, comments.value); + + console.log('잘되니?',comment) + try { const response = await axios.delete(`board/comment/${comment.commentId}`, { data: { LOCCMTSEQ: comment.commentId } @@ -678,6 +684,14 @@ const deleteReplyComment = async (comment) => { if (response.data.code === 200) { await fetchComments(); + + if (targetComment) { + console.log('타겟',targetComment) + // ✅ 댓글 내용만 "삭제된 댓글입니다."로 변경하고, 구조는 유지 + targetComment.content = "댓글이 삭제되었습니다."; + targetComment.author = "알 수 없음"; // 익명 처리 + targetComment.isDeleted = true; // ✅ 삭제 상태를 추가 + } } else { alert("댓글 삭제에 실패했습니다."); }