refactor: dashboard

This commit is contained in:
xiaozhou233 committed 2026-08-09 22:10:03 +08:00
1 parent 5da242b092
commit 73b648a782
21 files changed
+902 -519

No files matched your search

+10 -28
View File
@@ -1,33 +1,15 @@
import { Route, Routes } from 'react-router-dom'
import Navbar from './components/Navbar'
import Banner from './components/Banner'
import { Outlet } from 'react-router-dom'
import NavBar from './components/NavBar'
import Footer from './components/Footer'
import DashboardLayout from './layouts/DashboardLayout'
import Placeholder from './pages/Placeholder'
function App() {
export default function App() {
return (
<Routes>
<Route
path="/"
element={
<>
<Navbar />
<main>
<Banner />
</main>
<Footer />
</>
}
/>
<Route path="/dashboard" element={<DashboardLayout />}>
<Route index element={<Placeholder title="概览" />} />
<Route path="tasks" element={<Placeholder title="任务" />} />
<Route path="monitor" element={<Placeholder title="监控" />} />
<Route path="settings" element={<Placeholder title="设置" />} />
</Route>
</Routes>
<div className="min-h-screen bg-slate-50 text-slate-900">
<NavBar />
<main>
<Outlet />
</main>
<Footer />
</div>
)
}
export default App
-76
View File
@@ -1,76 +0,0 @@
.banner {
position: relative;
min-height: 100svh;
display: flex;
align-items: center;
justify-content: center;
background-image: url('/banner.jpg');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
.banner::before {
content: '';
position: absolute;
inset: 0;
background: rgba(0, 0, 0, 0.45);
}
.banner-overlay {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
gap: 32px;
padding: 120px 24px 64px;
text-align: center;
}
.banner-title {
margin: 0;
font-size: 64px;
font-weight: 700;
letter-spacing: -1px;
color: #fff;
text-shadow: 0 2px 16px rgba(0, 0, 0, 0.5);
}
.banner-button {
display: inline-block;
padding: 14px 40px;
font-size: 18px;
font-weight: 600;
color: #fff;
background: rgba(17, 18, 23, 0.65);
border: 1px solid rgba(255, 255, 255, 0.5);
border-radius: 999px;
text-decoration: none;
backdrop-filter: blur(6px);
transition:
background 0.25s,
transform 0.25s;
&:hover {
background: #c084fc;
border-color: #c084fc;
transform: translateY(-2px);
}
}
@media (max-width: 1024px) {
.banner-title {
font-size: 40px;
}
}
@media (max-width: 640px) {
.banner-title {
font-size: 32px;
}
.banner-button {
padding: 12px 32px;
font-size: 16px;
}
}
-16
View File
@@ -1,16 +0,0 @@
import './Banner.css'
function Banner() {
return (
<section className="banner">
<div className="banner-overlay">
<h1 className="banner-title">JuiceWorkStation</h1>
<a className="banner-button" href="/dashboard">
进入控制面板
</a>
</div>
</section>
)
}
export default Banner
-26
View File
@@ -1,26 +0,0 @@
.footer {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 8px;
padding: 24px;
background: rgba(22, 23, 29, 0.85);
border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.footer-text {
margin: 0;
font-size: 14px;
color: rgba(255, 255, 255, 0.6);
}
.footer-version {
display: flex;
flex-direction: column;
align-items: center;
gap: 2px;
font-family: ui-monospace, Consolas, monospace;
font-size: 12px;
color: rgba(255, 255, 255, 0.4);
}
+4 -9
View File
@@ -1,5 +1,4 @@
import { useEffect, useState } from 'react'
import './Footer.css'
interface VersionInfo {
buildNumber: string
@@ -8,7 +7,7 @@ interface VersionInfo {
time: string
}
function Footer() {
export default function Footer() {
const [version, setVersion] = useState<VersionInfo | null>(null)
useEffect(() => {
@@ -19,12 +18,10 @@ function Footer() {
}, [])
return (
<footer className="footer">
<p className="footer-text">
© {new Date().getFullYear()} JuiceWorkStation. All rights reserved.
</p>
<footer className="border-t border-slate-200 bg-white py-6 text-center text-sm text-slate-400">
<p>© {new Date().getFullYear()} JuiceWorkStation</p>
{version && (
<div className="footer-version">
<div className="mt-2 flex flex-col items-center gap-0.5 font-mono text-xs text-slate-300">
<span>Build {version.buildNumber}</span>
<span>
{version.branch}-{version.commit}
@@ -35,5 +32,3 @@ function Footer() {
</footer>
)
}
export default Footer
-51
View File
@@ -1,51 +0,0 @@
.navbar {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px 32px;
background: rgba(22, 23, 29, 0.85);
backdrop-filter: blur(8px);
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.navbar-brand {
font-size: 20px;
font-weight: 700;
color: #fff;
text-decoration: none;
letter-spacing: 0.2px;
}
.navbar-links {
list-style: none;
display: flex;
gap: 24px;
margin: 0;
padding: 0;
a {
color: rgba(255, 255, 255, 0.8);
text-decoration: none;
font-size: 15px;
transition: color 0.2s;
&:hover {
color: #c084fc;
}
}
}
@media (max-width: 640px) {
.navbar {
padding: 12px 16px;
}
.navbar-links {
gap: 16px;
}
}
+83 -19
View File
@@ -1,25 +1,89 @@
import './Navbar.css'
import { useState } from 'react'
import { NavLink } from 'react-router-dom'
const links = [
{ label: '首页', href: '/' },
{ label: '控制面板', href: '/dashboard' },
{ to: '/', label: '首页' },
{ to: '/dashboard', label: '控制面板' },
{ to: '/settings', label: '设置' },
]
function Navbar() {
return (
<nav className="navbar">
<a href="/" className="navbar-brand">
JuiceWorkStation
</a>
<ul className="navbar-links">
{links.map((link) => (
<li key={link.href}>
<a href={link.href}>{link.label}</a>
</li>
))}
</ul>
</nav>
)
function linkClassName({ isActive }: { isActive: boolean }) {
return `block rounded-md px-3 py-2 text-sm transition-colors ${
isActive
? 'bg-indigo-50 font-medium text-indigo-600'
: 'text-slate-600 hover:bg-slate-100 hover:text-slate-900'
}`
}
export default Navbar
export default function NavBar() {
const [open, setOpen] = useState(false)
return (
<header className="sticky top-0 z-50 border-b border-slate-200 bg-white/80 backdrop-blur">
<nav className="mx-auto flex h-16 max-w-6xl items-center justify-between px-6">
<NavLink to="/" className="flex items-center gap-2 text-lg font-semibold text-slate-900">
<span className="grid size-8 place-items-center rounded-lg bg-indigo-600 text-sm font-bold text-white">
J
</span>
JuiceWorkStation
</NavLink>
<ul className="hidden items-center gap-1 md:flex">
{links.map((link) => (
<li key={link.to}>
<NavLink to={link.to} end={link.to === '/'} className={linkClassName}>
{link.label}
</NavLink>
</li>
))}
</ul>
<button
type="button"
className="grid size-10 place-items-center rounded-md text-slate-600 transition-colors hover:bg-slate-100 md:hidden"
aria-label={open ? '关闭菜单' : '打开菜单'}
aria-expanded={open}
onClick={() => setOpen((v) => !v)}
>
<svg
className="size-6"
fill="none"
viewBox="0 0 24 24"
strokeWidth={1.8}
stroke="currentColor"
aria-hidden="true"
>
{open ? (
<path strokeLinecap="round" strokeLinejoin="round" d="M6 18 18 6M6 6l12 12" />
) : (
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M3.75 6.75h16.5M3.75 12h16.5M3.75 17.25h16.5"
/>
)}
</svg>
</button>
</nav>
{open && (
<div className="border-t border-slate-200 bg-white px-6 py-3 md:hidden">
<ul className="space-y-1">
{links.map((link) => (
<li key={link.to}>
<NavLink
to={link.to}
end={link.to === '/'}
className={linkClassName}
onClick={() => setOpen(false)}
>
{link.label}
</NavLink>
</li>
))}
</ul>
</div>
)}
</header>
)
}
+4 -105
View File
@@ -1,107 +1,6 @@
:root {
--text: #6b6375;
--text-h: #08060d;
--bg: #fff;
--border: #e5e4e7;
--code-bg: #f4f3ec;
--accent: #aa3bff;
--accent-bg: rgba(170, 59, 255, 0.1);
--accent-border: rgba(170, 59, 255, 0.5);
--social-bg: rgba(244, 243, 236, 0.5);
--shadow:
rgba(0, 0, 0, 0.1) 0 10px 15px -3px, rgba(0, 0, 0, 0.05) 0 4px 6px -2px;
@import 'tailwindcss';
--sans: system-ui, 'Segoe UI', Roboto, sans-serif;
--heading: system-ui, 'Segoe UI', Roboto, sans-serif;
--mono: ui-monospace, Consolas, monospace;
font: 18px/145% var(--sans);
letter-spacing: 0.18px;
color-scheme: light dark;
color: var(--text);
background: var(--bg);
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
@media (max-width: 1024px) {
font-size: 16px;
}
}
@media (prefers-color-scheme: dark) {
:root {
--text: #9ca3af;
--text-h: #f3f4f6;
--bg: #16171d;
--border: #2e303a;
--code-bg: #1f2028;
--accent: #c084fc;
--accent-bg: rgba(192, 132, 252, 0.15);
--accent-border: rgba(192, 132, 252, 0.5);
--social-bg: rgba(47, 48, 58, 0.5);
--shadow:
rgba(0, 0, 0, 0.4) 0 10px 15px -3px, rgba(0, 0, 0, 0.25) 0 4px 6px -2px;
}
#social .button-icon {
filter: invert(1) brightness(2);
}
}
#root {
min-height: 100svh;
display: flex;
flex-direction: column;
box-sizing: border-box;
}
body {
margin: 0;
background: #16171d;
}
h1,
h2 {
font-family: var(--heading);
font-weight: 500;
color: var(--text-h);
}
h1 {
font-size: 56px;
letter-spacing: -1.68px;
margin: 32px 0;
@media (max-width: 1024px) {
font-size: 36px;
margin: 20px 0;
}
}
h2 {
font-size: 24px;
line-height: 118%;
letter-spacing: -0.24px;
margin: 0 0 8px;
@media (max-width: 1024px) {
font-size: 20px;
}
}
p {
margin: 0;
}
code,
.counter {
font-family: var(--mono);
display: inline-flex;
border-radius: 4px;
color: var(--text-h);
}
code {
font-size: 15px;
line-height: 135%;
padding: 4px 8px;
background: var(--code-bg);
@theme {
--font-sans: system-ui, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', Roboto,
sans-serif;
}
-101
View File
@@ -1,101 +0,0 @@
.dashboard {
min-height: 100svh;
display: flex;
flex-direction: column;
background: #0f1014;
}
.dashboard-topbar {
display: flex;
align-items: center;
justify-content: space-between;
padding: 14px 24px;
background: #1a1c22;
border-bottom: 1px solid #2a2d35;
}
.dashboard-brand {
font-size: 18px;
font-weight: 700;
color: #fff;
text-decoration: none;
}
.dashboard-user {
font-size: 14px;
color: #9ca3af;
}
.dashboard-body {
display: flex;
flex: 1;
}
.dashboard-sidebar {
width: 200px;
flex-shrink: 0;
padding: 16px 0;
background: #16171d;
border-right: 1px solid #2a2d35;
nav {
display: flex;
flex-direction: column;
}
}
.dashboard-nav-link {
display: block;
padding: 12px 24px;
font-size: 14px;
color: #9ca3af;
text-decoration: none;
border-left: 3px solid transparent;
transition:
color 0.2s,
background 0.2s;
&:hover {
color: #fff;
background: rgba(255, 255, 255, 0.05);
}
&.active {
color: #c084fc;
background: rgba(192, 132, 252, 0.1);
border-left-color: #c084fc;
}
}
.dashboard-content {
flex: 1;
padding: 32px;
overflow: auto;
}
@media (max-width: 768px) {
.dashboard-body {
flex-direction: column;
}
.dashboard-sidebar {
width: 100%;
border-right: none;
border-bottom: 1px solid #2a2d35;
nav {
flex-direction: row;
overflow-x: auto;
}
}
.dashboard-nav-link {
border-left: none;
border-bottom: 3px solid transparent;
white-space: nowrap;
}
.dashboard-content {
padding: 20px;
}
}
-45
View File
@@ -1,45 +0,0 @@
import { NavLink, Outlet } from 'react-router-dom'
import './DashboardLayout.css'
const items = [
{ label: '概览', href: '/dashboard' },
{ label: '任务', href: '/dashboard/tasks' },
{ label: '监控', href: '/dashboard/monitor' },
{ label: '设置', href: '/dashboard/settings' },
]
function DashboardLayout() {
return (
<div className="dashboard">
<header className="dashboard-topbar">
<NavLink to="/" className="dashboard-brand">
JuiceWorkStation
</NavLink>
<div className="dashboard-user">管理员</div>
</header>
<div className="dashboard-body">
<aside className="dashboard-sidebar">
<nav>
{items.map((item) => (
<NavLink
key={item.href}
to={item.href}
end={item.href === '/dashboard'}
className={({ isActive }) =>
isActive ? 'dashboard-nav-link active' : 'dashboard-nav-link'
}
>
{item.label}
</NavLink>
))}
</nav>
</aside>
<main className="dashboard-content">
<Outlet />
</main>
</div>
</div>
)
}
export default DashboardLayout
+11 -2
View File
@@ -1,13 +1,22 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { HashRouter } from 'react-router-dom'
import { HashRouter, Route, Routes } from 'react-router-dom'
import './index.css'
import App from './App.tsx'
import Home from './pages/Home.tsx'
import Dashboard from './pages/Dashboard.tsx'
import Settings from './pages/Settings.tsx'
createRoot(document.getElementById('root')!).render(
<StrictMode>
<HashRouter>
<App />
<Routes>
<Route element={<App />}>
<Route index element={<Home />} />
<Route path="/dashboard" element={<Dashboard />} />
<Route path="/settings" element={<Settings />} />
</Route>
</Routes>
</HashRouter>
</StrictMode>,
)
+50
View File
@@ -0,0 +1,50 @@
import { useState } from 'react'
const navItems = [
{ key: 'overview', label: '概览' },
{ key: 'tasks', label: '任务' },
{ key: 'automation', label: '自动化' },
{ key: 'logs', label: '日志' },
]
export default function Dashboard() {
const [active, setActive] = useState('overview')
return (
<div className="flex min-h-[calc(100vh-4rem)] flex-col md:flex-row">
<aside className="shrink-0 bg-white md:w-56 md:border-r md:border-slate-200">
<nav className="border-b border-slate-200 md:border-b-0">
<ul className="flex gap-1 overflow-x-auto px-3 py-3 md:flex-col md:space-y-1">
{navItems.map((item) => (
<li key={item.key}>
<button
type="button"
onClick={() => setActive(item.key)}
className={`w-full whitespace-nowrap rounded-md px-3 py-2 text-left text-sm transition-colors ${
active === item.key
? 'bg-indigo-50 font-medium text-indigo-600'
: 'text-slate-600 hover:bg-slate-100 hover:text-slate-900'
}`}
>
{item.label}
</button>
</li>
))}
</ul>
</nav>
</aside>
<main className="flex-1 px-6 py-10">
<h1 className="text-2xl font-semibold text-slate-900">
控制面板 / {navItems.find((item) => item.key === active)?.label}
</h1>
<div className="mt-8 flex flex-col items-center justify-center rounded-xl border border-dashed border-slate-300 bg-white py-24 text-center">
<div className="grid size-16 place-items-center rounded-2xl bg-indigo-50 text-2xl">🚧</div>
<p className="mt-4 rounded-md bg-slate-100 px-3 py-1 text-sm text-slate-500">
页面建设中,敬请期待
</p>
</div>
</main>
</div>
)
}
+98
View File
@@ -0,0 +1,98 @@
import { Link } from 'react-router-dom'
const features = [
{
title: '实时监控',
description: '集中查看各服务器在线状态与 CPU、内存、磁盘使用情况,运行状况一目了然。',
bg: 'bg-indigo-50 text-indigo-600',
icon: (
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor" className="size-6">
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M2.25 12.75V12A2.25 2.25 0 014.5 9.75h15A2.25 2.25 0 0121.75 12v.75m-8.69-6.44l-2.12-2.12a1.5 1.5 0 00-1.061-.44H4.5A2.25 2.25 0 002.25 6v12a2.25 2.25 0 002.25 2.25h15A2.25 2.25 0 0021.75 18V9a2.25 2.25 0 00-2.25-2.25h-5.379a1.5 1.5 0 01-1.06-.44z"
/>
</svg>
),
},
{
title: '任务管理',
description: '统一管理各服务器上的任务,创建、跟踪与批量执行尽在掌控。',
bg: 'bg-emerald-50 text-emerald-600',
icon: (
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor" className="size-6">
<path strokeLinecap="round" strokeLinejoin="round" d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
),
},
{
title: '自动化',
description: '编排自动化流程与定时调度,让重复工作自动完成,释放人力。',
bg: 'bg-amber-50 text-amber-600',
icon: (
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor" className="size-6">
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.324.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 011.37.49l1.296 2.247a1.125 1.125 0 01-.26 1.431l-1.003.827c-.293.24-.438.613-.431.992a6.759 6.759 0 010 .255c-.007.378.138.75.43.99l1.005.828c.424.35.534.954.26 1.43l-1.298 2.247a1.125 1.125 0 01-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.57 6.57 0 01-.22.128c-.331.183-.581.495-.644.869l-.213 1.28c-.09.543-.56.941-1.11.941h-2.594c-.55 0-1.02-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 01-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 01-1.369-.49l-1.297-2.247a1.125 1.125 0 01.26-1.431l1.004-.827c.292-.24.437-.613.43-.992a6.932 6.932 0 010-.255c.007-.378-.138-.75-.43-.99l-1.004-.828a1.125 1.125 0 01-.26-1.43l1.297-2.247a1.125 1.125 0 011.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.087.22-.128.332-.183.582-.495.644-.869l.214-1.281z"
/>
<path strokeLinecap="round" strokeLinejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
</svg>
),
},
{
title: '日志中心',
description: '统一收集与检索各服务器运行日志,问题定位更加高效。',
bg: 'bg-rose-50 text-rose-600',
icon: (
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor" className="size-6">
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M6.75 7.5l3 2.25-3 2.25m4.5 0h3m-9 8.25h13.5A2.25 2.25 0 0021 18V6a2.25 2.25 0 00-2.25-2.25H5.25A2.25 2.25 0 003 6v12a2.25 2.25 0 002.25 2.25z"
/>
</svg>
),
},
]
export default function Home() {
return (
<div>
<section className="relative flex h-[calc(100vh-4rem)] items-center justify-center overflow-hidden">
<img src="/banner.jpg" alt="" className="absolute inset-0 size-full object-cover" />
<div className="absolute inset-0 bg-slate-900/60" />
<div className="relative z-10 mx-auto max-w-3xl px-6 text-center text-white">
<h1 className="text-5xl font-bold tracking-tight md:text-6xl">JuiceWorkStation</h1>
<Link
to="/dashboard"
className="mt-10 inline-flex items-center rounded-lg bg-indigo-500 px-6 py-3 text-base font-medium text-white shadow-lg shadow-indigo-900/40 transition-colors hover:bg-indigo-400"
>
进入控制面板
</Link>
</div>
</section>
<section className="border-t border-slate-200 py-20">
<div className="mx-auto max-w-6xl px-6">
<h2 className="text-center text-2xl font-semibold text-slate-900">功能展示</h2>
<p className="mt-1 text-center text-sm text-slate-500">JuiceWorkStation 提供的核心能力</p>
<div className="mt-10 grid gap-5 sm:grid-cols-2 lg:grid-cols-4">
{features.map((feature) => (
<div
key={feature.title}
className="rounded-xl border border-slate-200 bg-white p-6 shadow-sm transition-shadow hover:shadow-md"
>
<div className={`grid size-11 place-items-center rounded-lg ${feature.bg}`}>
{feature.icon}
</div>
<h3 className="mt-4 font-semibold text-slate-900">{feature.title}</h3>
<p className="mt-2 text-sm leading-relaxed text-slate-500">{feature.description}</p>
</div>
))}
</div>
</div>
</section>
</div>
)
}
-21
View File
@@ -1,21 +0,0 @@
.placeholder-title {
margin: 0 0 24px;
font-size: 28px;
font-weight: 600;
color: #f3f4f6;
}
.placeholder-box {
display: flex;
align-items: center;
justify-content: center;
min-height: 320px;
border: 1px dashed #2a2d35;
border-radius: 12px;
background: #1a1c22;
color: #9ca3af;
p {
font-size: 15px;
}
}
-18
View File
@@ -1,18 +0,0 @@
import './Placeholder.css'
interface PlaceholderProps {
title: string
}
function Placeholder({ title }: PlaceholderProps) {
return (
<section className="placeholder">
<h1 className="placeholder-title">{title}</h1>
<div className="placeholder-box">
<p>该页面正在建设中,敬请期待。</p>
</div>
</section>
)
}
export default Placeholder
+10
View File
@@ -0,0 +1,10 @@
export default function Settings() {
return (
<section className="mx-auto flex min-h-[70vh] max-w-6xl flex-col items-center justify-center px-6 text-center">
<div className="grid size-16 place-items-center rounded-2xl bg-indigo-50 text-2xl">🚧</div>
<h1 className="mt-6 text-2xl font-semibold text-slate-900">设置</h1>
<p className="mt-2 text-slate-500">系统偏好与账号配置</p>
<p className="mt-4 rounded-md bg-slate-100 px-3 py-1 text-sm text-slate-500">页面建设中,敬请期待</p>
</section>
)
}