This commit is contained in:
parent
942f2c660c
commit
c730ea6cd3
@ -71,7 +71,11 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- HTML 콘텐츠 렌더링 -->
|
<!-- 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">
|
<div class="row justify-content-center my-10">
|
||||||
@ -300,7 +304,7 @@
|
|||||||
LOCGOBBAD: isDislike ? 'T' : 'F',
|
LOCGOBBAD: isDislike ? 'T' : 'F',
|
||||||
});
|
});
|
||||||
|
|
||||||
await fetchComments();
|
fetchComments(pagination.value.currentPage);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 댓글 목록 조회
|
// 댓글 목록 조회
|
||||||
@ -324,8 +328,10 @@
|
|||||||
profileImg: comment.profileImg || '',
|
profileImg: comment.profileImg || '',
|
||||||
likeClicked: comment.likeClicked || false,
|
likeClicked: comment.likeClicked || false,
|
||||||
dislikeClicked: comment.dislikeClicked || false,
|
dislikeClicked: comment.dislikeClicked || false,
|
||||||
createdAtRaw: new Date(comment.LOCCMTRDT), // 정렬용
|
// createdAtRaw: new Date(comment.LOCCMTRDT), // 정렬용
|
||||||
createdAt: formattedDate(comment.LOCCMTRDT), // 표시용
|
// createdAt: formattedDate(comment.LOCCMTRDT), // 표시용
|
||||||
|
createdAtRaw: new Date(comment.LOCCMTUDT), // 수정순
|
||||||
|
createdAt: formattedDate(comment.LOCCMTUDT), // 수정순
|
||||||
children: [], // 대댓글을 담을 배열
|
children: [], // 대댓글을 담을 배열
|
||||||
updateAtRaw: comment.LOCCMTUDT,
|
updateAtRaw: comment.LOCCMTUDT,
|
||||||
}));
|
}));
|
||||||
@ -348,8 +354,10 @@
|
|||||||
boardId: reply.LOCBRDSEQ,
|
boardId: reply.LOCBRDSEQ,
|
||||||
parentId: reply.LOCCMTPNT, // 부모 댓글 ID
|
parentId: reply.LOCCMTPNT, // 부모 댓글 ID
|
||||||
content: reply.LOCCMTRPY || '내용 없음',
|
content: reply.LOCCMTRPY || '내용 없음',
|
||||||
createdAtRaw: new Date(reply.LOCCMTRDT),
|
// createdAtRaw: new Date(reply.LOCCMTRDT),
|
||||||
createdAt: formattedDate(reply.LOCCMTRDT),
|
// createdAt: formattedDate(reply.LOCCMTRDT),
|
||||||
|
createdAtRaw: new Date(reply.LOCCMTUDT),
|
||||||
|
createdAt: formattedDate(reply.LOCCMTUDT),
|
||||||
likeCount: reply.likeCount || 0,
|
likeCount: reply.likeCount || 0,
|
||||||
dislikeCount: reply.dislikeCount || 0,
|
dislikeCount: reply.dislikeCount || 0,
|
||||||
likeClicked: false,
|
likeClicked: false,
|
||||||
@ -426,27 +434,16 @@
|
|||||||
|
|
||||||
// 대댓글 추가
|
// 대댓글 추가
|
||||||
const handleCommentReply = async reply => {
|
const handleCommentReply = async reply => {
|
||||||
try {
|
const response = await axios.post(`board/${currentBoardId.value}/comment`, {
|
||||||
const response = await axios.post(`board/${currentBoardId.value}/comment`, {
|
LOCBRDSEQ: currentBoardId.value,
|
||||||
LOCBRDSEQ: currentBoardId.value,
|
LOCCMTRPY: reply.comment,
|
||||||
LOCCMTRPY: reply.comment,
|
LOCCMTPWD: reply.password || null,
|
||||||
LOCCMTPWD: reply.password || null,
|
LOCCMTPNT: reply.parentId,
|
||||||
LOCCMTPNT: reply.parentId,
|
LOCBRDTYP: reply.isCheck ? '300102' : null,
|
||||||
LOCBRDTYP: reply.isCheck ? '300102' : null,
|
});
|
||||||
});
|
|
||||||
|
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
if (response.data.code === 200) {
|
fetchComments(pagination.value.currentPage);
|
||||||
await fetchComments();
|
|
||||||
} else {
|
|
||||||
alert('대댓글 작성을 실패했습니다.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
if (error.response) {
|
|
||||||
alert('오류가 발생했습니다.');
|
|
||||||
}
|
|
||||||
alert('오류가 발생했습니다.');
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -490,7 +487,7 @@
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 댓글 수정(대댓글 포함)
|
// 댓글 수정 클릭 시 이벤트(대댓글 포함)
|
||||||
const editComment = comment => {
|
const editComment = comment => {
|
||||||
password.value = '';
|
password.value = '';
|
||||||
passwordCommentAlert.value = '';
|
passwordCommentAlert.value = '';
|
||||||
@ -676,9 +673,6 @@
|
|||||||
passwordCommentAlert.value = '비밀번호가 일치하지 않습니다.';
|
passwordCommentAlert.value = '비밀번호가 일치하지 않습니다.';
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response?.status === 401) {
|
|
||||||
passwordCommentAlert.value = '비밀번호가 일치하지 않습니다';
|
|
||||||
}
|
|
||||||
passwordCommentAlert.value = '비밀번호가 일치하지 않습니다';
|
passwordCommentAlert.value = '비밀번호가 일치하지 않습니다';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -720,7 +714,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (response.data.code === 200) {
|
if (response.data.code === 200) {
|
||||||
await fetchComments();
|
await fetchComments(pagination.value.currentPage);
|
||||||
closeAllPasswordAreas();
|
closeAllPasswordAreas();
|
||||||
|
|
||||||
if (targetComment) {
|
if (targetComment) {
|
||||||
@ -740,28 +734,27 @@
|
|||||||
|
|
||||||
// 댓글 수정 확인
|
// 댓글 수정 확인
|
||||||
const handleSubmitEdit = async (comment, editedContent) => {
|
const handleSubmitEdit = async (comment, editedContent) => {
|
||||||
if (!checkValidation(comment, editedContent)) return;
|
if (!checkValidation(comment, editedContent)) return; //빈값 확인
|
||||||
togglePassword();
|
togglePassword();
|
||||||
try {
|
|
||||||
const response = await axios.put(`board/comment/${comment.commentId}`, {
|
|
||||||
LOCCMTSEQ: comment.commentId,
|
|
||||||
LOCCMTRPY: editedContent,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response.status === 200) {
|
const response = await axios.put(`board/comment/${comment.commentId}`, {
|
||||||
const targetComment = findCommentById(comment.commentId, comments.value);
|
LOCCMTSEQ: comment.commentId,
|
||||||
if (targetComment) {
|
LOCCMTRPY: editedContent.trim(),
|
||||||
targetComment.content = editedContent; // 댓글 내용 업데이트
|
});
|
||||||
targetComment.isEditTextarea = false; // 수정 모드 닫기
|
|
||||||
togglePassword('close');
|
if (response.status === 200) {
|
||||||
} else {
|
togglePassword('close');
|
||||||
toastStore.onToast('수정할 댓글을 찾을 수 없습니다.', 'e');
|
fetchComments(pagination.value.currentPage);
|
||||||
}
|
return;
|
||||||
} else {
|
// const targetComment = findCommentById(comment.commentId, comments.value);
|
||||||
toastStore.onToast('댓글 수정 실패했습니다.', 'e');
|
|
||||||
}
|
// if (targetComment) {
|
||||||
} catch (error) {
|
// targetComment.content = editedContent.trim(); // 댓글 내용 업데이트
|
||||||
toastStore.onToast('댓글 수정 중 오류가 발생하였습니다.', 'e');
|
// targetComment.isEditTextarea = false; // 수정 모드 닫기
|
||||||
|
// togglePassword('close');
|
||||||
|
// }
|
||||||
|
} else {
|
||||||
|
toastStore.onToast('댓글 수정을 실패하였습니다', 'e');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user