Merge remote-tracking branch 'origin/main' into board-view-profile

This commit is contained in:
kimdaae328 2025-01-23 11:18:08 +09:00
commit 6f91347b32
3 changed files with 41 additions and 31 deletions

View File

@ -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,

View File

@ -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>

View File

@ -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>