대댓글 수정중
This commit is contained in:
parent
4440946c74
commit
fdb2d81e53
@ -106,28 +106,12 @@ const submitComment = (newComment) => {
|
|||||||
|
|
||||||
// 좋아요, 싫어요
|
// 좋아요, 싫어요
|
||||||
const handleUpdateReaction = (reactionData) => {
|
const handleUpdateReaction = (reactionData) => {
|
||||||
// console.log('📌 BoardComment.vue에서 좋아요 이벤트 발생:', reactionData);
|
|
||||||
|
|
||||||
// if (!reactionData.commentId) {
|
|
||||||
// console.log("⚠️ reactionData.commentId가 존재하지 않음! 이 값이 null이 되어 덮어씌워질 가능성이 있음.");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// console.log('🟢 BoardComment.vue의 props.comment:', props.comment);
|
|
||||||
// console.log('🟢 BoardComment.vue의 commentId:', props.comment.commentId);
|
|
||||||
|
|
||||||
// console.log('🔍 emit 하기 전 reactionData:', {
|
|
||||||
// boardId: props.comment.boardId,
|
|
||||||
// commentId: props.comment.commentId,
|
|
||||||
// ...reactionData
|
|
||||||
// });
|
|
||||||
|
|
||||||
emit('updateReaction', {
|
emit('updateReaction', {
|
||||||
boardId: props.comment.boardId,
|
boardId: props.comment.boardId,
|
||||||
commentId: props.comment.commentId || reactionData.commentId, // 기존 reactionData에 commentId가 없으면 props.comment.commentId 사용
|
commentId: props.comment.commentId || reactionData.commentId,
|
||||||
...reactionData,
|
...reactionData,
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.log('🚀 emit 완료!');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 수정
|
// 수정
|
||||||
|
|||||||
@ -79,9 +79,7 @@ const isCheck = ref(props.unknown);
|
|||||||
const emit = defineEmits(['submitComment']);
|
const emit = defineEmits(['submitComment']);
|
||||||
|
|
||||||
watch(() => props.unknown, (newVal) => {
|
watch(() => props.unknown, (newVal) => {
|
||||||
if (!newVal) {
|
isCheck.value = newVal;
|
||||||
isCheck.value = false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function handleCommentSubmit() {
|
function handleCommentSubmit() {
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
:unknown="unknown"
|
:unknown="unknown"
|
||||||
:comment="comment"
|
:comment="comment"
|
||||||
:isPassword="isPassword"
|
:isPassword="isPassword"
|
||||||
|
:isEditTextarea="isEditTextarea"
|
||||||
@editClick="editClick"
|
@editClick="editClick"
|
||||||
@deleteClick="deleteClick"
|
@deleteClick="deleteClick"
|
||||||
@submitPassword="submitPassword"
|
@submitPassword="submitPassword"
|
||||||
@ -37,6 +38,10 @@ const props = defineProps({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
isEditTextarea: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['submitComment', 'updateReaction', 'editClick']);
|
const emit = defineEmits(['submitComment', 'updateReaction', 'editClick']);
|
||||||
|
|||||||
@ -149,7 +149,7 @@ const authorId = ref(null); // 작성자 id
|
|||||||
|
|
||||||
const isAuthor = computed(() => currentUserId.value === authorId.value);
|
const isAuthor = computed(() => currentUserId.value === authorId.value);
|
||||||
|
|
||||||
const isEditTextarea = ref({});
|
const isEditTextarea = ref(false);
|
||||||
|
|
||||||
const password = ref('');
|
const password = ref('');
|
||||||
const passwordAlert = ref("");
|
const passwordAlert = ref("");
|
||||||
@ -257,6 +257,7 @@ const handleCommentReaction = async ({ boardId, commentId, isLike, isDislike })
|
|||||||
// 댓글 목록 조회
|
// 댓글 목록 조회
|
||||||
const fetchComments = async (page = 1) => {
|
const fetchComments = async (page = 1) => {
|
||||||
try {
|
try {
|
||||||
|
// 댓글
|
||||||
const response = await axios.get(`board/${currentBoardId.value}/comments`, {
|
const response = await axios.get(`board/${currentBoardId.value}/comments`, {
|
||||||
params: {
|
params: {
|
||||||
LOCBRDSEQ: currentBoardId.value,
|
LOCBRDSEQ: currentBoardId.value,
|
||||||
@ -264,12 +265,14 @@ const fetchComments = async (page = 1) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 대댓글
|
||||||
const replyResponse = await axios.get(`board/${currentBoardId.value}/reply`, {
|
const replyResponse = await axios.get(`board/${currentBoardId.value}/reply`, {
|
||||||
params: { LOCBRDSEQ: currentBoardId.value }
|
params: {
|
||||||
|
LOCCMTPNT: 120
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.log("댓글:", response.data);
|
console.log(replyResponse.data)
|
||||||
console.log("대댓글:", replyResponse.data);
|
|
||||||
|
|
||||||
comments.value = response.data.data.list.map(comment => ({
|
comments.value = response.data.data.list.map(comment => ({
|
||||||
commentId: comment.LOCCMTSEQ, // 댓글 ID
|
commentId: comment.LOCCMTSEQ, // 댓글 ID
|
||||||
@ -286,8 +289,6 @@ const fetchComments = async (page = 1) => {
|
|||||||
children: [] // 대댓글을 담을 배열
|
children: [] // 대댓글을 담을 배열
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// console.log("변환 후 comments.value:", comments.value);
|
|
||||||
|
|
||||||
pagination.value = {
|
pagination.value = {
|
||||||
...pagination.value,
|
...pagination.value,
|
||||||
currentPage: response.data.data.pageNum, // 현재 페이지 번호
|
currentPage: response.data.data.pageNum, // 현재 페이지 번호
|
||||||
@ -310,6 +311,31 @@ const fetchComments = async (page = 1) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 대댓글 목록 조회
|
||||||
|
// const fetchReplies = async () => {
|
||||||
|
// try {
|
||||||
|
// const response = await axios.get(`board/${currentBoardId.value}/reply`);
|
||||||
|
|
||||||
|
// const replyData = response.data.data || [];
|
||||||
|
|
||||||
|
// return replyData.map(reply => ({
|
||||||
|
// commentId: reply.LOCCMTSEQ, // 대댓글 ID
|
||||||
|
// boardId: reply.LOCBRDSEQ,
|
||||||
|
// parentId: reply.LOCCMTPNT, // 부모 댓글 ID
|
||||||
|
// content: reply.LOCCMTRPY,
|
||||||
|
// createdAtRaw: new Date(reply.LOCCMTRDT), // 정렬용
|
||||||
|
// createdAt: formattedDate(reply.LOCCMTRDT), // 표시용
|
||||||
|
// likeCount: reply.likeCount || 0,
|
||||||
|
// dislikeCount: reply.dislikeCount || 0,
|
||||||
|
// likeClicked: false,
|
||||||
|
// dislikeClicked: false
|
||||||
|
// }));
|
||||||
|
// } catch (error) {
|
||||||
|
// console.error("대댓글 불러오기 오류:", error);
|
||||||
|
// return [];
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
// 댓글 작성
|
// 댓글 작성
|
||||||
const handleCommentSubmit = async ({ comment, password }) => {
|
const handleCommentSubmit = async ({ comment, password }) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user