新版官网模板
This commit is contained in:
102
app/components/home/ArticleItem.vue
Normal file
102
app/components/home/ArticleItem.vue
Normal file
@@ -0,0 +1,102 @@
|
||||
<template>
|
||||
<div :class="{ 'has-image': showImage && article.image }" class="article-item">
|
||||
<NuxtLink :to="article.link || `/article/${article.id}`" class="article-link">
|
||||
<div class="article-content">
|
||||
<div class="article-title">{{ article.title }}</div>
|
||||
<div class="article-meta">
|
||||
<span v-if="article.source" class="source">{{ article.source }}</span>
|
||||
<span class="date">{{ article.date }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<img v-if="showImage && article.image" :alt="article.title" :src="article.image" class="article-image" />
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
interface Article {
|
||||
id: number
|
||||
title: string
|
||||
date: string
|
||||
source?: string
|
||||
image?: string
|
||||
link?: string
|
||||
}
|
||||
|
||||
defineProps<{
|
||||
article: Article
|
||||
showImage?: boolean
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.article-item {
|
||||
padding: 10px 0;
|
||||
border-bottom: 1px dashed #eee;
|
||||
}
|
||||
|
||||
.article-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.article-link {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.article-content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.article-title {
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
line-height: 1.5;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
|
||||
.article-link:hover .article-title {
|
||||
color: #1e3a5f;
|
||||
}
|
||||
|
||||
.article-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-top: 6px;
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.source {
|
||||
color: #e74c3c;
|
||||
}
|
||||
|
||||
.article-image {
|
||||
width: 100px;
|
||||
height: 70px;
|
||||
object-fit: cover;
|
||||
border-radius: 4px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.has-image .article-title {
|
||||
-webkit-line-clamp: 1;
|
||||
}
|
||||
|
||||
@media (max-width: 576px) {
|
||||
.article-image {
|
||||
width: 80px;
|
||||
height: 56px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user