Skip to content

Commit 5803ea4

Browse files
committed
更新首页UI
1 parent cf46359 commit 5803ea4

2 files changed

Lines changed: 86 additions & 13 deletions

File tree

frontend/src/assets/blog.css

Lines changed: 72 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ body {
4545
}
4646

4747
.blog-container {
48-
max-width: none;
49-
margin: 0;
50-
padding: 26px var(--page-pad) 60px;
48+
max-width: var(--container);
49+
margin: 0 auto;
50+
padding: 38px var(--page-pad) 90px;
5151
text-align: left;
5252
color: var(--text);
5353
}
@@ -532,7 +532,7 @@ body {
532532

533533
/* 首页:最新文章 + 订阅 */
534534
.home-section {
535-
margin-top: 26px;
535+
margin-top: 48px;
536536
}
537537

538538
.home-section-head {
@@ -565,7 +565,7 @@ body {
565565
.home-latest-grid {
566566
display: grid;
567567
grid-template-columns: repeat(3, minmax(0, 1fr));
568-
gap: 18px;
568+
gap: 28px;
569569
}
570570

571571
@media (max-width: 1024px) {
@@ -581,7 +581,7 @@ body {
581581
}
582582

583583
.home-newsletter {
584-
margin-top: 26px;
584+
margin-top: 64px;
585585
border-radius: 18px;
586586
background: rgba(0, 0, 0, 0.03);
587587
border: 1px solid var(--border);
@@ -592,7 +592,7 @@ body {
592592
}
593593

594594
.home-newsletter-inner {
595-
padding: 24px 18px;
595+
padding: 44px 18px;
596596
text-align: center;
597597
}
598598

@@ -657,6 +657,67 @@ body {
657657
color: #111;
658658
}
659659

660+
/* 首页:更接近参考图的“封面在上”的文章卡片 */
661+
.home-post-card {
662+
border-radius: 16px;
663+
overflow: hidden;
664+
border: 1px solid var(--border);
665+
background: rgba(255, 255, 255, 0.75);
666+
cursor: pointer;
667+
transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
668+
}
669+
670+
[data-theme='dark'] .home-post-card {
671+
background: rgba(20, 20, 22, 0.62);
672+
}
673+
674+
.home-post-card:hover {
675+
transform: translateY(-2px);
676+
box-shadow: 0 10px 26px rgba(0, 0, 0, 0.06);
677+
border-color: rgba(170, 59, 255, 0.25);
678+
}
679+
680+
.home-post-cover {
681+
aspect-ratio: 16 / 9;
682+
background: var(--placeholder-tint);
683+
}
684+
685+
.home-post-cover img {
686+
width: 100%;
687+
height: 100%;
688+
object-fit: cover;
689+
display: block;
690+
}
691+
692+
.home-post-body {
693+
padding: 14px 14px 16px;
694+
}
695+
696+
.home-post-meta {
697+
display: flex;
698+
flex-wrap: wrap;
699+
gap: 8px;
700+
align-items: baseline;
701+
color: var(--muted);
702+
font-size: 12px;
703+
}
704+
705+
.home-post-title {
706+
margin-top: 10px;
707+
font-size: 18px;
708+
font-weight: 900;
709+
letter-spacing: -0.01em;
710+
color: var(--text);
711+
line-height: 1.25;
712+
}
713+
714+
.home-post-excerpt {
715+
margin-top: 8px;
716+
color: var(--muted);
717+
font-size: 13px;
718+
line-height: 1.75;
719+
}
720+
660721
/* 全部文章(主从布局):左侧侧边栏 + 右侧正文 */
661722
.all-layout {
662723
display: grid;
@@ -1369,18 +1430,18 @@ body {
13691430
padding-bottom: 10px;
13701431
padding-left: max(var(--page-pad), env(safe-area-inset-left, 0px));
13711432
padding-right: max(var(--page-pad), env(safe-area-inset-right, 0px));
1372-
background: rgba(255, 255, 255, 0.42);
1373-
backdrop-filter: saturate(1.15) blur(16px);
1374-
-webkit-backdrop-filter: saturate(1.15) blur(16px);
1433+
background: #ffffff;
13751434
border-bottom: 1px solid var(--border);
13761435
}
13771436

13781437
[data-theme='dark'] .site-top-bar {
1379-
background: rgba(18, 18, 20, 0.52);
1438+
background: #0f1114;
13801439
}
13811440

13821441
.site-top-bar-inner {
13831442
width: 100%;
1443+
max-width: var(--container);
1444+
margin: 0 auto;
13841445
display: flex;
13851446
align-items: center;
13861447
justify-content: space-between;

frontend/src/views/HomeView.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,20 @@
5757
<div class="card-body" style="padding: 22px; color: var(--muted)">暂无文章</div>
5858
</div>
5959
<div v-else class="home-latest-grid">
60-
<ArticleCard v-for="a in latestArticles" :key="a.id" :article="a" />
60+
<div v-for="a in latestArticles" :key="a.id" class="home-post-card" @click="go(a.id)">
61+
<div class="home-post-cover">
62+
<img v-if="a.coverMediaKey" :src="coverUrl(a.coverMediaKey)" alt="cover" />
63+
</div>
64+
<div class="home-post-body">
65+
<div class="home-post-meta">
66+
<span>{{ formatDate(a.publishedAt) }}</span>
67+
<span>·</span>
68+
<span>{{ a.authorNickname || '作者' }}</span>
69+
</div>
70+
<div class="home-post-title">{{ a.title }}</div>
71+
<div class="home-post-excerpt">{{ a.summary || '' }}</div>
72+
</div>
73+
</div>
6174
</div>
6275
</section>
6376

@@ -87,7 +100,6 @@
87100
import { onMounted, ref } from 'vue'
88101
89102
import { fetchArticles, fetchArticleDetail, coverUrl } from '../api/article'
90-
import ArticleCard from '../components/ArticleCard.vue'
91103
import { useRouter } from 'vue-router'
92104
import { showMessage } from '../utils/message'
93105

0 commit comments

Comments
 (0)