게시판머지2
This commit is contained in:
parent
f853c4e25d
commit
9937e8591e
@ -1,20 +1,20 @@
|
||||
<template>
|
||||
<div>
|
||||
<BoardProfile :profileName="comment.author" :showDetail="false" :author="true" />
|
||||
<div class="my-6">
|
||||
<p>{{ comment.content }}</p>
|
||||
<BoardProfile :profileName="comment.author" :showDetail="false" :author="true" :isChild="isChild" />
|
||||
<div class="mt-6">
|
||||
<p class="m-0">{{ comment.content }}</p>
|
||||
</div>
|
||||
<PlusButton v-if="isPlusButton" @click="toggleComment"/>
|
||||
<PlusButton v-if="isPlusButton" @click="toggleComment" class="mt-6"/>
|
||||
<BoardComentArea v-if="isComment" @submit="submitComment"/>
|
||||
|
||||
|
||||
<!-- 대댓글 -->
|
||||
<ul v-if="comment.children && comment.children.length" class="list-unstyled">
|
||||
<li
|
||||
v-for="child in comment.children"
|
||||
:key="child.id"
|
||||
class="pt-6 ps-10"
|
||||
class="pt-8 ps-10"
|
||||
>
|
||||
<BoardComment :comment="child" :isPlusButton="false" @submitComment="addChildComment" />
|
||||
<BoardComment :comment="child" :isPlusButton="false" :isChild="true" @submitComment="addChildComment" />
|
||||
</li>
|
||||
</ul>
|
||||
<!-- <ul class="list-unstyled twoDepth">
|
||||
@ -46,7 +46,11 @@ const props = defineProps({
|
||||
isPlusButton: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
}
|
||||
},
|
||||
isChild: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
// emits 정의
|
||||
|
||||
@ -3,18 +3,15 @@
|
||||
<li
|
||||
v-for="comment in comments"
|
||||
:key="comment.id"
|
||||
class="mt-6"
|
||||
class="mt-8"
|
||||
>
|
||||
<BoardComment :comment="comment" @submitComment="addComment" />
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<Pagination/>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import Pagination from '../pagination/Pagination.vue';
|
||||
import BoardComment from './BoardComment.vue'
|
||||
|
||||
const comments = ref([
|
||||
@ -48,4 +45,4 @@ const comments = ref([
|
||||
children: [],
|
||||
},
|
||||
]);
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<div class="d-flex justify-content-between align-items-center flex-wrap mb-6 gap-2">
|
||||
<!-- 제목 섹션 -->
|
||||
<div class="me-1">
|
||||
<h5 class="mb-0">{{ boardTitle }}</h5>
|
||||
<h5 class="mb-0">{{ boardTitle }}adada</h5>
|
||||
</div>
|
||||
<!-- 첨부파일 섹션 -->
|
||||
<div v-if="dropdownItems.length > 0" class="btn-group">
|
||||
|
||||
@ -104,6 +104,7 @@ const handleDelete = async () => {
|
||||
alert('게시물이 성공적으로 삭제되었습니다.');
|
||||
router.push({ name: 'BoardList' });
|
||||
} catch (error) {
|
||||
console.error('게시물 삭제 중 오류 발생:', error);
|
||||
alert('게시물 삭제에 실패했습니다.');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,14 +1,16 @@
|
||||
<template v-if="isRecommend">
|
||||
<button class="btn btn-label-primary btn-icon" :class="likeClicked ? 'clicked' : '', bigBtn ? 'big' : '' ">
|
||||
<i class="fa-regular fa-thumbs-up"></i> <span class="num">1</span>
|
||||
<button class="btn btn-label-primary btn-icon" :class="{'clicked': likeClicked, 'big': bigBtn}" @click="handleLike">
|
||||
<i class="fa-regular fa-thumbs-up"></i> <span class="num">{{ likeCount }}</span>
|
||||
</button>
|
||||
<button class="btn btn-label-danger btn-icon" :class="dislikeClicked ? 'clicked' : '', bigBtn ? 'big' : '' ">
|
||||
<i class="fa-regular fa-thumbs-down"></i> <span class="num">1</span>
|
||||
<button class="btn btn-label-danger btn-icon" :class="{'clicked': dislikeClicked, 'big': bigBtn}" @click="handleDislike">
|
||||
<i class="fa-regular fa-thumbs-down"></i> <span class="num">{{ dislikeCount }}</span>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
defineProps({
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
const props = defineProps({
|
||||
likeClicked : {
|
||||
type : Boolean,
|
||||
default : false,
|
||||
@ -24,14 +26,71 @@ defineProps({
|
||||
isRecommend: {
|
||||
type:Boolean,
|
||||
default:true,
|
||||
}
|
||||
},
|
||||
boardId: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
commentId: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
likeCount: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
dislikeCount: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['updateReaction']);
|
||||
|
||||
const likeClicked = ref(props.likeClicked);
|
||||
const dislikeClicked = ref(props.dislikeClicked);
|
||||
const likeCount = ref(props.likeCount);
|
||||
const dislikeCount = ref(props.dislikeCount);
|
||||
|
||||
// 부모에서 likeCount 또는 dislikeCount가 변경되면 로컬 상태를 업데이트
|
||||
watch(() => props.likeCount, (newVal) => {
|
||||
likeCount.value = newVal;
|
||||
});
|
||||
|
||||
watch(() => props.dislikeCount, (newVal) => {
|
||||
dislikeCount.value = newVal;
|
||||
});
|
||||
|
||||
const handleLike = () => {
|
||||
likeClicked.value = !likeClicked.value;
|
||||
likeCount.value += likeClicked.value ? 1 : -1;
|
||||
emit('updateReaction', { type: 'like', boardId: props.boardId, commentId: props.commentId });
|
||||
if(likeClicked.value === true){
|
||||
if(dislikeClicked.value === true) {
|
||||
dislikeClicked.value = false;
|
||||
dislikeCount.value += -1
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleDislike = () => {
|
||||
dislikeClicked.value = !dislikeClicked.value;
|
||||
dislikeCount.value += dislikeClicked.value ? 1 : -1;
|
||||
emit('updateReaction', { type: 'dislike', boardId: props.boardId, commentId: props.commentId });
|
||||
if(dislikeClicked.value === true){
|
||||
if(likeClicked.value === true) {
|
||||
likeClicked.value = false;
|
||||
likeCount.value += -1
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.btn + .btn {
|
||||
margin-left: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.num {
|
||||
margin-left: 5px;
|
||||
@ -73,4 +132,4 @@ defineProps({
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@ -120,6 +120,7 @@ const fetchBoardDetails = async () => {
|
||||
|
||||
// API 응답 데이터 반영
|
||||
const boardDetail = data.boardDetail || {};
|
||||
// console.log('boardDetail:', boardDetail);
|
||||
|
||||
profileName.value = data.author || '익명 사용자';
|
||||
boardTitle.value = data.title || '제목 없음';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user