This commit is contained in:
parent
942f2c660c
commit
c730ea6cd3
@ -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,7 +434,6 @@
|
||||
|
||||
// 대댓글 추가
|
||||
const handleCommentReply = async reply => {
|
||||
try {
|
||||
const response = await axios.post(`board/${currentBoardId.value}/comment`, {
|
||||
LOCBRDSEQ: currentBoardId.value,
|
||||
LOCCMTRPY: reply.comment,
|
||||
@ -436,17 +443,7 @@
|
||||
});
|
||||
|
||||
if (response.status === 200) {
|
||||
if (response.data.code === 200) {
|
||||
await fetchComments();
|
||||
} else {
|
||||
alert('대댓글 작성을 실패했습니다.');
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.response) {
|
||||
alert('오류가 발생했습니다.');
|
||||
}
|
||||
alert('오류가 발생했습니다.');
|
||||
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,
|
||||
LOCCMTRPY: editedContent.trim(),
|
||||
});
|
||||
|
||||
if (response.status === 200) {
|
||||
const targetComment = findCommentById(comment.commentId, comments.value);
|
||||
if (targetComment) {
|
||||
targetComment.content = editedContent; // 댓글 내용 업데이트
|
||||
targetComment.isEditTextarea = false; // 수정 모드 닫기
|
||||
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');
|
||||
}
|
||||
} else {
|
||||
toastStore.onToast('댓글 수정 실패했습니다.', 'e');
|
||||
}
|
||||
} catch (error) {
|
||||
toastStore.onToast('댓글 수정 중 오류가 발생하였습니다.', 'e');
|
||||
toastStore.onToast('댓글 수정을 실패하였습니다', 'e');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user