146 lines
4.9 KiB
Svelte
146 lines
4.9 KiB
Svelte
<script lang="ts">
|
|
import type { PageData } from './$types';
|
|
import { page } from '$app/stores';
|
|
let { data }: { data: PageData } = $props();
|
|
</script>
|
|
|
|
<div class="dashboard">
|
|
<h2>仪表盘</h2>
|
|
<p class="welcome">欢迎回来,<strong>{data.user?.email || '管理员'}</strong>!这是您的后台概览。</p>
|
|
|
|
<div class="stats-grid">
|
|
<div class="stat-card">
|
|
<div class="stat-body">
|
|
<h3>{$page.data.aliases?.post || '文章'}总数</h3>
|
|
<div class="number">{data.postCount}</div>
|
|
</div>
|
|
<a href="/admin/posts" class="action-link">
|
|
管理{$page.data.aliases?.post || '文章'} <svg class="arrow-icon" xmlns="http://www.w3.org/2000/svg" width="1.3em" height="1.3em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="7" y1="17" x2="17" y2="7"></line><polyline points="7 7 17 7 17 17"></polyline></svg>
|
|
</a>
|
|
</div>
|
|
|
|
<div class="stat-card">
|
|
<div class="stat-body">
|
|
<h3>{$page.data.aliases?.post || '文章'}总字数</h3>
|
|
<div class="number">{(data.totalWords || 0).toLocaleString()}</div>
|
|
</div>
|
|
<a href="/admin/posts/new" class="action-link">
|
|
撰写新{$page.data.aliases?.post || '文章'} <svg class="arrow-icon" xmlns="http://www.w3.org/2000/svg" width="1.3em" height="1.3em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="7" y1="17" x2="17" y2="7"></line><polyline points="7 7 17 7 17 17"></polyline></svg>
|
|
</a>
|
|
</div>
|
|
|
|
<div class="stat-card">
|
|
<div class="stat-body">
|
|
<h3>{$page.data.aliases?.page || '页面'}总数</h3>
|
|
<div class="number">{data.pageCount}</div>
|
|
</div>
|
|
<a href="/admin/pages" class="action-link">
|
|
管理{$page.data.aliases?.page || '页面'} <svg class="arrow-icon" xmlns="http://www.w3.org/2000/svg" width="1.3em" height="1.3em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="7" y1="17" x2="17" y2="7"></line><polyline points="7 7 17 7 17 17"></polyline></svg>
|
|
</a>
|
|
</div>
|
|
|
|
<div class="stat-card">
|
|
<div class="stat-body">
|
|
<h3>{$page.data.aliases?.category || '分类'}总数</h3>
|
|
<div class="number">{data.categoryCount}</div>
|
|
</div>
|
|
<a href="/admin/categories" class="action-link">
|
|
管理{$page.data.aliases?.category || '分类'} <svg class="arrow-icon" xmlns="http://www.w3.org/2000/svg" width="1.3em" height="1.3em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="7" y1="17" x2="17" y2="7"></line><polyline points="7 7 17 7 17 17"></polyline></svg>
|
|
</a>
|
|
</div>
|
|
|
|
<div class="stat-card">
|
|
<div class="stat-body">
|
|
<h3>{$page.data.aliases?.tag || '标签'}总数</h3>
|
|
<div class="number">{data.tagCount}</div>
|
|
</div>
|
|
<a href="/admin/tags" class="action-link">
|
|
管理{$page.data.aliases?.tag || '标签'} <svg class="arrow-icon" xmlns="http://www.w3.org/2000/svg" width="1.3em" height="1.3em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="7" y1="17" x2="17" y2="7"></line><polyline points="7 7 17 7 17 17"></polyline></svg>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
.dashboard h2 {
|
|
margin-top: 0;
|
|
border-bottom: 2px solid var(--text-color);
|
|
padding-bottom: 12px;
|
|
font-size: 2rem;
|
|
color: var(--text-color);
|
|
}
|
|
|
|
.welcome {
|
|
color: var(--text-muted, rgba(0,0,0,0.6));
|
|
margin-bottom: 2.5rem;
|
|
font-size: 1.05rem;
|
|
}
|
|
|
|
.stats-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
|
gap: 25px;
|
|
}
|
|
|
|
.stat-card {
|
|
background: transparent;
|
|
border: 2px solid var(--text-color);
|
|
padding: 24px;
|
|
text-align: center;
|
|
transition: border-color 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.stat-card:hover {
|
|
border-color: var(--accent-color, #419b38);
|
|
}
|
|
|
|
.stat-body {
|
|
width: 100%;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.stat-card h3 {
|
|
margin: 0 0 12px 0;
|
|
font-size: 1.1rem;
|
|
color: var(--text-muted, rgba(0,0,0,0.6));
|
|
font-weight: 500;
|
|
}
|
|
|
|
.stat-card .number {
|
|
font-size: 3.2rem;
|
|
font-weight: 700;
|
|
color: var(--text-color, rgba(0,0,0,0.86));
|
|
margin-bottom: 0;
|
|
line-height: 1;
|
|
}
|
|
|
|
.action-link {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
font-size: 0.95rem;
|
|
color: var(--text-color);
|
|
font-weight: 600;
|
|
border-bottom: 1px solid rgba(0, 0, 0, 0.2);
|
|
transition: all 0.2s;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.arrow-icon {
|
|
margin-left: 6px;
|
|
transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
|
|
}
|
|
|
|
.stat-card:hover .arrow-icon {
|
|
transform: translate(3px, -3px);
|
|
}
|
|
|
|
.stat-card:hover .action-link {
|
|
color: var(--accent-color, #419b38);
|
|
border-bottom-color: var(--accent-color, #419b38);
|
|
}
|
|
</style>
|