익명부분 수정중

This commit is contained in:
kimdaae328 2025-02-24 15:11:37 +09:00
parent 2ba5121c85
commit 170e472815
3 changed files with 40 additions and 25 deletions

View File

@ -8,7 +8,6 @@
:date="comment.createdAt"
:comment="comment"
:showDetail="false"
:author="true"
:isLike="!isLike"
:isCommentPassword="comment.isCommentPassword"
:isCommentProfile="true"
@ -16,6 +15,7 @@
@deleteClick="$emit('deleteClick', comment)"
@updateReaction="handleUpdateReaction"
/>
<!-- :author="true" -->
<!-- 댓글 비밀번호 입력창 (익명일 경우) -->
<div v-if="isCommentPassword && unknown" class="mt-3 w-25 ms-auto">
<div class="input-group">

View File

@ -101,6 +101,7 @@ const emit = defineEmits(['updateReaction', 'editClick', 'deleteClick']);
//
const editClick = () => {
console.log('클릭 확인')
emit('editClick', props.unknown);
};

View File

@ -163,6 +163,7 @@ const currentUserId = computed(() => userStore.user.id); // 현재 로그인한
const authorId = ref(''); // id
const isAuthor = computed(() => currentUserId.value === authorId.value);
// const isCommentAuthor =
const commentsWithAuthStatus = computed(() => {
const updatedComments = comments.value.map(comment => ({
...comment,
@ -459,34 +460,32 @@ const deleteClick = (unknown) => {
}
};
// ( )
//
const editComment = (comment) => {
if (comment.isEditTextarea) {
//
comment.isEditTextarea = false;
const targetComment = comments.value.find(c => c.commentId === comment.commentId);
if (!targetComment) {
return;
}
// text ,
if (targetComment.isEditTextarea) {
targetComment.isEditTextarea = false;
} else {
targetComment.isEditTextarea = true;
}
//
if (unknown.value) {
toggleCommentPassword(comment, "edit");
} else {
comment.isEditTextarea = true;
}
// comments.value.forEach(c => {
// c.isEditTextarea = false;
// c.isCommentPassword = false;
// });
// if (comment.unknown) {
// comment.isCommentPassword = true;
// } else {
// comment.isEditTextarea = true;
// }
}
// ( )
const deleteComment = (comment) => {
//
const deleteComment = async (comment) => {
//
if (unknown.value) {
if (comment.isEditTextarea) {
// ,
@ -497,8 +496,8 @@ const deleteComment = (comment) => {
toggleCommentPassword(comment, "delete");
}
} else {
//
comments.value = comments.value.filter(c => c.commentId !== comment.commentId);
// ( )
deleteReplyComment(comment)
}
};
@ -656,7 +655,7 @@ const deleteReplyComment = async (comment) => {
}
};
// ( )
//
const handleSubmitEdit = async (comment, editedContent) => {
try {
const response = await axios.put(`board/comment/${comment.commentId}`, {
@ -665,8 +664,14 @@ const handleSubmitEdit = async (comment, editedContent) => {
});
//
comment.content = editedContent;
comment.isEditTextarea = false;
// comment.content = editedContent;
// comment.isEditTextarea = false;
if (response.status === 200) {
//
await fetchComments();
} else {
console.log("❌ 댓글 수정 실패:", response.data);
}
} catch (error) {
console.error("댓글 수정 중 오류 발생:", error);
}
@ -675,7 +680,16 @@ const handleSubmitEdit = async (comment, editedContent) => {
// ( )
const handleCancelEdit = (comment) => {
console.log("BoardView.vue - 댓글 수정 취소:", comment);
comment.isEditTextarea = false;
// comments comment
const targetComment = comments.value.find(c => c.commentId === comment.commentId);
if (targetComment) {
console.log("✅ 원본 데이터 찾음, 수정 취소 처리 가능");
targetComment.isEditTextarea = false;
} else {
console.error("❌ 원본 데이터 찾을 수 없음, 수정 취소 실패");
}
};
//