You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pyx_gitkeshe/library_system/src/components/BookCard.vue

88 lines
1.7 KiB

<template>
<el-card class="book-card" shadow="hover" @click="$emit('click')">
<div class="book-cover">
<el-image :src="book.url" fit="cover" class="cover-image" :alt="book.title" />
</div>
<div class="book-info">
<h3 class="book-title">{{ book.title }}</h3>
<div class="book-meta" v-if="showMeta">
<el-tag type="info" size="small">{{ book.content }}</el-tag>
<el-tag type="success" size="small">{{ book.money }}/</el-tag>
</div>
<div class="book-status"v-if="showMeta">
<el-tag :type="book.state" size="small">
{{ book.state }}
</el-tag>
<span>阅读量: {{ book.number }}</span>
<el-button @click="$emit('borrow')"></el-button>
</div>
</div>
</el-card>
</template>
<script setup>
defineProps({
book: {
type: Object,
required: true
},
showMeta: {
type: Boolean,
default: true
}
})
</script>
<style scoped>
.book-card {
cursor: pointer;
transition: transform 0.3s;
height: 100%;
}
.book-card:hover {
transform: translateY(-5px);
}
.book-cover {
height: 180px;
overflow: hidden;
border-radius: 4px;
margin-bottom: 15px;
}
.cover-image {
width: 100%;
height: 100%;
object-fit: cover;
}
.book-info {
padding: 0 10px 10px;
}
.book-title {
margin: 0 0 10px;
font-size: 16px;
height: 24px;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
}
.book-meta {
display: flex;
gap: 5px;
margin-bottom: 10px;
flex-wrap: wrap;
}
.book-status {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 13px;
color: #666;
}
</style>