댓글 업데이트 로직 변경
All checks were successful
LocalNet_front/pipeline/head This commit looks good

This commit is contained in:
nevermoregb 2025-03-17 22:47:57 +09:00
parent 942f2c660c
commit c730ea6cd3

View File

@ -71,7 +71,11 @@
</div>
<!-- HTML 콘텐츠 렌더링 -->
<div class="board-content text-body mw-100 overflow-hidden text-break" style="line-height: 1.6" v-html="$common.contentToHtml(boardContent)"></div>
<div
class="board-content text-body mw-100 overflow-hidden text-break"
style="line-height: 1.6"
v-html="$common.contentToHtml(boardContent)"
></div>
<!-- 좋아요 버튼 -->
<div class="row justify-content-center my-10">
@ -300,7 +304,7 @@
LOCGOBBAD: isDislike ? 'T' : 'F',
});
await fetchComments();
fetchComments(pagination.value.currentPage);
};
//
@ -324,8 +328,10 @@
profileImg: comment.profileImg || '',
likeClicked: comment.likeClicked || false,
dislikeClicked: comment.dislikeClicked || false,
createdAtRaw: new Date(comment.LOCCMTRDT), //
createdAt: formattedDate(comment.LOCCMTRDT), //
// createdAtRaw: new Date(comment.LOCCMTRDT), //
// createdAt: formattedDate(comment.LOCCMTRDT), //
createdAtRaw: new Date(comment.LOCCMTUDT), //
createdAt: formattedDate(comment.LOCCMTUDT), //
children: [], //
updateAtRaw: comment.LOCCMTUDT,
}));
@ -348,8 +354,10 @@
boardId: reply.LOCBRDSEQ,
parentId: reply.LOCCMTPNT, // ID
content: reply.LOCCMTRPY || '내용 없음',
createdAtRaw: new Date(reply.LOCCMTRDT),
createdAt: formattedDate(reply.LOCCMTRDT),
// createdAtRaw: new Date(reply.LOCCMTRDT),
// createdAt: formattedDate(reply.LOCCMTRDT),
createdAtRaw: new Date(reply.LOCCMTUDT),
createdAt: formattedDate(reply.LOCCMTUDT),
likeCount: reply.likeCount || 0,
dislikeCount: reply.dislikeCount || 0,
likeClicked: false,
@ -426,27 +434,16 @@
//
const handleCommentReply = async reply => {
try {
const response = await axios.post(`board/${currentBoardId.value}/comment`, {
LOCBRDSEQ: currentBoardId.value,
LOCCMTRPY: reply.comment,
LOCCMTPWD: reply.password || null,
LOCCMTPNT: reply.parentId,
LOCBRDTYP: reply.isCheck ? '300102' : null,
});
const response = await axios.post(`board/${currentBoardId.value}/comment`, {
LOCBRDSEQ: currentBoardId.value,
LOCCMTRPY: reply.comment,
LOCCMTPWD: reply.password || null,
LOCCMTPNT: reply.parentId,
LOCBRDTYP: reply.isCheck ? '300102' : null,
});
if (response.status === 200) {
if (response.data.code === 200) {
await fetchComments();
} else {
alert('대댓글 작성을 실패했습니다.');
}
}
} catch (error) {
if (error.response) {
alert('오류가 발생했습니다.');
}
alert('오류가 발생했습니다.');
if (response.status === 200) {
fetchComments(pagination.value.currentPage);
}
};
@ -490,7 +487,7 @@
return null;
};
// ( )
// ( )
const editComment = comment => {
password.value = '';
passwordCommentAlert.value = '';
@ -676,9 +673,6 @@
passwordCommentAlert.value = '비밀번호가 일치하지 않습니다.';
}
} catch (error) {
if (error.response?.status === 401) {
passwordCommentAlert.value = '비밀번호가 일치하지 않습니다';
}
passwordCommentAlert.value = '비밀번호가 일치하지 않습니다';
}
};
@ -720,7 +714,7 @@
});
if (response.data.code === 200) {
await fetchComments();
await fetchComments(pagination.value.currentPage);
closeAllPasswordAreas();
if (targetComment) {
@ -740,28 +734,27 @@
//
const handleSubmitEdit = async (comment, editedContent) => {
if (!checkValidation(comment, editedContent)) return;
if (!checkValidation(comment, editedContent)) return; //
togglePassword();
try {
const response = await axios.put(`board/comment/${comment.commentId}`, {
LOCCMTSEQ: comment.commentId,
LOCCMTRPY: editedContent,
});
if (response.status === 200) {
const targetComment = findCommentById(comment.commentId, comments.value);
if (targetComment) {
targetComment.content = editedContent; //
targetComment.isEditTextarea = false; //
togglePassword('close');
} else {
toastStore.onToast('수정할 댓글을 찾을 수 없습니다.', 'e');
}
} else {
toastStore.onToast('댓글 수정 실패했습니다.', 'e');
}
} catch (error) {
toastStore.onToast('댓글 수정 중 오류가 발생하였습니다.', 'e');
const response = await axios.put(`board/comment/${comment.commentId}`, {
LOCCMTSEQ: comment.commentId,
LOCCMTRPY: editedContent.trim(),
});
if (response.status === 200) {
togglePassword('close');
fetchComments(pagination.value.currentPage);
return;
// const targetComment = findCommentById(comment.commentId, comments.value);
// if (targetComment) {
// targetComment.content = editedContent.trim(); //
// targetComment.isEditTextarea = false; //
// togglePassword('close');
// }
} else {
toastStore.onToast('댓글 수정을 실패하였습니다', 'e');
}
};