# Personal Blog - Admin Dashboard UI 设计与实现文档
> **设计风格**: Modern Admin Dashboard
> **版本**: v2.0
> **更新日期**: 2026-04-19
---
## 1. 设计概述
### 1.1 设计理念
Admin Dashboard 采用现代化的 SaaS 管理后台设计,强调:
- **专业感**: 深色侧边栏 + 浅色内容区的高对比度设计
- **效率优先**: 信息密度适中,关键数据一目了然
- **视觉层次**: 清晰的视觉层级引导用户操作
- **一致性**: 所有组件遵循统一的设计语言
### 1.2 与访客端的区别
| 维度 | Admin Dashboard | 访客端 (Neobrutalism) |
|------|-----------------|----------------------|
| 用户 | 管理员 | 普通访客 |
| 目标 | 高效管理内容 | 阅读体验 |
| 风格 | 专业、现代 | 个性、艺术 |
| 色调 | 深墨绿 + 翠绿 | 奶油色 + 粉红 |
---
## 2. 色彩系统
### 2.1 CSS 变量定义
```css
:root {
/* 侧边栏 */
--admin-sidebar-bg: #0F172A;
--admin-sidebar-hover: #1E293B;
--admin-sidebar-active: #334155;
--admin-sidebar-text: #94A3B8;
--admin-sidebar-text-active: #FFFFFF;
/* 主内容区 */
--admin-bg: #F8FAFC;
--admin-card: #FFFFFF;
--admin-border: #E2E8F0;
/* 主色调 - 翠绿 */
--admin-primary: #10B981;
--admin-primary-hover: #059669;
--admin-primary-light: #D1FAE5;
--admin-primary-subtle: #ECFDF5;
/* 状态色 */
--admin-success: #10B981;
--admin-warning: #F59E0B;
--admin-danger: #EF4444;
--admin-info: #3B82F6;
/* 文字 */
--admin-text-primary: #0F172A;
--admin-text-secondary: #64748B;
--admin-text-muted: #94A3B8;
--admin-text-inverse: #FFFFFF;
/* 阴影 */
--admin-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
--admin-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
--admin-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
--admin-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
/* 圆角 */
--admin-radius-sm: 6px;
--admin-radius: 8px;
--admin-radius-lg: 12px;
--admin-radius-xl: 16px;
}
```
### 2.2 Tailwind 配置扩展
```javascript
// tailwind.config.js
theme: {
extend: {
colors: {
admin: {
sidebar: {
DEFAULT: '#0F172A',
hover: '#1E293B',
active: '#334155',
text: '#94A3B8',
'text-active': '#FFFFFF',
},
bg: '#F8FAFC',
card: '#FFFFFF',
border: '#E2E8F0',
primary: {
DEFAULT: '#10B981',
hover: '#059669',
light: '#D1FAE5',
subtle: '#ECFDF5',
},
text: {
primary: '#0F172A',
secondary: '#64748B',
muted: '#94A3B8',
}
}
},
boxShadow: {
'admin': '0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)',
'admin-md': '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',
'admin-lg': '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',
}
}
}
```
---
## 3. 布局架构
### 3.1 整体结构
```
┌─────────────────────────────────────────────────────────────┐
│ ┌────────────┐ ┌─────────────────────────────────────────┐ │
│ │ │ │ Header: Logo + Search + Actions │ │
│ │ Sidebar │ ├─────────────────────────────────────────┤ │
│ │ (240px) │ │ │ │
│ │ │ │ Breadcrumbs (可选) │ │
│ │ 🏠 Dashboard│ │ │ │
│ │ 📝 Posts │ │ ┌─────────────────────────────────┐ │ │
│ │ 🏷️ Tags │ │ │ Page Title + Actions │ │ │
│ │ 📁 Categories│ │ └─────────────────────────────────┘ │ │
│ │ 🖼️ Images │ │ │ │
│ │ 💬 Comments│ │ ┌─────┐ ┌─────┐ ┌─────┐ ┌─────┐ │ │
│ │ ⚙️ Settings│ │ │Stat │ │Stat │ │Stat │ │Stat │ │ │
│ │ │ │ └─────┘ └─────┘ └─────┘ └─────┘ │ │
│ │ ───────────│ │ │ │
│ │ 🔗 External│ │ ┌─────────────────────────────────┐ │ │
│ │ 📊 Analytics│ │ │ Main Content │ │ │
│ │ 🛒 Shop │ │ │ │ │ │
│ └────────────┘ │ └─────────────────────────────────┘ │ │
│ └─────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
```
### 3.2 布局组件
```jsx
// AdminLayout.jsx
const AdminLayout = ({ children }) => {
return (
{/* 侧边栏 */}
{/* 主内容区 */}
{children}
)
}
```
---
## 4. 组件实现规范
### 4.1 侧边栏 (Sidebar)
```jsx
const Sidebar = () => {
const menuGroups = [
{
title: '内容管理',
items: [
{ icon: LayoutDashboard, label: 'Dashboard', path: '/admin' },
{ icon: FileText, label: '文章管理', path: '/admin/posts' },
{ icon: FolderOpen, label: '分类管理', path: '/admin/categories' },
{ icon: Tags, label: '标签管理', path: '/admin/tags' },
{ icon: Image, label: '图片管理', path: '/admin/images' },
{ icon: MessageSquare, label: '评论管理', path: '/admin/comments' },
]
},
{
title: '系统设置',
items: [
{ icon: Settings, label: '系统设置', path: '/admin/settings' },
]
}
]
return (
)
}
```
### 4.2 头部 (Header)
```jsx
const Header = () => {
return (
{/* Search */}
{/* Actions */}
)
}
```
### 4.3 统计卡片 (StatsCard)
```jsx
const StatsCard = ({ title, value, change, changeType, icon: Icon, color = 'primary' }) => {
const colorMap = {
primary: 'bg-admin-primary-light text-admin-primary',
success: 'bg-green-100 text-green-600',
warning: 'bg-amber-100 text-amber-600',
danger: 'bg-red-100 text-red-600',
info: 'bg-blue-100 text-blue-600',
}
return (
{title}
{value}
{change && (
{changeType === 'up' ? : }
{change}
较上月
)}
)
}
```
### 4.4 数据表格 (DataTable)
```jsx
const DataTable = ({ columns, data, onEdit, onDelete }) => {
return (
{columns.map((col) => (
|
{col.title}
|
))}
操作
|
{data.map((row, idx) => (
{columns.map((col) => (
|
{col.render ? col.render(row[col.key], row) : row[col.key]}
|
))}
|
))}
)
}
```
### 4.5 按钮组件 (Button)
```jsx
const Button = ({
children,
variant = 'primary',
size = 'md',
loading = false,
disabled = false,
...props
}) => {
const variants = {
primary: 'bg-admin-primary text-white hover:bg-admin-primary-hover focus:ring-admin-primary',
secondary: 'bg-white text-admin-text-primary border border-admin-border hover:bg-gray-50 focus:ring-gray-200',
ghost: 'bg-transparent text-admin-text-secondary hover:bg-gray-100 hover:text-admin-text-primary',
danger: 'bg-admin-danger text-white hover:bg-red-600 focus:ring-red-500',
}
const sizes = {
sm: 'px-3 py-1.5 text-xs rounded-md',
md: 'px-4 py-2 text-sm rounded-lg',
lg: 'px-6 py-2.5 text-base rounded-lg',
}
return (
)
}
```
### 4.6 表单组件
```jsx
// Input
const Input = ({ label, error, ...props }) => {
return (
{label &&
}
{error &&
{error}
}
)
}
// Select
const Select = ({ label, options, ...props }) => {
return (
{label &&
}
)
}
// Textarea
const Textarea = ({ label, error, rows = 4, ...props }) => {
return (
{label &&
}
{error &&
{error}
}
)
}
```
### 4.7 卡片组件 (Card)
```jsx
const Card = ({ children, className = '' }) => {
return (
{children}
)
}
const CardHeader = ({ title, description, action }) => {
return (
{title}
{description &&
{description}
}
{action &&
{action}
}
)
}
const CardContent = ({ children, className = '' }) => {
return {children}
}
const CardFooter = ({ children, className = '' }) => {
return (
{children}
)
}
```
### 4.8 模态框 (Modal)
```jsx
const Modal = ({ isOpen, onClose, title, children, footer }) => {
if (!isOpen) return null
return (
{/* Backdrop */}
{/* Modal */}
{title}
{children}
{footer && (
{footer}
)}
)
}
```
### 4.9 Toast 通知
```jsx
const Toast = ({ message, type = 'success', onClose }) => {
const icons = {
success: CheckCircle,
error: XCircle,
warning: AlertTriangle,
info: Info,
}
const colors = {
success: 'bg-green-50 border-green-200 text-green-800',
error: 'bg-red-50 border-red-200 text-red-800',
warning: 'bg-amber-50 border-amber-200 text-amber-800',
info: 'bg-blue-50 border-blue-200 text-blue-800',
}
const Icon = icons[type]
useEffect(() => {
const timer = setTimeout(onClose, 3000)
return () => clearTimeout(timer)
}, [onClose])
return (
{message}
)
}
```
### 4.10 分页组件 (Pagination)
```jsx
const Pagination = ({ currentPage, totalPages, onPageChange }) => {
return (
第 {currentPage} 页,共 {totalPages} 页
{Array.from({ length: Math.min(5, totalPages) }, (_, i) => {
const page = i + 1
return (
)
})}
)
}
```
---
## 5. 页面实现
### 5.1 Dashboard 页面
```jsx
const Dashboard = () => {
const stats = [
{ title: '总文章数', value: '128', change: '12%', changeType: 'up', icon: FileText },
{ title: '本月发布', value: '24', change: '8%', changeType: 'up', icon: TrendingUp },
{ title: '总浏览量', value: '45.2K', change: '23%', changeType: 'up', icon: Eye },
{ title: '待审评论', value: '18', change: '5%', changeType: 'down', icon: MessageSquare },
]
return (
{/* Page Header */}
Dashboard
欢迎回来,今天也是创作的好日子!
{/* Stats */}
{stats.map((stat) => (
))}
{/* Recent Posts */}
查看全部 →}
/>
)
}
```
---
## 6. 文件结构
```
frontend/src/
├── components/
│ └── admin/
│ ├── AdminLayout.jsx # 后台布局
│ ├── Sidebar.jsx # 侧边栏
│ ├── Header.jsx # 顶部导航
│ ├── StatsCard.jsx # 统计卡片
│ ├── DataTable.jsx # 数据表格
│ ├── Button.jsx # 按钮
│ ├── Card.jsx # 卡片组件
│ ├── Input.jsx # 输入框
│ ├── Select.jsx # 下拉选择
│ ├── Modal.jsx # 模态框
│ ├── Toast.jsx # 通知提示
│ └── Pagination.jsx # 分页
├── pages/
│ └── admin/
│ ├── Dashboard.jsx
│ ├── Posts.jsx
│ ├── PostEdit.jsx
│ ├── Categories.jsx
│ ├── Tags.jsx
│ ├── Images.jsx
│ ├── Comments.jsx
│ └── Settings.jsx
├── styles/
│ └── admin.css # Admin 主题样式
└── hooks/
└── useToast.js # Toast 状态管理
```
---
## 7. 更新日志
| 日期 | 版本 | 变更内容 |
|------|------|----------|
| 2026-04-19 | v2.0 | 初始版本,完整的 Admin Dashboard 设计规范 |
---
*本文档定义了个人博客后台管理的完整 UI 设计规范与组件实现。*