# 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) => ( ))} {data.map((row, idx) => ( {columns.map((col) => ( ))} ))}
{col.title} 操作
{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 && }