공지사항 코멘트 수정 및 셀렉트 박스 위치 조정
This commit is contained in:
parent
05c26f7b7b
commit
3e6c9f2c97
@ -34,11 +34,11 @@
|
|||||||
<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">
|
<span class="text-muted me-3" v-if="likes != null">
|
||||||
<i class="bx bx-like"></i> {{ likes || 0 }}
|
<i class="bx bx-like"></i> {{ likes }}
|
||||||
</span>
|
</span>
|
||||||
<span class="text-muted">
|
<span class="text-muted" v-if="comments !== null">
|
||||||
<i class="bx bx-comment"></i> {{ comments || 0 }}
|
<i class="bx bx-comment"></i> {{ comments }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -80,11 +80,11 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
likes: {
|
likes: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: null,
|
||||||
},
|
},
|
||||||
comments: {
|
comments: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: null,
|
||||||
},
|
},
|
||||||
attachment: {
|
attachment: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
|||||||
@ -1,43 +1,53 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="mt-4">
|
<div class="mt-4">
|
||||||
<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>
|
||||||
</div>
|
</div>
|
||||||
<div v-for="post in posts" :key="post.id" @click="handleClick(post.id)">
|
<div v-for="post in posts" :key="post.id" @click="handleClick(post.id)">
|
||||||
<BoardCard
|
<BoardCard
|
||||||
:img="post.img"
|
:img="post.img || null"
|
||||||
:category="post.category"
|
:category="post.category || ''"
|
||||||
:title="post.title"
|
:title="post.title"
|
||||||
:content="post.content"
|
:content="post.content"
|
||||||
:date="post.date"
|
:date="post.date"
|
||||||
:views="post.views"
|
:views="post.views || 0"
|
||||||
:likes="post.likes"
|
v-bind="getBoardCardProps(post)"
|
||||||
:comments="post.comments"
|
:attachment="post.attachment || false"
|
||||||
:attachment="post.attachment"
|
@click="() => goDetail(post.id)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
|
import { defineProps, defineEmits } from 'vue';
|
||||||
import BoardCard from './BoardCard.vue';
|
import BoardCard from './BoardCard.vue';
|
||||||
|
|
||||||
export default {
|
const props = defineProps({
|
||||||
components: {
|
posts: {
|
||||||
BoardCard,
|
type: Array,
|
||||||
},
|
required: true,
|
||||||
props: {
|
default: () => [],
|
||||||
posts: {
|
}
|
||||||
type: Array,
|
});
|
||||||
required: true,
|
|
||||||
},
|
const emit = defineEmits(['click']);
|
||||||
},
|
|
||||||
emits: ['click'],
|
// 상세 페이지 이동
|
||||||
methods: {
|
const goDetail = (id) => {
|
||||||
handleClick(id) {
|
emit('click', id);
|
||||||
this.$emit('click', id);
|
};
|
||||||
},
|
|
||||||
},
|
// 없는 데이터는 상위 페이지에서 삭제해도 되게끔 설정
|
||||||
|
const getBoardCardProps = (post) => {
|
||||||
|
const boardCardProps = {};
|
||||||
|
if ('likes' in post) {
|
||||||
|
boardCardProps.likes = post.likes;
|
||||||
|
}
|
||||||
|
if ('comments' in post) {
|
||||||
|
boardCardProps.comments = post.comments;
|
||||||
|
}
|
||||||
|
return boardCardProps;
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="input-group mb-3 d-flex">
|
<div class="input-group mb-3 d-flex">
|
||||||
<input type="text" class="form-control bg-white" placeholder="Search" @change="search" />
|
<input type="text" class="form-control" placeholder="Search" @change="search" />
|
||||||
<button type="button" class="btn btn-primary"><i class="bx bx-search bx-md"></i></button>
|
<button type="button" class="btn btn-primary"><i class="bx bx-search bx-md"></i></button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="container-xxl flex-grow-1 container-p-y">
|
<div class="container-xxl flex-grow-1 container-p-y">
|
||||||
<!-- 상단 바: 검색창, 정렬 셀렉트 박스, 새 글쓰기 버튼 -->
|
|
||||||
<div class="row mb-4">
|
<div class="row mb-4">
|
||||||
<!-- 검색창 -->
|
<!-- 검색창 -->
|
||||||
<div class="col">
|
<div class="col">
|
||||||
@ -9,31 +8,36 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<!-- 정렬 셀렉트 박스 -->
|
<!-- 새 글쓰기 -->
|
||||||
<div class="col-md-3 mb-4">
|
<div class="mb-4">
|
||||||
<select class="form-select" v-model="selectedOrder" @change="handleSortChange">
|
|
||||||
<option value="date">최신날짜</option>
|
|
||||||
<option value="views">조회수</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 새 글쓰기 버튼 -->
|
|
||||||
<div class="col-auto ms-auto mb-4">
|
|
||||||
<router-link to="/board/write">
|
<router-link to="/board/write">
|
||||||
<WriteButton />
|
<WriteButton />
|
||||||
</router-link>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 공지사항 게시물 리스트 -->
|
<!-- 공지사항 리스트 -->
|
||||||
<div class="row g-3 mt-2 mt-md-8">
|
<div class="row g-3">
|
||||||
<h3>공지사항</h3>
|
<h3>공지사항</h3>
|
||||||
<board-card :posts="noticeList" @click="goDetail" />
|
|
||||||
</div>
|
</div>
|
||||||
<!-- 일반 게시물 리스트 -->
|
<div class="row">
|
||||||
|
<BoardCardList :posts="noticeList" @click="goDetail" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 일반 리스트 -->
|
||||||
<div class="row g-3 mt-8">
|
<div class="row g-3 mt-8">
|
||||||
<h3>일반게시판</h3>
|
<h3 class="col">일반게시판</h3>
|
||||||
<board-card :posts="generalList" @click="goDetail" />
|
|
||||||
|
<!-- 셀렉트 박스 -->
|
||||||
|
<div class="col-12 col-md-auto">
|
||||||
|
<select class="form-select" v-model="selectedOrder" @change="handleSortChange">
|
||||||
|
<option value="date">최신날짜</option>
|
||||||
|
<option value="views">조회수</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<BoardCardList :posts="generalList" @click="goDetail" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 페이지네이션 -->
|
<!-- 페이지네이션 -->
|
||||||
@ -61,7 +65,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, onMounted } from 'vue';
|
import { ref, computed, onMounted } from 'vue';
|
||||||
import BoardCard from '@/components/list/BoardCardList.vue';
|
import BoardCardList from '@/components/list/BoardCardList.vue';
|
||||||
import Pagination from '@c/pagination/Pagination.vue';
|
import Pagination from '@c/pagination/Pagination.vue';
|
||||||
import SearchBar from '@c/search/SearchBar.vue';
|
import SearchBar from '@c/search/SearchBar.vue';
|
||||||
import router from '@/router';
|
import router from '@/router';
|
||||||
@ -102,7 +106,7 @@ const search = (e) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 정렬 변경 핸들러
|
// 정렬 변경 핸들러
|
||||||
const handleSortChange = (event) => {
|
const handleSortChange = () => {
|
||||||
fetchGeneralPosts(1);
|
fetchGeneralPosts(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -125,8 +129,8 @@ const fetchGeneralPosts = async (page = 1) => {
|
|||||||
id: post.id || index,
|
id: post.id || index,
|
||||||
img: post.img || null,
|
img: post.img || null,
|
||||||
views: post.cnt || 0,
|
views: post.cnt || 0,
|
||||||
likes: post.likeCount || 0,
|
likes: post.likeCount != null ? post.likeCount : null,
|
||||||
comments: post.commentCount || 0,
|
comments: post.commentCount != null ? post.commentCount : null,
|
||||||
attachment: post.hasAttachment || false,
|
attachment: post.hasAttachment || false,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -164,8 +168,6 @@ const fetchNoticePosts = async () => {
|
|||||||
id: post.id || index,
|
id: post.id || index,
|
||||||
img: post.img || null,
|
img: post.img || null,
|
||||||
views: post.cnt || 0,
|
views: post.cnt || 0,
|
||||||
likes: post.likeCount || 0,
|
|
||||||
comments: post.commentCount || 0,
|
|
||||||
attachment: post.hasAttachment || false,
|
attachment: post.hasAttachment || false,
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user