익명 댓글 수정 수정중

This commit is contained in:
kimdaae328 2025-02-27 16:35:20 +09:00
parent b02d99e4b1
commit e30dd8f7b0
3 changed files with 6 additions and 30 deletions

View File

@ -11,12 +11,10 @@
:isLike="!isLike" :isLike="!isLike"
:isCommentPassword="isCommentPassword" :isCommentPassword="isCommentPassword"
:isCommentProfile="true" :isCommentProfile="true"
@editClick="aaaa" @editClick="handleEditClick"
@deleteClick="$emit('deleteClick', comment)" @deleteClick="$emit('deleteClick', comment)"
@updateReaction="handleUpdateReaction" @updateReaction="handleUpdateReaction"
/> />
<!-- <P>Commentpassssss: {{isCommentPassword}}</P> -->
<!-- :author="true" -->
<!-- 댓글 비밀번호 입력창 (익명일 경우) --> <!-- 댓글 비밀번호 입력창 (익명일 경우) -->
<div v-if="isCommentPassword === comment.commentId && unknown" class="mt-3 w-25 ms-auto"> <div v-if="isCommentPassword === comment.commentId && unknown" class="mt-3 w-25 ms-auto">
<div class="input-group"> <div class="input-group">
@ -30,16 +28,11 @@
</div> </div>
<span v-if="passwordCommentAlert" class="invalid-feedback d-block text-start">{{ passwordCommentAlert }}</span> <span v-if="passwordCommentAlert" class="invalid-feedback d-block text-start">{{ passwordCommentAlert }}</span>
</div> </div>
<!-- <p>authorId:{{ comment.authorId }}</p>
<p>코멘트 비교: {{comment.isCommentAuthor}}</p> -->
<div class="mt-6"> <div class="mt-6">
<template v-if="comment.isEditTextarea"> <template v-if="comment.isEditTextarea">
<textarea v-model="localEditedContent" class="form-control"></textarea> <textarea v-model="localEditedContent" class="form-control"></textarea>
<div class="mt-2 d-flex justify-content-end"> <div class="mt-2 d-flex justify-content-end">
<!-- <button class="btn btn-secondary me-2" @click="$emit('cancelEdit', comment)">취소</button> -->
<!-- <button class="btn btn-primary" @click="submitEdit">수정</button> -->
<SaveBtn class="btn btn-primary" @click="submitEdit"></SaveBtn> <SaveBtn class="btn btn-primary" @click="submitEdit"></SaveBtn>
</div> </div>
</template> </template>
@ -58,10 +51,6 @@
:key="child.commentId" :key="child.commentId"
class="mt-8 pt-6 ps-10 border-top" class="mt-8 pt-6 ps-10 border-top"
> >
<!-- <p>대댓글 데이터(JSON): {{ JSON.stringify(child, null, 2) }}</p> -->
<!-- <p>comment child: {{ comment.children }}</p> -->
<!-- :unknown="child.author === '익명'" -->
<p>child.isCommentPassword: {{ child.isCommentPassword }}</p>
<BoardComment <BoardComment
:comment="child" :comment="child"
:unknown="child.author === '익명'" :unknown="child.author === '익명'"
@ -169,7 +158,7 @@ const submitEdit = () => {
emit('submitEdit', props.comment, localEditedContent.value); emit('submitEdit', props.comment, localEditedContent.value);
}; };
const aaaa = () => { const handleEditClick = () => {
emit('editClick', props.comment); emit('editClick', props.comment);
} }

View File

