댓글 노출 기본 최신순, 수정시 수정됨 문구 표기
This commit is contained in:
parent
03bb18a1e8
commit
29d8095107
@ -5,7 +5,7 @@
|
||||
수정일 :
|
||||
설명 : 게시글 수정 시 비밀번호 적재용.
|
||||
*/
|
||||
import { ref, computed, watch } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
export const useBoardAccessStore = defineStore(
|
||||
|
||||
@ -316,27 +316,27 @@
|
||||
page,
|
||||
},
|
||||
});
|
||||
const commentsList = response.data.data.list.map(comment => ({
|
||||
commentId: comment.LOCCMTSEQ, // 댓글 ID
|
||||
boardId: comment.LOCBRDSEQ,
|
||||
parentId: comment.LOCCMTPNT, // 부모 ID
|
||||
author: comment.author || '익명',
|
||||
authorId: comment.authorId,
|
||||
content: comment.LOCCMTRPY,
|
||||
likeCount: comment.likeCount || 0,
|
||||
dislikeCount: comment.dislikeCount || 0,
|
||||
profileImg: comment.profileImg || '',
|
||||
likeClicked: comment.likeClicked || false,
|
||||
dislikeClicked: comment.dislikeClicked || false,
|
||||
// createdAtRaw: new Date(comment.LOCCMTRDT), // 정렬용
|
||||
// createdAt: formattedDate(comment.LOCCMTRDT), // 표시용
|
||||
createdAtRaw: new Date(comment.LOCCMTUDT), // 수정순
|
||||
createdAt: formattedDate(comment.LOCCMTUDT), // 수정순
|
||||
children: [], // 대댓글을 담을 배열
|
||||
updateAtRaw: comment.LOCCMTUDT,
|
||||
}));
|
||||
|
||||
commentsList.sort((a, b) => b.createdAtRaw - a.createdAtRaw);
|
||||
const commentsList = response.data.data.list
|
||||
.map(comment => ({
|
||||
commentId: comment.LOCCMTSEQ, // 댓글 ID
|
||||
boardId: comment.LOCBRDSEQ,
|
||||
parentId: comment.LOCCMTPNT, // 부모 ID
|
||||
author: comment.author || '익명',
|
||||
authorId: comment.authorId,
|
||||
content: comment.LOCCMTRPY,
|
||||
likeCount: comment.likeCount || 0,
|
||||
dislikeCount: comment.dislikeCount || 0,
|
||||
profileImg: comment.profileImg || '',
|
||||
likeClicked: comment.likeClicked || false,
|
||||
dislikeClicked: comment.dislikeClicked || false,
|
||||
createdAtRaw: comment.LOCCMTRDT, // 작성일
|
||||
// createdAt: formattedDate(comment.LOCCMTRDT), // 작성일(노출용)
|
||||
// createdAtRaw: new Date(comment.LOCCMTUDT), // 수정순
|
||||
createdAt: formattedDate(comment.LOCCMTUDT) + (comment.LOCCMTUDT !== comment.LOCCMTRDT ? ' (수정됨)' : ''), // 수정일(노출용)
|
||||
children: [], // 대댓글을 담을 배열
|
||||
updateAtRaw: comment.LOCCMTUDT,
|
||||
}))
|
||||
.sort((a, b) => b.createdAtRaw - a.createdAtRaw);
|
||||
|
||||
for (const comment of commentsList) {
|
||||
if (!comment.commentId) continue;
|
||||
@ -346,23 +346,25 @@
|
||||
});
|
||||
|
||||
if (replyResponse.data.data) {
|
||||
comment.children = replyResponse.data.data.map(reply => ({
|
||||
author: reply.author || '익명',
|
||||
authorId: reply.authorId,
|
||||
profileImg: reply.profileImg || '',
|
||||
commentId: reply.LOCCMTSEQ,
|
||||
boardId: reply.LOCBRDSEQ,
|
||||
parentId: reply.LOCCMTPNT, // 부모 댓글 ID
|
||||
content: reply.LOCCMTRPY || '내용 없음',
|
||||
// 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,
|
||||
dislikeClicked: false,
|
||||
}));
|
||||
comment.children = replyResponse.data.data
|
||||
.map(reply => ({
|
||||
author: reply.author || '익명',
|
||||
authorId: reply.authorId,
|
||||
profileImg: reply.profileImg || '',
|
||||
commentId: reply.LOCCMTSEQ,
|
||||
boardId: reply.LOCBRDSEQ,
|
||||
parentId: reply.LOCCMTPNT, // 부모 댓글 ID
|
||||
content: reply.LOCCMTRPY || '내용 없음',
|
||||
createdAtRaw: reply.LOCCMTRDT,
|
||||
// createdAt: formattedDate(reply.LOCCMTRDT),
|
||||
//createdAtRaw: new Date(reply.LOCCMTUDT),
|
||||
createdAt: formattedDate(reply.LOCCMTUDT) + (reply.LOCCMTUDT !== reply.LOCCMTRDT ? ' (수정됨)' : ''),
|
||||
likeCount: reply.likeCount || 0,
|
||||
dislikeCount: reply.dislikeCount || 0,
|
||||
likeClicked: false,
|
||||
dislikeClicked: false,
|
||||
}))
|
||||
.sort((a, b) => b.createdAtRaw - a.createdAtRaw);
|
||||
} else {
|
||||
comment.children = []; // 대댓글이 없으면 빈 배열로 초기화
|
||||
}
|
||||
@ -732,7 +734,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
// 댓글 수정 확인
|
||||
// 댓글 수정
|
||||
const handleSubmitEdit = async (comment, editedContent) => {
|
||||
if (!checkValidation(comment, editedContent)) return; //빈값 확인
|
||||
togglePassword();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user