feat: 重构首页模板,双栏现代化布局 + 移动端适配

- 全新 Hero Banner:渐变背景,用户欢迎语
- 左侧最新文章卡片列表,含标题/摘要/作者/日期
- 右侧侧边栏:用户卡片(修复头像显示)、社区统计、快捷入口
- 完全重写 home.css,现代化样式,sticky 侧边栏
- 移动端适配:768px 单列布局,比例缩放
- 后端路由注入 PostService,获取最新 6 篇 approved 文章
This commit is contained in:
2026-05-31 19:51:47 +08:00
parent b75e1867f6
commit dae2a38e79
5 changed files with 446 additions and 356 deletions

View File

@ -1,341 +1,222 @@
/* ============================================================
MetaLab Home Styles — 首页专属样式Hero / Plans / Features / Timeline
仅在首页加载,通过 ExtraCSS 注入
MetaLab Home Styles — 首页专属样式
现代化双栏布局,移动端优先,体验至上
============================================================ */
/* ---------- Two-column layout ---------- */
.home-layout {
display: flex;
min-height: 100vh;
align-items: stretch;
}
/* ---------- Hero ---------- */
.hero {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
padding: 4rem 0;
/* ---------- Hero Banner ---------- */
.hero-banner {
position: relative;
text-align: center;
background: linear-gradient(180deg, #fff 0%, #f0f4f8 100%);
min-width: 0;
padding: 3.5rem 1.5rem 3rem;
overflow: hidden;
background: linear-gradient(135deg, #3498db 0%, #2980b9 30%, #2c3e50 100%);
}
.hero h1 {
font-size: 4rem;
.hero-bg {
position: absolute;
inset: 0;
background: radial-gradient(circle at 20% 50%, rgba(255,255,255,.08) 0%, transparent 60%),
radial-gradient(circle at 80% 30%, rgba(255,255,255,.05) 0%, transparent 50%);
pointer-events: none;
}
.hero-content {
position: relative;
z-index: 1;
max-width: 600px;
margin: 0 auto;
}
.hero-title {
font-size: 3.2rem;
font-weight: 800;
color: var(--color-primary);
margin-bottom: .6rem;
line-height: 1.1;
letter-spacing: -1px;
color: #fff;
margin-bottom: .5rem;
letter-spacing: -.02em;
line-height: 1.15;
}
.hero h1 span {
color: var(--color-accent);
.hero-accent {
color: rgba(255,255,255,.65);
font-weight: 700;
}
.hero-tagline {
font-size: 1.5rem;
color: var(--color-secondary);
margin-bottom: 1.5rem;
font-size: 1.15rem;
color: rgba(255,255,255,.75);
font-weight: 400;
margin-bottom: .75rem;
}
.hero-welcome {
font-size: .95rem;
color: rgba(255,255,255,.55);
font-weight: 400;
}
.hero-desc {
font-size: 1.15rem;
color: var(--color-text-light);
max-width: 500px;
margin: 0 auto 2.2rem;
line-height: 1.8;
/* ---------- Main Layout ---------- */
.home-main {
padding: 2rem 20px 3rem;
}
.hero-actions {
display: flex;
justify-content: center;
gap: 1rem;
flex-wrap: wrap;
}
.cta-button,
.secondary-button {
display: inline-block;
padding: .9rem 2.2rem;
border-radius: var(--radius);
font-weight: 600;
font-size: 1.1rem;
transition: var(--transition);
}
.cta-button {
background: var(--color-accent);
color: #fff;
border: 2px solid var(--color-accent);
}
.cta-button:hover {
background: transparent;
color: var(--color-accent);
}
.secondary-button {
background: transparent;
color: var(--color-accent);
border: 2px solid var(--color-accent);
}
.secondary-button:hover {
background: var(--color-accent);
color: #fff;
}
/* ---------- Shared section headings ---------- */
.section-title {
text-align: center;
font-size: 2.2rem;
color: var(--color-primary);
margin-bottom: .8rem;
}
.section-subtitle {
text-align: center;
color: var(--color-secondary);
font-size: 1.1rem;
max-width: 600px;
margin: 0 auto 3.5rem;
}
/* ---------- Plans ---------- */
.plans {
min-height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
padding: 1.5rem 0;
}
.plans .section-title {
font-size: 2rem;
margin-bottom: .4rem;
}
.plans .section-subtitle {
margin-bottom: 1.2rem;
}
.plans-grid {
.home-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 1.25rem;
grid-template-columns: 1fr 340px;
gap: 2rem;
align-items: start;
}
.plan-card {
background: var(--color-surface);
border-radius: var(--radius);
padding: 1.5rem;
box-shadow: var(--shadow);
transition: var(--transition);
border: 1px solid var(--color-border);
/* ---------- Feed (Left) ---------- */
.home-feed {
min-width: 0;
}
.feed-header {
display: flex;
flex-direction: column;
position: relative;
justify-content: space-between;
align-items: baseline;
margin-bottom: 1.25rem;
}
.plan-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 20px rgba(0,0,0,.12);
}
.plan-icon {
width: 50px;
height: 50px;
background: rgba(52,152,219,.1);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 1rem;
color: var(--color-accent);
font-size: 1.6rem;
}
.plan-card h3 {
font-size: 1.25rem;
font-weight: 600;
.feed-title {
font-size: 1.35rem;
font-weight: 700;
color: var(--color-primary);
margin-bottom: .5rem;
}
.plan-card p {
color: var(--color-text-light);
margin-bottom: 1rem;
flex-grow: 1;
font-size: .95rem;
}
.plan-status {
display: inline-block;
background: #e8f4fc;
.feed-more {
font-size: .88rem;
color: var(--color-accent);
padding: .3rem .9rem;
border-radius: 20px;
font-size: .85rem;
font-weight: 500;
text-decoration: none;
transition: opacity .2s ease;
}
/* ---------- Features ---------- */
.features {
min-height: 100vh;
.feed-more:hover {
opacity: .75;
}
/* ---------- Article Cards ---------- */
.article-list {
display: flex;
flex-direction: column;
justify-content: center;
padding: 4rem 0;
gap: 1rem;
}
.article-card {
background: var(--color-surface);
border-radius: 10px;
border: 1px solid var(--color-border);
padding: 1.35rem 1.5rem;
transition: box-shadow .2s ease, transform .2s ease;
cursor: default;
}
.features-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 2.5rem;
margin-top: 3rem;
.article-card:hover {
box-shadow: 0 4px 20px rgba(0,0,0,.08);
transform: translateY(-1px);
}
.feature {
text-align: center;
}
.feature .icon {
font-size: 2.5rem;
color: var(--color-accent);
margin-bottom: 1.5rem;
}
.feature h3 {
font-size: 1.3rem;
margin-bottom: .8rem;
color: var(--color-primary);
}
.feature p {
color: var(--color-text-light);
}
/* ---------- Timeline ---------- */
.section-group {
height: 100vh;
display: flex;
flex-direction: column;
}
.timeline-vision {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
padding: 1.5rem 0 1rem;
.article-body {
overflow: hidden;
}
.timeline-vision .section-title {
margin-bottom: .3rem;
}
.timeline-vision .section-subtitle {
margin-bottom: 1.5rem;
}
.timeline {
max-width: 1100px;
margin: 0 auto;
position: relative;
display: flex;
justify-content: center;
gap: 2rem;
padding: 2rem 0 1rem;
overflow-x: auto;
overflow-y: visible;
-webkit-overflow-scrolling: touch;
overscroll-behavior-y: contain;
}
.timeline::before {
content: '';
position: absolute;
left: 4%;
top: 1.9rem;
width: 92%;
height: 3px;
background: var(--color-accent);
border-radius: 2px;
}
.timeline-item {
display: flex;
flex-direction: column;
align-items: center;
position: relative;
flex-shrink: 0;
min-width: 200px;
max-width: 240px;
padding: 0 .5rem;
}
.timeline-marker {
width: 24px;
height: 24px;
background: var(--color-accent);
border-radius: 50%;
border: 4px solid var(--color-surface);
box-shadow: var(--shadow);
margin-bottom: 1.5rem;
z-index: 1;
flex-shrink: 0;
}
.timeline-content {
background: var(--color-surface);
border-radius: var(--radius);
padding: 1.5rem 1.2rem;
box-shadow: var(--shadow);
border: 1px solid var(--color-border);
text-align: center;
width: 100%;
transition: var(--transition);
}
.timeline-item:hover .timeline-content {
transform: translateY(-4px);
box-shadow: 0 10px 20px rgba(0,0,0,.12);
}
.timeline-title {
.article-title {
font-size: 1.15rem;
font-weight: 600;
font-weight: 650;
margin-bottom: .45rem;
line-height: 1.4;
}
.article-title a {
color: var(--color-primary);
margin-bottom: .5rem;
text-decoration: none;
transition: color .15s ease;
}
.timeline-desc {
.article-title a:hover {
color: var(--color-accent);
}
.article-excerpt {
font-size: .9rem;
color: var(--color-text-light);
font-size: .95rem;
line-height: 1.6;
margin-bottom: .75rem;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
/* ---------- Sidebar ---------- */
.sidebar {
width: 300px;
flex-shrink: 0;
padding: 4rem 20px 4rem 0;
.article-meta {
display: flex;
align-items: center;
gap: .35rem;
font-size: .82rem;
color: var(--color-secondary);
}
.article-author {
font-weight: 500;
color: var(--color-text-light);
}
.meta-dot {
color: var(--color-border);
}
/* ---------- Empty Feed ---------- */
.empty-feed {
text-align: center;
padding: 3.5rem 1.5rem;
background: var(--color-surface);
border-radius: 10px;
border: 1px solid var(--color-border);
}
.empty-icon {
color: var(--color-border);
margin-bottom: 1rem;
}
.empty-text {
font-size: .95rem;
color: var(--color-text-light);
margin-bottom: 1.25rem;
}
.btn-primary {
display: inline-block;
padding: .6rem 1.8rem;
background: var(--color-accent);
color: #fff;
border-radius: 8px;
font-size: .9rem;
font-weight: 600;
text-decoration: none;
transition: background .2s ease, transform .15s ease;
}
.btn-primary:hover {
background: #2980b9;
transform: translateY(-1px);
}
/* ---------- Sidebar (Right) ---------- */
.home-sidebar {
display: flex;
flex-direction: column;
gap: 1rem;
gap: 1.25rem;
position: sticky;
top: 5rem;
}
.sidebar-card {
background: var(--color-surface);
border-radius: var(--radius);
box-shadow: var(--shadow);
border-radius: 10px;
border: 1px solid var(--color-border);
padding: 1.5rem;
padding: 1.35rem 1.5rem;
}
/* --- User Card --- */
@ -343,93 +224,214 @@
text-align: center;
}
.user-card-avatar {
width: 56px;
height: 56px;
.user-avatar-img {
width: 64px;
height: 64px;
border-radius: 50%;
background: var(--color-accent);
object-fit: cover;
border: 3px solid var(--color-accent);
display: block;
margin: 0 auto .75rem;
}
.user-avatar-fallback {
width: 64px;
height: 64px;
border-radius: 50%;
background: linear-gradient(135deg, var(--color-accent), #2980b9);
color: #fff;
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto .8rem;
font-size: 1.5rem;
margin: 0 auto .75rem;
font-size: 1.6rem;
font-weight: 700;
text-transform: uppercase;
}
.guest-avatar {
background: var(--color-border);
}
.guest-avatar svg {
color: var(--color-text-light);
}
.user-card-name {
font-size: 1.1rem;
font-weight: 600;
font-weight: 650;
color: var(--color-primary);
margin-bottom: .3rem;
margin-bottom: .25rem;
word-break: break-all;
}
.user-card-desc {
font-size: .85rem;
font-size: .82rem;
color: var(--color-text-light);
margin-bottom: 1rem;
}
.user-card-link {
display: inline-block;
display: block;
font-size: .85rem;
color: var(--color-accent);
font-weight: 500;
transition: var(--transition);
text-decoration: none;
padding: .45rem 0;
border-radius: 6px;
background: rgba(52,152,219,.06);
transition: background .15s ease;
}
.user-card-link:hover {
opacity: .8;
background: rgba(52,152,219,.12);
}
.user-card-btn {
display: inline-block;
padding: .5rem 1.8rem;
.btn-login {
display: block;
padding: .55rem 0;
background: var(--color-accent);
color: #fff;
border-radius: var(--radius);
border-radius: 8px;
font-size: .9rem;
font-weight: 500;
transition: var(--transition);
font-weight: 600;
text-decoration: none;
transition: background .2s ease, transform .15s ease;
}
.user-card-btn:hover {
opacity: .85;
.btn-login:hover {
background: #2980b9;
transform: translateY(-1px);
}
/* --- Stats Card --- */
.stats-title {
font-size: .92rem;
font-weight: 650;
color: var(--color-primary);
margin-bottom: .85rem;
}
.stats-grid {
display: flex;
gap: 1rem;
}
.stat-item {
text-align: center;
flex: 1;
}
.stat-value {
display: block;
font-size: 1.5rem;
font-weight: 700;
color: var(--color-accent);
line-height: 1;
margin-bottom: .25rem;
}
.stat-label {
font-size: .78rem;
color: var(--color-text-light);
}
/* --- Links Card --- */
.links-title {
font-size: .92rem;
font-weight: 650;
color: var(--color-primary);
margin-bottom: .75rem;
}
.links-item {
display: flex;
align-items: center;
gap: .6rem;
padding: .55rem .5rem;
font-size: .88rem;
color: var(--color-text-light);
border-radius: 6px;
text-decoration: none;
transition: background .15s ease, color .15s ease;
}
.links-item:hover {
background: var(--color-bg);
color: var(--color-accent);
}
.links-icon {
width: 18px;
height: 18px;
flex-shrink: 0;
}
/* ---------- Responsive ---------- */
@media (max-width: 960px) {
.home-grid {
grid-template-columns: 1fr 280px;
gap: 1.5rem;
}
.hero-title {
font-size: 2.6rem;
}
}
/* ---------- Responsive (首页专属) ---------- */
@media (max-width: 768px) {
.hero h1 {
font-size: 3rem;
.hero-banner {
padding: 2.5rem 1.25rem 2.25rem;
}
.hero-title {
font-size: 2.2rem;
}
.hero-tagline {
font-size: 1.25rem;
font-size: 1rem;
}
.hero-desc {
.home-main {
padding: 1.5rem 16px 2rem;
}
.home-grid {
grid-template-columns: 1fr;
gap: 1.5rem;
}
.home-sidebar {
position: static;
}
.article-card {
padding: 1.1rem 1.2rem;
}
.article-title {
font-size: 1.05rem;
}
}
.timeline {
justify-content: flex-start;
gap: 1.5rem;
padding: 2rem 20px 1.5rem;
@media (max-width: 480px) {
.hero-banner {
padding: 2rem 1rem 1.75rem;
}
.timeline-item {
min-width: 240px;
max-width: 280px;
.hero-title {
font-size: 1.8rem;
}
.timeline::before {
left: 20px;
width: calc(240px * 4 + 1.5rem * 3 + 20px);
.hero-welcome {
font-size: .85rem;
}
.cta-button,
.secondary-button {
display: block;
width: 100%;
margin: .5rem 0;
.feed-title {
font-size: 1.15rem;
}
.secondary-button {
margin-left: 0;
.home-main {
padding: 1rem 12px 1.5rem;
}
}