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 {