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