board-view-profile1 머지
This commit is contained in:
parent
dbc0ad83ae
commit
f853c4e25d
@ -10,13 +10,13 @@
|
|||||||
<span>2024.12.10 10:46</span>
|
<span>2024.12.10 10:46</span>
|
||||||
<template v-if="showDetail">
|
<template v-if="showDetail">
|
||||||
<span>
|
<span>
|
||||||
<i class="fa-regular fa-eye"></i> 1
|
<i class="fa-regular fa-eye"></i> {{ views }}
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
<i class="fa-regular fa-thumbs-up"></i> 1
|
<i class="fa-regular fa-thumbs-up"></i> {{ likes }}
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
<i class="fa-regular fa-thumbs-down"></i> 1
|
<i class="fa-regular fa-thumbs-down"></i> {{ dislikes }}
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
@ -38,7 +38,7 @@
|
|||||||
<i class='bx bx-trash'></i>
|
<i class='bx bx-trash'></i>
|
||||||
</button> -->
|
</button> -->
|
||||||
</template>
|
</template>
|
||||||
<BoardRecommendBtn :likeClicked="true" :dislikeClicked="false" :isRecommend="false" />
|
<BoardRecommendBtn v-if="!isChild" :isRecommend="false" />
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -50,13 +50,12 @@ import axios from '@api';
|
|||||||
import DeleteButton from '../button/DeleteBtn.vue';
|
import DeleteButton from '../button/DeleteBtn.vue';
|
||||||
import EditButton from '../button/EditBtn.vue';
|
import EditButton from '../button/EditBtn.vue';
|
||||||
import BoardRecommendBtn from '../button/BoardRecommendBtn.vue';
|
import BoardRecommendBtn from '../button/BoardRecommendBtn.vue';
|
||||||
import { onMounted } from 'vue';
|
|
||||||
|
|
||||||
// Vue Router 인스턴스
|
// Vue Router 인스턴스
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
// Props 정의
|
// Props 정의
|
||||||
defineProps({
|
const props = defineProps({
|
||||||
profileName: {
|
profileName: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '익명',
|
default: '익명',
|
||||||
@ -73,6 +72,22 @@ defineProps({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
views: {
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
|
likes: {
|
||||||
|
type: Number,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
dislikes: {
|
||||||
|
type: Number,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
isChild: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const boardId = 100; //수정필요!!
|
const boardId = 100; //수정필요!!
|
||||||
@ -89,7 +104,6 @@ const handleDelete = async () => {
|
|||||||
alert('게시물이 성공적으로 삭제되었습니다.');
|
alert('게시물이 성공적으로 삭제되었습니다.');
|
||||||
router.push({ name: 'BoardList' });
|
router.push({ name: 'BoardList' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('게시물 삭제 중 오류 발생:', error);
|
|
||||||
alert('게시물 삭제에 실패했습니다.');
|
alert('게시물 삭제에 실패했습니다.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,59 +1,54 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="card mb-3 shadow-sm">
|
<div class="card mb-3 shadow-sm fixed-card" style="width: 18rem;">
|
||||||
<div class="row g-0">
|
<!-- 이미지가 있을 경우 card-img-top으로 표시 -->
|
||||||
<!-- 이미지 섹션 -->
|
|
||||||
<div v-if="img" class="col-sm-2">
|
|
||||||
<img
|
<img
|
||||||
|
v-if="img"
|
||||||
:src="img"
|
:src="img"
|
||||||
|
class="card-img-top"
|
||||||
alt="이미지"
|
alt="이미지"
|
||||||
class="img-fluid rounded-start"
|
style="object-fit: cover; height: 100px;"
|
||||||
style="object-fit: cover; height: 100%; width: 100%;"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
<!-- 게시물 내용 섹션 -->
|
|
||||||
<div :class="contentColClass">
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<!-- 태그 -->
|
<!-- 카테고리 태그 (존재할 경우) -->
|
||||||
<h6 class="badge rounded-pill bg-primary text-white mb-2">
|
<h6 v-if="category" class="badge rounded-pill bg-primary text-white mb-2">
|
||||||
{{ category }}
|
{{ category }}
|
||||||
</h6>
|
</h6>
|
||||||
<!-- 제목 -->
|
<!-- 제목과 첨부파일 아이콘 -->
|
||||||
<h5 class="card-title">
|
<h5 class="card-title">
|
||||||
{{ title }}
|
{{ title }}
|
||||||
<span class="text-muted me-3" v-if="attachment">
|
<span class="text-muted" v-if="attachment">
|
||||||
<i class="fa-solid fa-paperclip"></i>
|
<i class="fa-solid fa-paperclip"></i>
|
||||||
</span>
|
</span>
|
||||||
</h5>
|
</h5>
|
||||||
<!-- 본문 -->
|
<!-- 본문 -->
|
||||||
<div class="card-text str_wrap my-5">{{ content }}</div>
|
<p class="card-text limit-two-lines">{{ content }}</p>
|
||||||
<!-- 날짜 -->
|
<!-- 날짜 및 조회수, 좋아요, 댓글 -->
|
||||||
<div class="d-flex flex-column flex-sm-row justify-content-between align-items-start">
|
<p class="card-text">
|
||||||
<small class="text-muted">{{ formattedDate }}</small>
|
<small class="text-muted">{{ formattedDate }}</small>
|
||||||
<!-- 조회수, 좋아요, 댓글 -->
|
|
||||||
<div class="d-flex mt-2 mt-sm-0">
|
<div class="d-flex mt-2 mt-sm-0">
|
||||||
<span class="text-muted me-3">
|
<span class="text-muted me-3">
|
||||||
<i class="fa-regular fa-eye"></i> {{ views || 0 }}
|
<i class="fa-regular fa-eye"></i> {{ views || 0 }}
|
||||||
</span>
|
</span>
|
||||||
|
<span class="text-muted me-3" v-if="comments !== null">
|
||||||
|
<i class="bx bx-comment"></i> {{ comments }}
|
||||||
|
</span>
|
||||||
<span class="text-muted me-3" v-if="likes != null">
|
<span class="text-muted me-3" v-if="likes != null">
|
||||||
<i class="bx bx-like"></i> {{ likes }}
|
<i class="bx bx-like"></i> {{ likes }}
|
||||||
</span>
|
</span>
|
||||||
<span class="text-muted" v-if="comments !== null">
|
<span class="text-muted me-3" v-if="dislikes != null">
|
||||||
<i class="bx bx-comment"></i> {{ comments }}
|
<i class="bx bx-dislike"></i> {{ dislikes }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</template>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import { defineProps } from 'vue';
|
import { defineProps } from 'vue';
|
||||||
|
|
||||||
// Props 정의
|
const props = defineProps({
|
||||||
const props = defineProps({
|
|
||||||
img: {
|
img: {
|
||||||
type: String,
|
type: String,
|
||||||
default: null,
|
default: null,
|
||||||
@ -82,6 +77,10 @@ const props = defineProps({
|
|||||||
type: Number,
|
type: Number,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
|
dislikes: {
|
||||||
|
type: Number,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
comments: {
|
comments: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: null,
|
default: null,
|
||||||
@ -90,53 +89,36 @@ const props = defineProps({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// computed 속성
|
const formattedDate = computed(() => {
|
||||||
const contentColClass = computed(() => {
|
const dateObj = new Date(props.date);
|
||||||
return props.img ? 'col-sm-10 col-12' : 'col-sm-12';
|
return `${dateObj.getFullYear()}-${String(dateObj.getMonth() + 1).padStart(2, '0')}-${String(dateObj.getDate()).padStart(2, '0')} ${String(dateObj.getHours()).padStart(2, '0')}:${String(dateObj.getMinutes()).padStart(2, '0')}`;
|
||||||
});
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
// formattedDate을 computed로 정의
|
<style scoped>
|
||||||
const formattedDate = computed(() => {
|
.card {
|
||||||
const date = new Date(props.date);
|
|
||||||
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(
|
|
||||||
date.getDate()
|
|
||||||
).padStart(2, "0")} ${String(date.getHours()).padStart(2, "0")}:${String(
|
|
||||||
date.getMinutes()
|
|
||||||
).padStart(2, "0")}`;
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
/* 카드 스타일 */
|
|
||||||
.card {
|
|
||||||
border: 1px solid #e6e6e6;
|
border: 1px solid #e6e6e6;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
transition: transform 0.2s ease-in-out;
|
transition: transform 0.2s ease-in-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card:hover {
|
.card:hover {
|
||||||
transform: scale(1.02);
|
transform: scale(1.02);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 텍스트 줄임 표시 */
|
/* card-img-top의 모서리 둥글게 처리 */
|
||||||
.str_wrap {
|
.card-img-top {
|
||||||
overflow: hidden;
|
border-top-left-radius: 8px;
|
||||||
text-overflow: ellipsis;
|
border-top-right-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 내용 텍스트를 두 줄로 제한 */
|
||||||
|
.limit-two-lines {
|
||||||
display: -webkit-box;
|
display: -webkit-box;
|
||||||
-webkit-line-clamp: 2;
|
-webkit-line-clamp: 2;
|
||||||
-webkit-box-orient: vertical;
|
-webkit-box-orient: vertical;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
</style>
|
||||||
/* 이미지 스타일 */
|
|
||||||
.img-fluid {
|
|
||||||
border-radius: 8px 0 0 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 태그 배지 스타일 */
|
|
||||||
.badge {
|
|
||||||
font-size: 0.8rem;
|
|
||||||
padding: 5px 10px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="mt-4">
|
<div class="container my-4">
|
||||||
|
<div class="row">
|
||||||
<div v-if="posts.length === 0" class="text-center">
|
<div v-if="posts.length === 0" class="text-center">
|
||||||
<p class="text-muted mt-4">게시물이 없습니다.</p>
|
<p class="text-muted mt-4">게시물이 없습니다.</p>
|
||||||
</div>
|
</div>
|
||||||
<div v-for="post in posts" :key="post.id" @click="handleClick(post.id)">
|
<div class="col-md-3 mb-4 d-flex justify-content-center" v-for="post in posts" :key="post.id" @click="handleClick(post.id)">
|
||||||
<BoardCard
|
<BoardCard
|
||||||
:img="post.img || null"
|
:img="post.img || null"
|
||||||
:category="post.category || ''"
|
:category="post.category || ''"
|
||||||
@ -11,12 +12,15 @@
|
|||||||
:content="post.content"
|
:content="post.content"
|
||||||
:date="post.date"
|
:date="post.date"
|
||||||
:views="post.views || 0"
|
:views="post.views || 0"
|
||||||
|
:likes="post.likes"
|
||||||
|
:dislikes="post.dislikes"
|
||||||
v-bind="getBoardCardProps(post)"
|
v-bind="getBoardCardProps(post)"
|
||||||
:attachment="post.attachment || false"
|
:attachment="post.attachment || false"
|
||||||
@click="() => goDetail(post.id)"
|
@click="() => goDetail(post.id)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<div class="container flex-grow-1 container-p-y">
|
<div class="container flex-grow-1 container-p-y">
|
||||||
<div class="row mb-4">
|
<div class="row mb-4">
|
||||||
<!-- 검색창 -->
|
<!-- 검색창 -->
|
||||||
<div class="container col-9 px-10 ">
|
<div class="container col-11 px-10 ">
|
||||||
<search-bar @update:data="search" />
|
<search-bar @update:data="search" />
|
||||||
</div>
|
</div>
|
||||||
<!-- 새 글쓰기 -->
|
<!-- 새 글쓰기 -->
|
||||||
@ -13,23 +13,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container flex-grow-1 container-p-y col-11">
|
|
||||||
|
|
||||||
<!-- 공지사항 리스트 -->
|
|
||||||
<div v-if="pagination.currentPage === 1" class="mb-8">
|
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
<h3>공지사항</h3>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<BoardCardList :posts="noticeList" @click="goDetail" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 일반 리스트 -->
|
|
||||||
<div>
|
|
||||||
<div class="row g-3">
|
|
||||||
<h3 class="col">일반게시판</h3>
|
|
||||||
|
|
||||||
<!-- 셀렉트 박스 -->
|
<!-- 셀렉트 박스 -->
|
||||||
<div class="col-12 col-md-auto">
|
<div class="col-12 col-md-auto">
|
||||||
<select class="form-select" v-model="selectedOrder" @change="handleSortChange">
|
<select class="form-select" v-model="selectedOrder" @change="handleSortChange">
|
||||||
@ -38,6 +22,16 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 공지사항 리스트 -->
|
||||||
|
<div v-if="pagination.currentPage === 1" class="mb-8">
|
||||||
|
<div class="row">
|
||||||
|
<BoardCardList :posts="noticeList" @click="goDetail" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 일반 리스트 -->
|
||||||
|
<div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<BoardCardList :posts="generalList" @click="goDetail" />
|
<BoardCardList :posts="generalList" @click="goDetail" />
|
||||||
</div>
|
</div>
|
||||||
@ -64,7 +58,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
@ -133,7 +126,8 @@ const fetchGeneralPosts = async (page = 1) => {
|
|||||||
id: post.id || index,
|
id: post.id || index,
|
||||||
img: post.firstImageUrl || null,
|
img: post.firstImageUrl || null,
|
||||||
views: post.cnt || 0,
|
views: post.cnt || 0,
|
||||||
likes: post.likeCount != null ? post.likeCount : null,
|
likes: post.likeCount != null ? post.dislikeCount : null,
|
||||||
|
dislikes: post.dislikeCount != null ? post.likeCount : null,
|
||||||
comments: post.commentCount != null ? post.commentCount : null,
|
comments: post.commentCount != null ? post.commentCount : null,
|
||||||
attachment: post.hasAttachment || false,
|
attachment: post.hasAttachment || false,
|
||||||
content: post.plainContent || '',
|
content: post.plainContent || '',
|
||||||
|
|||||||
@ -5,28 +5,62 @@
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
<!-- 프로필 헤더 -->
|
<!-- 프로필 헤더 -->
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<BoardProfile :boardId="currentBoardId" :profileName="profileName" />
|
<BoardProfile
|
||||||
<hr/>
|
:boardId="currentBoardId"
|
||||||
|
:profileName="profileName"
|
||||||
|
:views="views"
|
||||||
|
:likes="likes"
|
||||||
|
:dislikes="dislikes"
|
||||||
|
class="pb-6 border-bottom"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<!-- 게시글 내용 -->
|
<!-- 게시글 내용 -->
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h5 class="mb-4">{{ boardTitle }}</h5>
|
|
||||||
<!-- HTML 콘텐츠 렌더링 -->
|
|
||||||
<div class="board-content text-body" style="line-height: 1.6;" v-html="$common.contentToHtml(boardContent)">
|
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-between align-items-center flex-wrap mb-6 gap-2">
|
||||||
|
<!-- 제목 섹션 -->
|
||||||
|
<div class="me-1">
|
||||||
|
<h5 class="mb-4">{{ boardTitle }}</h5>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 첨부파일 섹션 -->
|
||||||
|
<div v-if="attachments" class="btn-group">
|
||||||
|
<button type="button" class="btn btn-label-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
|
<i class="fa-solid fa-download me-2"></i>
|
||||||
|
첨부파일
|
||||||
|
<!-- (<span class="attachment-num">{{ dropdownItems.length }}</span>) -->
|
||||||
|
</button>
|
||||||
|
<!-- <ul class="dropdown-menu">
|
||||||
|
<li v-for="(item, index) in dropdownItems" :key="index">
|
||||||
|
<a class="dropdown-item" href="javascript:void(0);">
|
||||||
|
{{ item.label }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul> -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- HTML 콘텐츠 렌더링 -->
|
||||||
|
<div class="board-content text-body" style="line-height: 1.6;" v-html="$common.contentToHtml(boardContent)"></div>
|
||||||
|
|
||||||
<!-- 좋아요 버튼 -->
|
<!-- 좋아요 버튼 -->
|
||||||
<div class="row justify-content-center my-10">
|
<div class="row justify-content-center my-10">
|
||||||
<BoardRecommendBtn :bigBtn="true"/>
|
<BoardRecommendBtn
|
||||||
|
:bigBtn="true"
|
||||||
|
:boardId="currentBoardId"
|
||||||
|
:commentId="null"
|
||||||
|
:likeCount="currentLikeCount"
|
||||||
|
:dislikeCount="currentDislikeCount"
|
||||||
|
@updateReaction="handleUpdateReaction"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 첨부파일 목록 -->
|
<!-- 첨부파일 목록 -->
|
||||||
<ul v-if="attachments.length" class="attachments mt-4 list-unstyled">
|
<!-- <ul v-if="attachments.length" class="attachments mt-4 list-unstyled">
|
||||||
<li v-for="(attachment, index) in attachments" :key="index" class="mb-2">
|
<li v-for="(attachment, index) in attachments" :key="index" class="mb-2">
|
||||||
<a :href="attachment.url" target="_blank" class="text-decoration-none">{{ attachment.name }}</a>
|
<a :href="attachment.url" target="_blank" class="text-decoration-none">{{ attachment.name }}</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul> -->
|
||||||
|
|
||||||
<!-- 댓글 영역 -->
|
<!-- 댓글 영역 -->
|
||||||
<BoardComentArea :comments="comments" />
|
<BoardComentArea :comments="comments" />
|
||||||
@ -38,6 +72,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="card-footer">
|
<div class="card-footer">
|
||||||
<BoardCommentList/>
|
<BoardCommentList/>
|
||||||
|
|
||||||
|
<Pagination/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -47,21 +83,24 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import BoardComentArea from '@c/board/BoardComentArea.vue';
|
import BoardComentArea from '@c/board/BoardComentArea.vue';
|
||||||
import BoardCommentList from '@/components/board/BoardCommentList.vue';
|
|
||||||
import BoardProfile from '@c/board/BoardProfile.vue';
|
import BoardProfile from '@c/board/BoardProfile.vue';
|
||||||
|
import BoardCommentList from '@/components/board/BoardCommentList.vue';
|
||||||
import BoardRecommendBtn from '@/components/button/BoardRecommendBtn.vue';
|
import BoardRecommendBtn from '@/components/button/BoardRecommendBtn.vue';
|
||||||
|
import Pagination from '@/components/pagination/Pagination.vue';
|
||||||
import { ref, onMounted } from 'vue';
|
import { ref, onMounted } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import axios from '@api';
|
import axios from '@api';
|
||||||
import Quill from 'quill';
|
|
||||||
|
|
||||||
// 게시물 데이터 상태
|
// 게시물 데이터 상태
|
||||||
const profileName = ref('익명 사용자');
|
const profileName = ref('익명 사용자');
|
||||||
const boardTitle = ref('제목 없음');
|
const boardTitle = ref('제목 없음');
|
||||||
const boardContent = ref('');
|
const boardContent = ref('');
|
||||||
const convertedContent = ref('내용 없음');
|
|
||||||
const comments = ref([]);
|
const comments = ref([]);
|
||||||
const attachments = ref([]);
|
const attachments = ref([]);
|
||||||
|
const views = ref(0);
|
||||||
|
const likes = ref(0);
|
||||||
|
const dislikes = ref(0);
|
||||||
|
const attachment = ref(false);
|
||||||
|
|
||||||
// 라우트에서 ID 가져오기
|
// 라우트에서 ID 가져오기
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
@ -81,19 +120,36 @@ const fetchBoardDetails = async () => {
|
|||||||
|
|
||||||
// API 응답 데이터 반영
|
// API 응답 데이터 반영
|
||||||
const boardDetail = data.boardDetail || {};
|
const boardDetail = data.boardDetail || {};
|
||||||
profileName.value = boardDetail.author || '익명 사용자';
|
|
||||||
boardTitle.value = boardDetail.title || '제목 없음';
|
|
||||||
boardContent.value = boardDetail.content || '';
|
|
||||||
|
|
||||||
|
profileName.value = data.author || '익명 사용자';
|
||||||
|
boardTitle.value = data.title || '제목 없음';
|
||||||
|
boardContent.value = data.content || '';
|
||||||
|
views.value = data.cnt || 0;
|
||||||
|
likes.value = data.likeCount || 0;
|
||||||
|
dislikes.value = data.dislikeCount || 0;
|
||||||
|
attachment.value = data.hasAttachment || null;
|
||||||
|
|
||||||
attachments.value = data.attachments || [];
|
attachments.value = data.attachments || [];
|
||||||
comments.value = data.comments || [];
|
comments.value = data.comments || [];
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('게시물 가져오기 오류:', error);
|
|
||||||
alert('게시물 데이터를 불러오는 중 오류가 발생했습니다.');
|
alert('게시물 데이터를 불러오는 중 오류가 발생했습니다.');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const currentLikeCount = ref(10);
|
||||||
|
const currentDislikeCount = ref(2);
|
||||||
|
|
||||||
|
// 좋아요, 싫어요
|
||||||
|
const handleUpdateReaction = async ({ type, boardId, commentId }) => {
|
||||||
|
try {
|
||||||
|
const cmtId = commentId !== null ? commentId : 0;
|
||||||
|
|
||||||
|
const response = await axios.post(`/board/${boardId}/${cmtId}/reaction`, { type });
|
||||||
|
} catch (error) {
|
||||||
|
alert('반응을 업데이트하는 중 오류 발생');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// 컴포넌트 마운트 시 데이터 로드
|
// 컴포넌트 마운트 시 데이터 로드
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
fetchBoardDetails();
|
fetchBoardDetails();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user