From 29d8095107f6ae6adc8ea0f0127cfee1a817ceba Mon Sep 17 00:00:00 2001 From: nevermoregb Date: Tue, 18 Mar 2025 10:56:48 +0900 Subject: [PATCH] =?UTF-8?q?=EB=8C=93=EA=B8=80=20=EB=85=B8=EC=B6=9C=20?= =?UTF-8?q?=EA=B8=B0=EB=B3=B8=20=EC=B5=9C=EC=8B=A0=EC=88=9C,=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=EC=8B=9C=20=EC=88=98=EC=A0=95=EB=90=A8=20=EB=AC=B8?= =?UTF-8?q?=EA=B5=AC=20=ED=91=9C=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/useBoardAccessStore.js | 2 +- src/views/board/BoardView.vue | 80 ++++++++++++++++--------------- 2 files changed, 42 insertions(+), 40 deletions(-) diff --git a/src/stores/useBoardAccessStore.js b/src/stores/useBoardAccessStore.js index 1d33d88..541b77e 100644 --- a/src/stores/useBoardAccessStore.js +++ b/src/stores/useBoardAccessStore.js @@ -5,7 +5,7 @@ 수정일 : 설명 : 게시글 수정 시 비밀번호 적재용. */ -import { ref, computed, watch } from 'vue'; +import { ref } from 'vue'; import { defineStore } from 'pinia'; export const useBoardAccessStore = defineStore( diff --git a/src/views/board/BoardView.vue b/src/views/board/BoardView.vue index 9f7a992..d630a0d 100644 --- a/src/views/board/BoardView.vue +++ b/src/views/board/BoardView.vue @@ -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();