@ -88,7 +88,6 @@ const isCheck = ref(props.unknown);
const emit = defineEmits(['submitComment']); const emit = defineEmits(['submitComment']);
const LOCBRDTYP = isCheck.value ? '300102' : null; const LOCBRDTYP = isCheck.value ? '300102' : null;
function handleCommentSubmit() { function handleCommentSubmit() {
console.log(isCheck.value)
emit('submitComment', { emit('submitComment', {
comment: comment.value, comment: comment.value,
password: isCheck.value ? password.value : '', password: isCheck.value ? password.value : '',

View File

@ -372,7 +372,6 @@ const fetchComments = async (page = 1) => {
// console.log("📌 :", comments.value); // console.log("📌 :", comments.value);
} catch (error) { } catch (error) {
alert('오류가 발생했습니다.'); alert('오류가 발생했습니다.');
// alert(' :', error); // alert(' :', error);
@ -410,21 +409,18 @@ const handleCommentSubmit = async (data) => {
}); });
if (response.status === 200) { if (response.status === 200) {
// console.log(' :', response.data.message);
passwordAlert.value = ''; passwordAlert.value = '';
commentAlert.value = ''; commentAlert.value = '';
await fetchComments(); await fetchComments();
} else { } else {
// console.error(' :', response.data.message);
alert("댓글 작성을 실패했습니다.") alert("댓글 작성을 실패했습니다.")
} }
} catch (error) { } catch (error) {
// console.error(' :', error);
alert("오류가 발생했습니다.") alert("오류가 발생했습니다.")
} }
}; };
// ( `BoardCommentList` ) //
const handleCommentReply = async (reply) => { const handleCommentReply = async (reply) => {
try { try {
const response = await axios.post(`board/${currentBoardId.value}/comment`, { const response = await axios.post(`board/${currentBoardId.value}/comment`, {
@ -437,17 +433,13 @@ const handleCommentReply = async (reply) => {
if (response.status === 200) { if (response.status === 200) {
if (response.data.code === 200) { // if (response.data.code === 200) { //
// console.log(' :', response.data);
await fetchComments(); // await fetchComments(); //
} else { } else {
// console.log(' - :', response.data);
alert('대댓글 작성을 실패했습니다.'); alert('대댓글 작성을 실패했습니다.');
} }
} }
} catch (error) { } catch (error) {
// console.error(' :', error);
if (error.response) { if (error.response) {
// console.error(' :', error.response.data);
alert("오류가 발생했습니다."); alert("오류가 발생했습니다.");
} }
alert("오류가 발생했습니다."); alert("오류가 발생했습니다.");
@ -504,11 +496,10 @@ const editComment = (comment) => {
if (isMyComment) { if (isMyComment) {
// //
targetComment.isEditTextarea = true; targetComment.isEditTextarea = !targetComment.isEditTextarea;
} else if (isAnonymous) { } else if (isAnonymous) {
// //
toggleCommentPassword(comment, "edit"); toggleCommentPassword(comment, "edit");
} else { } else {
// console.log(" - "); // console.log(" - ");
alert("수정이 불가능합니다"); alert("수정이 불가능합니다");
@ -545,8 +536,6 @@ const toggleCommentPassword = (comment, button) => {
lastCommentClickedButton.value = button; lastCommentClickedButton.value = button;
}; };
const togglePassword = (button) => { const togglePassword = (button) => {
if (lastClickedButton.value === button) { if (lastClickedButton.value === button) {
isPassword.value = !isPassword.value; isPassword.value = !isPassword.value;
@ -562,7 +551,6 @@ const submitPassword = async () => {
passwordAlert.value = "비밀번호를 입력해주세요."; passwordAlert.value = "비밀번호를 입력해주세요.";
return; return;
} }
// console.log("📌 : submitPassword ");
try { try {
const response = await axios.post(`board/${currentBoardId.value}/password`, { const response = await axios.post(`board/${currentBoardId.value}/password`, {
@ -674,7 +662,7 @@ const deletePost = async () => {
// ( ) // ( )
const deleteReplyComment = async (comment) => { const deleteReplyComment = async (comment) => {
if (!confirm("정말 이 댓글을 삭제하시겠습니까?")) return; if (!confirm("정말 이 댓글을 삭제하시겠습니까?")) return;
// console.log(" ID:", comment); console.log("댓글 수정, 대댓글도?");
try { try {
const response = await axios.delete(`board/comment/${comment.commentId}`, { const response = await axios.delete(`board/comment/${comment.commentId}`, {