feat: 完成后端-管理后台集成及部署配置

🚀 主要功能:
- 完善后端API服务层,实现完整的CRUD操作
- 开发管理后台所有核心页面 (仪表板、照片、分类、标签、用户、设置)
- 完成前后端完全集成,所有API接口正常对接
- 配置完整的CI/CD流水线,支持自动化部署

🎯 后端完善:
- 实现PhotoService, CategoryService, TagService, UserService
- 添加完整的API处理器和路由配置
- 支持Docker容器化部署
- 添加数据库迁移和健康检查

🎨 管理后台完成:
- 仪表板: 实时统计数据展示
- 照片管理: 完整的CRUD操作,支持批量处理
- 分类管理: 树形结构展示和管理
- 标签管理: 颜色标签和统计信息
- 用户管理: 角色权限控制
- 系统设置: 多标签配置界面
- 添加pre-commit代码质量检查

🔧 部署配置:
- Docker Compose完整配置
- 后端CI/CD流水线 (Docker部署)
- 管理后台CI/CD流水线 (静态文件部署)
- 前端CI/CD流水线优化
- 自动化脚本: 部署、备份、监控
- 完整的部署文档和运维指南

 集成完成:
- 所有API接口正常连接
- 认证系统完整集成
- 数据获取和状态管理
- 错误处理和用户反馈
- 响应式设计优化
This commit is contained in:
xujiang
2025-07-09 16:23:18 +08:00
parent c57ec3aa82
commit 72414d0979
62 changed files with 12416 additions and 262 deletions

View File

@ -0,0 +1,217 @@
import React, { useState } from 'react'
import { Link, useLocation, useNavigate } from 'react-router-dom'
import { useQuery } from '@tanstack/react-query'
import { Button } from '@/components/ui/button'
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
import { Badge } from '@/components/ui/badge'
import { Separator } from '@/components/ui/separator'
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from '@/components/ui/dropdown-menu'
import { Sheet, SheetContent, SheetTrigger } from '@/components/ui/sheet'
import {
LayoutDashboard,
Camera,
FolderOpen,
Tags,
Users,
Settings,
LogOut,
Menu,
User,
Bell,
Search
} from 'lucide-react'
import { cn } from '@/lib/utils'
import { useAuthStore } from '@/stores/authStore'
import { authService } from '@/services/authService'
import { toast } from 'sonner'
interface DashboardLayoutProps {
children: React.ReactNode
}
const navigation = [
{ name: '仪表板', href: '/dashboard', icon: LayoutDashboard },
{ name: '照片管理', href: '/photos', icon: Camera },
{ name: '分类管理', href: '/categories', icon: FolderOpen },
{ name: '标签管理', href: '/tags', icon: Tags },
{ name: '用户管理', href: '/users', icon: Users },
{ name: '系统设置', href: '/settings', icon: Settings },
]
export default function DashboardLayout({ children }: DashboardLayoutProps) {
const location = useLocation()
const navigate = useNavigate()
const { user, logout } = useAuthStore()
const [sidebarOpen, setSidebarOpen] = useState(false)
// 获取当前用户信息
const { data: currentUser } = useQuery({
queryKey: ['current-user'],
queryFn: authService.getCurrentUser,
initialData: user,
staleTime: 5 * 60 * 1000, // 5分钟
})
const handleLogout = async () => {
try {
await authService.logout()
logout()
toast.success('退出登录成功')
navigate('/login')
} catch (error) {
toast.error('退出登录失败')
}
}
const isCurrentPath = (path: string) => {
return location.pathname === path || location.pathname.startsWith(path + '/')
}
const SidebarContent = () => (
<div className="flex h-full flex-col">
{/* Logo */}
<div className="flex h-16 items-center border-b px-4">
<Link to="/dashboard" className="flex items-center space-x-2">
<div className="bg-primary p-2 rounded-md">
<Camera className="h-5 w-5 text-white" />
</div>
<span className="text-xl font-semibold"></span>
</Link>
</div>
{/* Navigation */}
<nav className="flex-1 space-y-1 px-2 py-4">
{navigation.map((item) => {
const Icon = item.icon
const isActive = isCurrentPath(item.href)
return (
<Link
key={item.name}
to={item.href}
className={cn(
'group flex items-center px-2 py-2 text-sm font-medium rounded-md transition-colors',
isActive
? 'bg-primary text-white'
: 'text-gray-700 hover:bg-gray-100 hover:text-gray-900'
)}
onClick={() => setSidebarOpen(false)}
>
<Icon className="mr-3 h-5 w-5" />
{item.name}
</Link>
)
})}
</nav>
{/* User info */}
<div className="border-t p-4">
<div className="flex items-center space-x-3">
<Avatar className="h-8 w-8">
<AvatarImage src={undefined} />
<AvatarFallback>
{currentUser?.username?.charAt(0).toUpperCase()}
</AvatarFallback>
</Avatar>
<div className="flex-1 min-w-0">
<p className="text-sm font-medium text-gray-900 truncate">
{currentUser?.username}
</p>
<Badge variant="secondary" className="text-xs">
{currentUser?.role === 'admin' ? '管理员' :
currentUser?.role === 'editor' ? '编辑者' : '用户'}
</Badge>
</div>
</div>
</div>
</div>
)
return (
<div className="flex h-screen bg-gray-100">
{/* Desktop sidebar */}
<div className="hidden lg:flex lg:flex-col lg:w-64 lg:fixed lg:inset-y-0 lg:bg-white lg:border-r">
<SidebarContent />
</div>
{/* Mobile sidebar */}
<Sheet open={sidebarOpen} onOpenChange={setSidebarOpen}>
<SheetContent side="left" className="p-0 w-64">
<SidebarContent />
</SheetContent>
</Sheet>
{/* Main content */}
<div className="flex-1 lg:ml-64">
{/* Top bar */}
<header className="bg-white border-b h-16 flex items-center justify-between px-4">
<div className="flex items-center space-x-4">
<Sheet>
<SheetTrigger asChild>
<Button variant="ghost" size="sm" className="lg:hidden">
<Menu className="h-5 w-5" />
</Button>
</SheetTrigger>
</Sheet>
<div className="flex items-center space-x-2">
<Search className="h-5 w-5 text-gray-400" />
<input
type="text"
placeholder="搜索..."
className="bg-gray-50 border-0 rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary"
/>
</div>
</div>
<div className="flex items-center space-x-4">
<Button variant="ghost" size="sm">
<Bell className="h-5 w-5" />
</Button>
<Separator orientation="vertical" className="h-6" />
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" className="flex items-center space-x-2">
<Avatar className="h-8 w-8">
<AvatarImage src={undefined} />
<AvatarFallback>
{currentUser?.username?.charAt(0).toUpperCase()}
</AvatarFallback>
</Avatar>
<div className="hidden md:block text-left">
<p className="text-sm font-medium">{currentUser?.username}</p>
<p className="text-xs text-gray-500">{currentUser?.email}</p>
</div>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-56">
<DropdownMenuLabel></DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuItem onClick={() => navigate('/profile')}>
<User className="mr-2 h-4 w-4" />
</DropdownMenuItem>
<DropdownMenuItem onClick={() => navigate('/settings')}>
<Settings className="mr-2 h-4 w-4" />
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem onClick={handleLogout}>
<LogOut className="mr-2 h-4 w-4" />
退
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
</header>
{/* Page content */}
<main className="flex-1 overflow-auto">
{children}
</main>
</div>
</div>
)
}