From b02d99e4b17ab0ea00221e5a5107763b6f3d7835 Mon Sep 17 00:00:00 2001 From: kimdaae328 Date: Thu, 27 Feb 2025 16:23:45 +0900 Subject: [PATCH 01/12] =?UTF-8?q?=EB=8C=93=EA=B8=80=20=EC=9D=B5=EB=AA=85?= =?UTF-8?q?=20=EC=B2=B4=ED=81=AC=20=EC=88=98=EC=A0=95=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/board/BoardCommentArea.vue | 7 +++---- src/views/board/BoardView.vue | 10 ++++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/components/board/BoardCommentArea.vue b/src/components/board/BoardCommentArea.vue index 4f2fca2..e696680 100644 --- a/src/components/board/BoardCommentArea.vue +++ b/src/components/board/BoardCommentArea.vue @@ -51,10 +51,7 @@
- +
@@ -63,6 +60,7 @@ diff --git a/src/components/board/BoardCommentList.vue b/src/components/board/BoardCommentList.vue index 3ee4624..3c315a8 100644 --- a/src/components/board/BoardCommentList.vue +++ b/src/components/board/BoardCommentList.vue @@ -78,7 +78,11 @@ const submitPassword = (comment, password) => { }; const handleEditClick = (comment) => { - emit('editClick', comment); + if (comment.parentId) { + emit('deleteClick', comment); // 대댓글 + } else { + emit('deleteClick', comment); // 댓글 + } }; const handleSubmitEdit = (comment, editedContent) => { diff --git a/src/views/board/BoardView.vue b/src/views/board/BoardView.vue index 5a6caf8..725dd2a 100644 --- a/src/views/board/BoardView.vue +++ b/src/views/board/BoardView.vue @@ -482,7 +482,6 @@ const findCommentById = (commentId, commentsList) => { // 댓글 수정 버튼 클릭 const editComment = (comment) => { - // 부모 또는 대댓글을 찾아서 가져오기 const targetComment = findCommentById(comment.commentId, comments.value); @@ -590,9 +589,10 @@ const submitPassword = async () => { // 댓글 삭제 (비밀번호 확인 후) const submitCommentPassword = async (comment, password) => { + console.log('야야야') - // console.log("비밀번호 :", password); - // console.log("댓글 ID:", comment.commentId); + console.log("비밀번호 :", password); + console.log("댓글 ID:", comment.commentId); if (!password) { passwordCommentAlert.value = "비밀번호를 입력해주세요."; @@ -607,7 +607,7 @@ const submitCommentPassword = async (comment, password) => { LOCCMTPWD: password, LOCCMTSEQ: comment.commentId, }); - // console.log("✅ 서버 응답 데이터:", response.data); + console.log("✅ 서버 응답 데이터:", response.data); if (response.data.code === 200 && response.data.data === true) { passwordCommentAlert.value = ""; @@ -671,7 +671,6 @@ const deletePost = async () => { // 댓글 삭제 (대댓글 포함) const deleteReplyComment = async (comment) => { if (!confirm("정말 이 댓글을 삭제하시겠습니까?")) return; - console.log("댓글 수정, 대댓글도?"); try { const response = await axios.delete(`board/comment/${comment.commentId}`, { From d1c91b30df144b11908e8671db45e8bff186a568 Mon Sep 17 00:00:00 2001 From: kimdaae328 Date: Fri, 28 Feb 2025 10:01:53 +0900 Subject: [PATCH 05/12] =?UTF-8?q?=EC=A3=BC=EC=84=9D=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/board/BoardComment.vue | 1 - src/components/board/BoardProfile.vue | 7 ++- src/views/board/BoardList.vue | 5 +- src/views/board/BoardView.vue | 86 +++------------------------ 4 files changed, 15 insertions(+), 84 deletions(-) diff --git a/src/components/board/BoardComment.vue b/src/components/board/BoardComment.vue index 965f6d7..82b54ea 100644 --- a/src/components/board/BoardComment.vue +++ b/src/components/board/BoardComment.vue @@ -165,7 +165,6 @@ const handleEditClick = () => { } const handleReplyEditClick = (event) => { - console.log("📌 editClick 이벤트 실행됨! 전달된 데이터:", event); emit('editClick', event); } diff --git a/src/components/board/BoardProfile.vue b/src/components/board/BoardProfile.vue index c3c4f91..cf43b87 100644 --- a/src/components/board/BoardProfile.vue +++ b/src/components/board/BoardProfile.vue @@ -4,6 +4,7 @@
Avatar
+
{{ profileName }}
@@ -94,7 +95,7 @@ const props = defineProps({ isLike: { type: Boolean, default: false, - } + }, }); const emit = defineEmits(['updateReaction', 'editClick', 'deleteClick']); @@ -117,6 +118,10 @@ const handleUpdateReaction = (reactionData) => { }); }; +const getProfileImage = (profilePath) => { + return profilePath && profilePath.trim() ? `${baseUrl}upload/img/profile/${profilePath}` : defaultProfile; +}; + diff --git a/src/views/board/BoardList.vue b/src/views/board/BoardList.vue index 095e5e3..3ac8ef0 100644 --- a/src/views/board/BoardList.vue +++ b/src/views/board/BoardList.vue @@ -195,10 +195,7 @@ const fetchGeneralPosts = async (page = 1) => { }); if (data?.data) { - // console.log(data) - const totalPosts = data.data.total; // 전체 게시물 개수 받아오기 - - // console.log('📌 API 응답 데이터:', data.data); + const totalPosts = data.data.total; generalList.value = data.data.list.map((post, index) => ({ realId: post.id, diff --git a/src/views/board/BoardView.vue b/src/views/board/BoardView.vue index 725dd2a..30d7921 100644 --- a/src/views/board/BoardView.vue +++ b/src/views/board/BoardView.vue @@ -76,13 +76,7 @@ @updateReaction="handleUpdateReaction" />
- - - - - +
@@ -173,7 +166,6 @@ const commentsWithAuthStatus = computed(() => { isCommentAuthor: reply.authorId === currentUserId.value, })) })); - // console.log("✅ commentsWithAuthStatus 업데이트됨:", updatedComments); return updatedComments; }); @@ -210,20 +202,12 @@ const fetchBoardDetails = async () => { const response = await axios.get(`board/${currentBoardId.value}`); const data = response.data.data; - // console.log(data) // API 응답 데이터 반영 // const boardDetail = data.boardDetail || {}; profileName.value = data.author || '익명'; - // 익명확인하고 싶을때 - // profileName.value = '익명'; - - // console.log("📌 게시글 작성자:", profileName.value); // 작성자 이름 출력 - // console.log("🔍 익명 여부 (unknown.value):", unknown.value); // 익명 여부 확인 - - authorId.value = data.authorId; //게시글 작성자 id boardTitle.value = data.title || '제목 없음'; boardContent.value = data.content || ''; @@ -245,7 +229,6 @@ const handleUpdateReaction = async ({ boardId, commentId, isLike, isDislike }) = await axios.post(`/board/${boardId}/${commentId}/reaction`, { LOCBRDSEQ: boardId, // 게시글 id LOCCMTSEQ: commentId, //댓글 id - // MEMBERSEQ: 1, // 멤버아이디 지금은 1 나중에 수정해야함 LOCGOBGOD: isLike ? 'T' : 'F', LOCGOBBAD: isDislike ? 'T' : 'F' }); @@ -258,13 +241,9 @@ const handleUpdateReaction = async ({ boardId, commentId, isLike, isDislike }) = likeClicked.value = isLike; dislikeClicked.value = isDislike; - // console.log(updatedData) - - // console.log("갱신된 데이터:", updatedData); } catch (error) { alert('오류가 발생했습니다.'); - // console.log('반응을 업데이트하는 중 오류가 발생했습니다.'); } }; @@ -281,13 +260,10 @@ const handleCommentReaction = async ({ boardId, commentId, isLike, isDislike }) LOCGOBBAD: isDislike ? 'T' : 'F' }); - // console.log("댓글 좋아요 API 응답 데이터:", response.data); - await fetchComments(); } catch (error) { alert('오류가 발생했습니다.'); - // console.log('댓글 반응을 업데이트하는 중 오류 발생'); } }; @@ -302,8 +278,6 @@ const fetchComments = async (page = 1) => { } }); - // console.log(response.data.data) - const commentsList = response.data.data.list.map(comment => ({ commentId: comment.LOCCMTSEQ, // 댓글 ID boardId: comment.LOCBRDSEQ, @@ -329,8 +303,6 @@ const fetchComments = async (page = 1) => { params: { LOCCMTPNT: comment.commentId } }); - // console.log(`대댓글 데이터 (${comment.commentId}의 대댓글):`, replyResponse.data); - if (replyResponse.data.data) { comment.children = replyResponse.data.data.map(reply => ({ author: reply.author || '익명', @@ -370,18 +342,15 @@ const fetchComments = async (page = 1) => { navigateLastPage: response.data.data.navigateLastPage // 페이지네이션에서 마지막 페이지 번호 }; - // console.log("📌 댓글 목록:", comments.value); } catch (error) { alert('오류가 발생했습니다.'); - // alert('댓글 목록 불러오기 오류:', error); } }; // 댓글 작성 const handleCommentSubmit = async (data) => { if (!data) { - console.error("handleCommentSubmit: data가 undefined입니다."); return; } @@ -432,8 +401,8 @@ const handleCommentReply = async (reply) => { }); if (response.status === 200) { - if (response.data.code === 200) { // 서버 응답 코드도 확인 - await fetchComments(); // 댓글 목록 새로고침 + if (response.data.code === 200) { + await fetchComments(); } else { alert('대댓글 작성을 실패했습니다.'); } @@ -443,7 +412,6 @@ const handleCommentReply = async (reply) => { alert("오류가 발생했습니다."); } alert("오류가 발생했습니다."); - } } @@ -482,41 +450,33 @@ const findCommentById = (commentId, commentsList) => { // 댓글 수정 버튼 클릭 const editComment = (comment) => { - // 부모 또는 대댓글을 찾아서 가져오기 const targetComment = findCommentById(comment.commentId, comments.value); if (!targetComment) { return; } - // 댓글 작성자가 현재 로그인한 사용자와 동일한지 확인 const isMyComment = comment.authorId === currentUserId.value; const isAnonymous = comment.author === "익명"; if (isMyComment) { - // 본인 댓글이면 바로 수정 모드 활성화 targetComment.isEditTextarea = !targetComment.isEditTextarea; } else if (isAnonymous) { - // 익명 댓글이면 비밀번호 입력창 띄우기 toggleCommentPassword(comment, "edit"); } else { - // console.log("다른 사용자 댓글 - 수정 불가"); alert("수정이 불가능합니다"); } } // 댓글 삭제 버튼 클릭 const deleteComment = async (comment) => { - // 익명 사용자인 경우 const isMyComment = comment.authorId === currentUserId.value; if (unknown.value && !isMyComment) { if (comment.isEditTextarea) { - // 현재 수정 중이라면 수정 모드를 끄고, 삭제 비밀번호 입력창을 띄움 comment.isEditTextarea = false; comment.isCommentPassword = true; } else { - // 수정 중이 아니면 기존의 삭제 비밀번호 입력창을 띄우는 로직 실행 toggleCommentPassword(comment, "delete"); } } else { @@ -554,7 +514,7 @@ const submitPassword = async () => { try { const response = await axios.post(`board/${currentBoardId.value}/password`, { LOCBRDPWD: password.value, - LOCBRDSEQ: 288, // 나중에 현재 게시글 ID 사용해야함 + LOCBRDSEQ: 288, }); if (response.data.code === 200 && response.data.data === true) { @@ -571,8 +531,6 @@ const submitPassword = async () => { passwordAlert.value = "비밀번호가 일치하지 않습니다."; } } catch (error) { - // console.log("📌 전체 오류:", error); - if (error.response) { if (error.response.status === 401) { passwordAlert.value = "비밀번호가 일치하지 않습니다."; @@ -589,11 +547,6 @@ const submitPassword = async () => { // 댓글 삭제 (비밀번호 확인 후) const submitCommentPassword = async (comment, password) => { - console.log('야야야') - - console.log("비밀번호 :", password); - console.log("댓글 ID:", comment.commentId); - if (!password) { passwordCommentAlert.value = "비밀번호를 입력해주세요."; return; @@ -602,12 +555,10 @@ const submitCommentPassword = async (comment, password) => { const targetComment = findCommentById(comment.commentId, comments.value); try { - // console.log('서버로 비밀번호 확인 요청') const response = await axios.post(`board/comment/${comment.commentId}/password`, { LOCCMTPWD: password, LOCCMTSEQ: comment.commentId, }); - console.log("✅ 서버 응답 데이터:", response.data); if (response.data.code === 200 && response.data.data === true) { passwordCommentAlert.value = ""; @@ -622,9 +573,6 @@ const submitCommentPassword = async (comment, password) => { } else { alert("수정 취소를 실패했습니다."); } - - // 여기부분이 익명 수정 비밀번호 부분임!!!!! - } else if (lastCommentClickedButton.value === "delete") { passwordCommentAlert.value = ""; @@ -632,14 +580,12 @@ const submitCommentPassword = async (comment, password) => { } lastCommentClickedButton.value = null; } else { - // console.log("❌ 비밀번호가 틀림"); passwordCommentAlert.value = "비밀번호가 일치하지 않습니다."; } } catch (error) { - // console.log("🚨 서버 요청 중 오류 발생:", error.response?.data || error); - // if (error.response?.status === 401) { - // console.log("❌ 401 오류: 인증 실패 (비밀번호 불일치)"); - // } + if (error.response?.status === 401) { + passwordCommentAlert.value = "비밀번호가 일치하지 않습니다"; + } passwordCommentAlert.value = "비밀번호가 일치하지 않습니다"; } }; @@ -677,17 +623,12 @@ const deleteReplyComment = async (comment) => { data: { LOCCMTSEQ: comment.commentId } }); - // console.log("서버 응답:", response.data); - if (response.data.code === 200) { - // console.log("댓글 삭제 성공!"); await fetchComments(); } else { - // console.log("댓글 삭제 실패:", response.data.message); alert("댓글 삭제에 실패했습니다."); } } catch (error) { - // console.log("댓글 삭제 중 오류 발생:", error); alert("댓글 삭제 중 오류가 발생했습니다."); } }; @@ -700,9 +641,6 @@ const handleSubmitEdit = async (comment, editedContent) => { LOCCMTRPY: editedContent }); - // 수정 성공 시 업데이트 - // comment.content = editedContent; - // comment.isEditTextarea = false; f if (response.status === 200) { const targetComment = findCommentById(comment.commentId, comments.value); @@ -710,15 +648,12 @@ const handleSubmitEdit = async (comment, editedContent) => { targetComment.content = editedContent; // 댓글 내용 업데이트 targetComment.isEditTextarea = false; // 수정 모드 닫기 } else { - // console.warn("❌ 수정할 댓글을 찾을 수 없음"); alert("수정할 댓글을 찾을 수 없습니다."); } } else { - // console.log("❌ 댓글 수정 실패:", response.data); alert("댓글 수정 실패했습니다."); } } catch (error) { - // console.error("댓글 수정 중 오류 발생:", error); alert("댓글 수정 중 오류 발생했습니다."); } }; @@ -728,10 +663,8 @@ const handleCancelEdit = (comment) => { const targetComment = findCommentById(comment.commentId, comments.value); if (targetComment) { - // console.log("✅ 원본 데이터 찾음, 수정 취소 처리 가능:", targetComment); targetComment.isEditTextarea = false; } else { - // console.error("❌ 원본 데이터 찾을 수 없음, 수정 취소 실패"); alert("수정 취소를 실패했습니다."); } }; @@ -754,7 +687,7 @@ const handleCommentDeleted = (deletedCommentId) => { return; } - // 2대댓글 삭제 + // 대댓글 삭제 for (let parent of comments.value) { const childIndex = parent.children.findIndex(child => child.commentId === deletedCommentId); if (childIndex !== -1) { @@ -762,11 +695,8 @@ const handleCommentDeleted = (deletedCommentId) => { return; } } - - // console.error("❌ 삭제할 댓글을 찾을 수 없음:", deletedCommentId); }; - // 날짜 const formattedDate = (dateString) => { if (!dateString) return "날짜 없음"; From 2cc280717d1d5638f066dca8d6a7f42c087eae39 Mon Sep 17 00:00:00 2001 From: kimdaae328 Date: Fri, 28 Feb 2025 10:09:45 +0900 Subject: [PATCH 06/12] . --- src/views/board/BoardView.vue | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/views/board/BoardView.vue b/src/views/board/BoardView.vue index 30d7921..cfacd8f 100644 --- a/src/views/board/BoardView.vue +++ b/src/views/board/BoardView.vue @@ -461,6 +461,7 @@ const editComment = (comment) => { if (isMyComment) { targetComment.isEditTextarea = !targetComment.isEditTextarea; + lastCommentClickedButton.value = "edit"; } else if (isAnonymous) { toggleCommentPassword(comment, "edit"); } else { @@ -616,6 +617,7 @@ const deletePost = async () => { // 댓글 삭제 (대댓글 포함) const deleteReplyComment = async (comment) => { + console.log('지금 여기') if (!confirm("정말 이 댓글을 삭제하시겠습니까?")) return; try { @@ -635,6 +637,7 @@ const deleteReplyComment = async (comment) => { // 댓글 수정 확인 const handleSubmitEdit = async (comment, editedContent) => { + console.log('asdasdasdasd') try { const response = await axios.put(`board/comment/${comment.commentId}`, { LOCCMTSEQ: comment.commentId, From 63f8f167ebc631d57eed7456b905f5f31ed8703f Mon Sep 17 00:00:00 2001 From: kimdaae328 Date: Fri, 28 Feb 2025 10:57:25 +0900 Subject: [PATCH 07/12] =?UTF-8?q?=EA=B2=BD=EA=B3=A0=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/board/BoardComment.vue | 8 ++++---- src/components/board/BoardCommentArea.vue | 4 ++-- src/components/board/BoardCommentList.vue | 11 +++++------ src/components/board/BoardProfile.vue | 2 +- src/components/button/BoardRecommendBtn.vue | 4 ++-- src/views/board/BoardView.vue | 3 ++- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/components/board/BoardComment.vue b/src/components/board/BoardComment.vue index 82b54ea..4ad12f7 100644 --- a/src/components/board/BoardComment.vue +++ b/src/components/board/BoardComment.vue @@ -59,7 +59,7 @@ :isCommentProfile="true" :isCommentAuthor="child.isCommentAuthor" :isCommentPassword="isCommentPassword" - @editClick="handleReplyEditClick " + @editClick="handleReplyEditClick" @deleteClick="$emit('deleteClick', child)" @submitEdit="(comment, editedContent) => $emit('submitEdit', comment, editedContent)" @cancelEdit="$emit('cancelEdit', child)" @@ -110,7 +110,7 @@ const props = defineProps({ }, passwordCommentAlert: { type: String, - default: false + default: '' } }); @@ -164,8 +164,8 @@ const handleEditClick = () => { emit('editClick', props.comment); } -const handleReplyEditClick = (event) => { - emit('editClick', event); +const handleReplyEditClick = (comment) => { + emit('editClick', comment); } diff --git a/src/components/board/BoardCommentArea.vue b/src/components/board/BoardCommentArea.vue index c7cfe2c..ed153ab 100644 --- a/src/components/board/BoardCommentArea.vue +++ b/src/components/board/BoardCommentArea.vue @@ -73,11 +73,11 @@ const props = defineProps({ }, passwordAlert: { type: String, - default: false + default: '' }, commentAlert: { type: String, - default: false + default: '' } }); diff --git a/src/components/board/BoardCommentList.vue b/src/components/board/BoardCommentList.vue index 3c315a8..8ac413b 100644 --- a/src/components/board/BoardCommentList.vue +++ b/src/components/board/BoardCommentList.vue @@ -11,12 +11,11 @@ :isCommentAuthor="comment.isCommentAuthor" :isEditTextarea="comment.isEditTextarea" :isCommentPassword="isCommentPassword" - :passwordCommentAlert="passwordCommentAlert" + :passwordCommentAlert="passwordCommentAlert || ''" @editClick="handleEditClick" @deleteClick="handleDeleteClick" @submitPassword="submitPassword" @submitComment="submitComment" - @commentDeleted="handleCommentDeleted" @submitEdit="handleSubmitEdit" @cancelEdit="handleCancelEdit" @updateReaction="(reactionData) => handleUpdateReaction(reactionData, comment.commentId, comment.boardId)" @@ -53,11 +52,11 @@ const props = defineProps({ }, passwordCommentAlert: { type: String, - default: false + default: '' } }); -const emit = defineEmits(['submitComment', 'updateReaction', 'editClick', 'deleteClick', 'submitPassword', 'clearPassword']); +const emit = defineEmits(['submitComment', 'updateReaction', 'editClick', 'deleteClick', 'submitPassword', 'clearPassword','submitEdit']); const submitComment = (replyData) => { emit('submitComment', replyData); @@ -79,9 +78,9 @@ const submitPassword = (comment, password) => { const handleEditClick = (comment) => { if (comment.parentId) { - emit('deleteClick', comment); // 대댓글 + emit('editClick', comment); // 대댓글 } else { - emit('deleteClick', comment); // 댓글 + emit('editClick', comment); // 댓글 } }; diff --git a/src/components/board/BoardProfile.vue b/src/components/board/BoardProfile.vue index cf43b87..e357e1d 100644 --- a/src/components/board/BoardProfile.vue +++ b/src/components/board/BoardProfile.vue @@ -82,7 +82,7 @@ const props = defineProps({ isCommentProfile: Boolean, // 현재 컴포넌트가 댓글용인지 여부 date: { type: String, - required: true, + required: '', }, views: { type: Number, diff --git a/src/components/button/BoardRecommendBtn.vue b/src/components/button/BoardRecommendBtn.vue index e297eb7..8ffa805 100644 --- a/src/components/button/BoardRecommendBtn.vue +++ b/src/components/button/BoardRecommendBtn.vue @@ -13,7 +13,7 @@ import { ref, computed } from 'vue'; const props = defineProps({ comment: { type: Object, - required: true, + default: () => ({}), }, likeClicked : { type : Boolean, @@ -36,7 +36,7 @@ const props = defineProps({ required: true, }, commentId: { - type: Number, + type: [Number, null], default: null, }, likeCount: { diff --git a/src/views/board/BoardView.vue b/src/views/board/BoardView.vue index cfacd8f..358c192 100644 --- a/src/views/board/BoardView.vue +++ b/src/views/board/BoardView.vue @@ -175,6 +175,7 @@ const passwordAlert = ref(""); const passwordCommentAlert = ref(""); const isPassword = ref(false); const isCommentPassword = ref(false); +const currentPasswordCommentId = ref(null); const lastClickedButton = ref(""); const lastCommentClickedButton = ref(""); const isEditTextarea = ref(false); @@ -487,6 +488,7 @@ const deleteComment = async (comment) => { // 익명 비밀번호 창 토글 const toggleCommentPassword = (comment, button) => { + console.log(comment.commentId) if (lastCommentClickedButton.value === button && isCommentPassword.value === comment.commentId) { isCommentPassword.value = false; // 비밀번호 창 닫기 } else { @@ -637,7 +639,6 @@ const deleteReplyComment = async (comment) => { // 댓글 수정 확인 const handleSubmitEdit = async (comment, editedContent) => { - console.log('asdasdasdasd') try { const response = await axios.put(`board/comment/${comment.commentId}`, { LOCCMTSEQ: comment.commentId, From 4720e619581dc57a57d42ac8ba2595028ec9b9e2 Mon Sep 17 00:00:00 2001 From: kimdaae328 Date: Fri, 28 Feb 2025 11:09:10 +0900 Subject: [PATCH 08/12] =?UTF-8?q?warning=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/board/BoardComment.vue | 6 +++++- src/components/board/BoardCommentList.vue | 4 ++++ src/views/board/BoardView.vue | 7 ++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/components/board/BoardComment.vue b/src/components/board/BoardComment.vue index 4ad12f7..01879d2 100644 --- a/src/components/board/BoardComment.vue +++ b/src/components/board/BoardComment.vue @@ -16,7 +16,7 @@ @updateReaction="handleUpdateReaction" /> -
+
{ // 익명 비밀번호 창 토글 const toggleCommentPassword = (comment, button) => { console.log(comment.commentId) - if (lastCommentClickedButton.value === button && isCommentPassword.value === comment.commentId) { - isCommentPassword.value = false; // 비밀번호 창 닫기 + if (lastCommentClickedButton.value === button && currentPasswordCommentId.value === comment.commentId) { + currentPasswordCommentId.value = null; // 비밀번호 창 닫기 } else { - isCommentPassword.value = comment.commentId; // 비밀번호 창 열기 + currentPasswordCommentId.value = comment.commentId; // 비밀번호 창 열기 } lastCommentClickedButton.value = button; From 3678b40e1cf17d5de15bad7c6a9f868d3db30bdf Mon Sep 17 00:00:00 2001 From: kimdaae328 Date: Fri, 28 Feb 2025 12:01:59 +0900 Subject: [PATCH 09/12] =?UTF-8?q?=EB=8C=93=EA=B8=80=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/board/BoardComment.vue | 29 ++++++++++++++++------- src/components/board/BoardCommentList.vue | 19 ++++++++++++++- src/components/board/BoardProfile.vue | 2 +- src/views/board/BoardView.vue | 15 ++++++++---- 4 files changed, 51 insertions(+), 14 deletions(-) diff --git a/src/components/board/BoardComment.vue b/src/components/board/BoardComment.vue index 01879d2..9c81151 100644 --- a/src/components/board/BoardComment.vue +++ b/src/components/board/BoardComment.vue @@ -21,8 +21,9 @@
@@ -42,7 +43,7 @@
- +
    @@ -60,13 +61,18 @@ :isCommentAuthor="child.isCommentAuthor" :isCommentPassword="isCommentPassword" :currentPasswordCommentId="currentPasswordCommentId" + :passwordCommentAlert="passwordCommentAlert" + :password="password" + :commentAlert="commentAlert" + :passwordAlert="passwordAlert" @editClick="handleReplyEditClick" @deleteClick="$emit('deleteClick', child)" @submitEdit="(comment, editedContent) => $emit('submitEdit', comment, editedContent)" @cancelEdit="$emit('cancelEdit', child)" @submitComment="submitComment" @updateReaction="handleUpdateReaction" - @submitPassword="logPasswordAndEmit" + @submitPassword="$emit('submitPassword', child, password)" + @update:password="$emit('update:password', $event)" />
@@ -115,13 +121,21 @@ const props = defineProps({ }, currentPasswordCommentId: { type: Number + }, + password:{ + type: String + }, + commentAlert: { + type: String, + }, + passwordAlert: { + type: String, } }); // emits 정의 -const emit = defineEmits(['submitComment', 'updateReaction', 'editClick', 'deleteClick', 'submitPassword', 'submitEdit', 'cancelEdit']); +const emit = defineEmits(['submitComment', 'updateReaction', 'editClick', 'deleteClick', 'submitPassword', 'submitEdit', 'cancelEdit', 'update:password']); -const password = ref(''); const localEditedContent = ref(props.comment.content); // 댓글 입력 창 토글 @@ -148,9 +162,8 @@ const handleUpdateReaction = (reactionData) => { // 비밀번호 확인 const logPasswordAndEmit = () => { - console.log('비밀번호 확인',password.value) - emit('submitPassword', props.comment, password.value); - password.value = ""; + console.log('비밀번호 확인',props.password) + emit('submitPassword', props.comment, props.password); }; watch(() => props.comment.isEditTextarea, (newVal) => { diff --git a/src/components/board/BoardCommentList.vue b/src/components/board/BoardCommentList.vue index 928c281..667a8ec 100644 --- a/src/components/board/BoardCommentList.vue +++ b/src/components/board/BoardCommentList.vue @@ -13,6 +13,9 @@ :isCommentPassword="isCommentPassword" :passwordCommentAlert="passwordCommentAlert || ''" :currentPasswordCommentId="currentPasswordCommentId" + :password="password" + :commentAlert="commentAlert" + :passwordAlert="passwordAlert" @editClick="handleEditClick" @deleteClick="handleDeleteClick" @submitPassword="submitPassword" @@ -20,6 +23,7 @@ @submitEdit="handleSubmitEdit" @cancelEdit="handleCancelEdit" @updateReaction="(reactionData) => handleUpdateReaction(reactionData, comment.commentId, comment.boardId)" + @update:password="updatePassword" /> @@ -57,10 +61,19 @@ const props = defineProps({ }, currentPasswordCommentId: { type: Number + }, + password:{ + type: String + }, + commentAlert: { + type: String, + }, + passwordAlert: { + type: String, } }); -const emit = defineEmits(['submitComment', 'updateReaction', 'editClick', 'deleteClick', 'submitPassword', 'clearPassword','submitEdit']); +const emit = defineEmits(['submitComment', 'updateReaction', 'editClick', 'deleteClick', 'submitPassword', 'clearPassword','submitEdit', 'update:password']); const submitComment = (replyData) => { emit('submitComment', replyData); @@ -107,4 +120,8 @@ const handleCancelEdit = (comment) => { emit('cancelEdit', comment); // 댓글 수정 취소 } }; + +const updatePassword = (newPassword) => { + emit('update:password', newPassword); +}; diff --git a/src/components/board/BoardProfile.vue b/src/components/board/BoardProfile.vue index e357e1d..71c1c2e 100644 --- a/src/components/board/BoardProfile.vue +++ b/src/components/board/BoardProfile.vue @@ -95,7 +95,7 @@ const props = defineProps({ isLike: { type: Boolean, default: false, - }, + } }); const emit = defineEmits(['updateReaction', 'editClick', 'deleteClick']); diff --git a/src/views/board/BoardView.vue b/src/views/board/BoardView.vue index 63329d5..7233cce 100644 --- a/src/views/board/BoardView.vue +++ b/src/views/board/BoardView.vue @@ -27,6 +27,7 @@ class="form-control" v-model="password" placeholder="비밀번호 입력" + @input="password = password.replace(/\s/g, '')" />
@@ -103,6 +104,9 @@ :isEditTextarea="isEditTextarea" :passwordCommentAlert="passwordCommentAlert" :currentPasswordCommentId="currentPasswordCommentId" + :password="password" + :commentAlert="commentAlert" + :passwordAlert="passwordAlert" @editClick="editComment" @deleteClick="deleteComment" @updateReaction="handleCommentReaction" @@ -111,6 +115,7 @@ @commentDeleted="handleCommentDeleted" @cancelEdit="handleCancelEdit" @submitEdit="handleSubmitEdit" + @update:password="updatePassword" /> { + password.value = newPassword; +}; const pagination = ref({ currentPage: 1, @@ -489,7 +498,6 @@ const deleteComment = async (comment) => { // 익명 비밀번호 창 토글 const toggleCommentPassword = (comment, button) => { - console.log(comment.commentId) if (lastCommentClickedButton.value === button && currentPasswordCommentId.value === comment.commentId) { currentPasswordCommentId.value = null; // 비밀번호 창 닫기 } else { @@ -510,7 +518,7 @@ const togglePassword = (button) => { // 게시글 비밀번호 제출 const submitPassword = async () => { - if (!password.value) { + if (!password.value.trim()) { passwordAlert.value = "비밀번호를 입력해주세요."; return; } @@ -620,7 +628,6 @@ const deletePost = async () => { // 댓글 삭제 (대댓글 포함) const deleteReplyComment = async (comment) => { - console.log('지금 여기') if (!confirm("정말 이 댓글을 삭제하시겠습니까?")) return; try { From 785df5c51f1af1fe36ed9ee1a065d9620e317fc9 Mon Sep 17 00:00:00 2001 From: kimdaae328 Date: Fri, 28 Feb 2025 12:18:09 +0900 Subject: [PATCH 10/12] =?UTF-8?q?=EB=B9=84=EB=B0=80=EB=B2=88=ED=98=B8=20?= =?UTF-8?q?=EC=9E=85=EB=A0=A5=EC=B0=BD=20=EC=B4=88=EA=B8=B0=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/board/BoardComment.vue | 10 +------- src/components/board/BoardCommentList.vue | 8 ------- src/views/board/BoardView.vue | 29 ++++++++++++++++------- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/src/components/board/BoardComment.vue b/src/components/board/BoardComment.vue index 9c81151..205d5a6 100644 --- a/src/components/board/BoardComment.vue +++ b/src/components/board/BoardComment.vue @@ -43,7 +43,7 @@ - +
    @@ -63,8 +63,6 @@ :currentPasswordCommentId="currentPasswordCommentId" :passwordCommentAlert="passwordCommentAlert" :password="password" - :commentAlert="commentAlert" - :passwordAlert="passwordAlert" @editClick="handleReplyEditClick" @deleteClick="$emit('deleteClick', child)" @submitEdit="(comment, editedContent) => $emit('submitEdit', comment, editedContent)" @@ -125,12 +123,6 @@ const props = defineProps({ password:{ type: String }, - commentAlert: { - type: String, - }, - passwordAlert: { - type: String, - } }); // emits 정의 diff --git a/src/components/board/BoardCommentList.vue b/src/components/board/BoardCommentList.vue index 667a8ec..1b47923 100644 --- a/src/components/board/BoardCommentList.vue +++ b/src/components/board/BoardCommentList.vue @@ -14,8 +14,6 @@ :passwordCommentAlert="passwordCommentAlert || ''" :currentPasswordCommentId="currentPasswordCommentId" :password="password" - :commentAlert="commentAlert" - :passwordAlert="passwordAlert" @editClick="handleEditClick" @deleteClick="handleDeleteClick" @submitPassword="submitPassword" @@ -65,12 +63,6 @@ const props = defineProps({ password:{ type: String }, - commentAlert: { - type: String, - }, - passwordAlert: { - type: String, - } }); const emit = defineEmits(['submitComment', 'updateReaction', 'editClick', 'deleteClick', 'submitPassword', 'clearPassword','submitEdit', 'update:password']); diff --git a/src/views/board/BoardView.vue b/src/views/board/BoardView.vue index 7233cce..91c7e29 100644 --- a/src/views/board/BoardView.vue +++ b/src/views/board/BoardView.vue @@ -105,8 +105,6 @@ :passwordCommentAlert="passwordCommentAlert" :currentPasswordCommentId="currentPasswordCommentId" :password="password" - :commentAlert="commentAlert" - :passwordAlert="passwordAlert" @editClick="editComment" @deleteClick="deleteComment" @updateReaction="handleCommentReaction" @@ -412,7 +410,7 @@ const handleCommentReply = async (reply) => { }); if (response.status === 200) { - if (response.data.code === 200) { + if (response.data.code === 200) { await fetchComments(); } else { alert('대댓글 작성을 실패했습니다.'); @@ -459,8 +457,12 @@ const findCommentById = (commentId, commentsList) => { return null; }; -// 댓글 수정 버튼 클릭 +// 댓글 수정(대댓글 포함) const editComment = (comment) => { + password.value = ''; + passwordCommentAlert.value = ''; + currentPasswordCommentId.value = null; + const targetComment = findCommentById(comment.commentId, comments.value); if (!targetComment) { @@ -496,12 +498,16 @@ const deleteComment = async (comment) => { } }; -// 익명 비밀번호 창 토글 +// 익명 댓글 비밀번호 창 토글 const toggleCommentPassword = (comment, button) => { if (lastCommentClickedButton.value === button && currentPasswordCommentId.value === comment.commentId) { currentPasswordCommentId.value = null; // 비밀번호 창 닫기 + password.value = ''; + passwordCommentAlert.value = ''; } else { currentPasswordCommentId.value = comment.commentId; // 비밀번호 창 열기 + password.value = ''; + passwordCommentAlert.value = ''; } lastCommentClickedButton.value = button; @@ -557,7 +563,7 @@ const submitPassword = async () => { } }; -// 댓글 삭제 (비밀번호 확인 후) +// 댓글 (비밀번호 확인 후) const submitCommentPassword = async (comment, password) => { if (!password) { passwordCommentAlert.value = "비밀번호를 입력해주세요."; @@ -573,20 +579,25 @@ const submitCommentPassword = async (comment, password) => { }); if (response.data.code === 200 && response.data.data === true) { - passwordCommentAlert.value = ""; + passwordCommentAlert.value = ''; comment.isCommentPassword = false; + // 수정 if (lastCommentClickedButton.value === "edit") { if (targetComment) { + currentPasswordCommentId.value = null; + password.value = ''; + passwordCommentAlert.value = ''; + targetComment.isEditTextarea = true; - passwordCommentAlert.value = ""; } else { alert("수정 취소를 실패했습니다."); } + //삭제 } else if (lastCommentClickedButton.value === "delete") { - passwordCommentAlert.value = ""; + passwordCommentAlert.value = ''; deleteReplyComment(comment) } From 421ec4eaec925d3765c9c9c719fb968504c2bdac Mon Sep 17 00:00:00 2001 From: kimdaae328 Date: Fri, 28 Feb 2025 13:02:55 +0900 Subject: [PATCH 11/12] =?UTF-8?q?=EC=9D=B5=EB=AA=85=20=EB=8C=93=EA=B8=80?= =?UTF-8?q?=20=EB=B9=84=EB=B0=80=EB=B2=88=ED=98=B8=20=EB=82=98=EC=98=A4?= =?UTF-8?q?=EB=8A=94=EA=B3=B3=20=EC=88=98=EC=A0=95=ED=95=B4=EC=95=BC?= =?UTF-8?q?=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/board/BoardView.vue | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/views/board/BoardView.vue b/src/views/board/BoardView.vue index 91c7e29..3eca89b 100644 --- a/src/views/board/BoardView.vue +++ b/src/views/board/BoardView.vue @@ -579,25 +579,24 @@ const submitCommentPassword = async (comment, password) => { }); if (response.data.code === 200 && response.data.data === true) { - passwordCommentAlert.value = ''; + passwordCommentAlert.value = ""; comment.isCommentPassword = false; // 수정 if (lastCommentClickedButton.value === "edit") { if (targetComment) { - currentPasswordCommentId.value = null; - password.value = ''; - passwordCommentAlert.value = ''; - + currentPasswordCommentId.value = false; + //여기서 input 창 닫혀야함 targetComment.isEditTextarea = true; + passwordCommentAlert.value = ""; } else { alert("수정 취소를 실패했습니다."); } //삭제 } else if (lastCommentClickedButton.value === "delete") { - passwordCommentAlert.value = ''; + passwordCommentAlert.value = ""; deleteReplyComment(comment) } From 613d9f4c163e0015fea8b3c0ed5bcd0f7b546760 Mon Sep 17 00:00:00 2001 From: kimdaae328 Date: Fri, 28 Feb 2025 13:17:12 +0900 Subject: [PATCH 12/12] =?UTF-8?q?=EC=9D=B4=EB=AF=B8=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=EC=A4=91=EC=9D=B4=EB=A9=B4=20=EB=B9=84=EB=B0=80=EB=B2=88?= =?UTF-8?q?=ED=98=B8=20=EC=B0=BD=20no?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/board/BoardView.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/views/board/BoardView.vue b/src/views/board/BoardView.vue index 3eca89b..08411aa 100644 --- a/src/views/board/BoardView.vue +++ b/src/views/board/BoardView.vue @@ -476,6 +476,7 @@ const editComment = (comment) => { targetComment.isEditTextarea = !targetComment.isEditTextarea; lastCommentClickedButton.value = "edit"; } else if (isAnonymous) { + if (targetComment.isEditTextarea) return; toggleCommentPassword(comment, "edit"); } else { alert("수정이 불가능합니다"); @@ -586,10 +587,10 @@ const submitCommentPassword = async (comment, password) => { if (lastCommentClickedButton.value === "edit") { if (targetComment) { - currentPasswordCommentId.value = false; //여기서 input 창 닫혀야함 targetComment.isEditTextarea = true; passwordCommentAlert.value = ""; + currentPasswordCommentId.value = null; } else { alert("수정 취소를 실패했습니다.");