feat: LokiDeploy 初始提交 - 轻量级 K8s Loki 部署平台

Go(Gin) + React(Vite + shadcn/ui + Tailwind) 前后端分离,全中文 UI

- 集群管理:Kubeconfig / Token 双接入,kubectl + helm 部署
- 主机管理:SSH 密钥 / 密码双认证,CPU/内存/磁盘使用率监控,SSH 错误中文友好提示
- 存储配置、部署管理、系统设置
- Docker 镜像内置 kubectl + helm,开箱即用
- run.sh 一键启停(start/stop/restart/status)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Logan.LiandClaude committed 2026-06-29 17:03:57 +08:00
commit 2a93de600d
134 files changed
+19595

No files matched your search

+143
View File
@@ -0,0 +1,143 @@
import { Link, useLocation, useNavigate } from 'react-router'
import {
LayoutDashboard,
Server,
Monitor,
HardDrive,
Rocket,
Settings,
LogOut,
PanelLeftClose,
PanelLeftOpen,
Shield,
ChevronRight,
Activity,
} from 'lucide-react'
import { useState, useEffect } from 'react'
const menuItems = [
{ path: '/', icon: LayoutDashboard, label: '仪表盘' },
{ path: '/clusters', icon: Server, label: '集群管理' },
{ path: '/hosts', icon: Monitor, label: '主机管理' },
{ path: '/storage', icon: HardDrive, label: '存储配置' },
{ path: '/deployments', icon: Rocket, label: '部署管理' },
{ path: '/settings', icon: Settings, label: '系统设置' },
]
export default function Layout({ children }: { children: React.ReactNode }) {
const [sidebarOpen, setSidebarOpen] = useState(true)
const [user, setUser] = useState<{ username: string; role: string } | null>(null)
const location = useLocation()
const navigate = useNavigate()
useEffect(() => {
const stored = localStorage.getItem('user')
if (stored) {
setUser(JSON.parse(stored))
}
}, [])
const handleLogout = () => {
localStorage.removeItem('token')
localStorage.removeItem('user')
navigate('/login')
}
return (
<div className="flex h-screen bg-slate-50 dark:bg-slate-950">
{/* Sidebar */}
<aside
className={`${
sidebarOpen ? 'w-64' : 'w-16'
} bg-slate-900 text-white transition-all duration-300 flex flex-col`}
>
{/* Logo */}
<div className="h-16 flex items-center px-4 border-b border-slate-700">
{sidebarOpen ? (
<div className="flex items-center gap-2">
<div className="w-8 h-8 rounded-lg bg-emerald-500 flex items-center justify-center">
<Activity className="w-5 h-5 text-white" />
</div>
<span className="font-bold text-lg tracking-tight">LokiDeploy</span>
</div>
) : (
<div className="w-8 h-8 rounded-lg bg-emerald-500 flex items-center justify-center mx-auto">
<Activity className="w-5 h-5 text-white" />
</div>
)}
</div>
{/* Navigation */}
<nav className="flex-1 py-4 px-2 space-y-1">
{menuItems.map((item) => {
const isActive = location.pathname === item.path
return (
<Link
key={item.path}
to={item.path}
className={`flex items-center gap-3 px-3 py-2.5 rounded-lg transition-all ${
isActive
? 'bg-emerald-600 text-white'
: 'text-slate-400 hover:bg-slate-800 hover:text-white'
}`}
title={!sidebarOpen ? item.label : undefined}
>
<item.icon className="w-5 h-5 flex-shrink-0" />
{sidebarOpen && <span className="text-sm font-medium">{item.label}</span>}
{sidebarOpen && isActive && <ChevronRight className="w-4 h-4 ml-auto" />}
</Link>
)
})}
</nav>
{/* Bottom Actions */}
<div className="p-2 border-t border-slate-700">
<button
onClick={() => setSidebarOpen(!sidebarOpen)}
title={sidebarOpen ? '收起菜单' : '展开菜单'}
className="flex items-center justify-center w-full py-2.5 rounded-lg text-slate-400 hover:bg-slate-800 hover:text-white transition-all"
>
{sidebarOpen ? <PanelLeftClose className="w-5 h-5" /> : <PanelLeftOpen className="w-5 h-5" />}
</button>
</div>
</aside>
{/* Main Content */}
<div className="flex-1 flex flex-col overflow-hidden">
{/* Top Bar */}
<header className="h-16 bg-white dark:bg-slate-900 border-b border-slate-200 dark:border-slate-800 flex items-center justify-between px-6">
<h1 className="text-xl font-semibold text-slate-800 dark:text-white">
{menuItems.find((item) => item.path === location.pathname)?.label || '仪表盘'}
</h1>
<div className="flex items-center gap-4">
{user && (
<div className="flex items-center gap-3 text-sm text-slate-600 dark:text-slate-300">
<div className="flex items-center gap-2">
<Shield className="w-4 h-4" />
<span>{user.username}</span>
<span className="px-2 py-0.5 rounded-full bg-emerald-100 text-emerald-700 text-xs font-medium">
{user.role === 'admin' ? '管理员' : user.role}
</span>
</div>
<button
onClick={handleLogout}
title="退出登录"
className="flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-slate-500 hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-900/30 transition-all"
>
<LogOut className="w-4 h-4" />
<span>退出</span>
</button>
</div>
)}
</div>
</header>
{/* Page Content */}
<main className="flex-1 overflow-auto p-6">
{children}
</main>
</div>
</div>
)
}