From a5ee886f2dcb457f4b28d0e7b064519a2a027097 Mon Sep 17 00:00:00 2001 From: dushixiang Date: Sat, 24 Jan 2026 20:53:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=89=8D=E7=AB=AF=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/index.css | 53 +------------- web/src/portal/components/Card.tsx | 23 ++---- .../portal/components/ChartPlaceholder.tsx | 28 +++----- web/src/portal/components/CustomTooltip.tsx | 36 +++------- web/src/portal/components/EmptyState.tsx | 32 +++------ web/src/portal/components/LoadingSpinner.tsx | 17 ++--- .../portal/components/TimeRangeSelector.tsx | 51 +++----------- web/src/portal/pages/PublicLayout.tsx | 70 +------------------ web/src/portal/pages/ServerList.tsx | 11 +-- web/src/router/index.tsx | 4 +- 10 files changed, 54 insertions(+), 271 deletions(-) diff --git a/web/src/index.css b/web/src/index.css index e71bd12..2818a0a 100644 --- a/web/src/index.css +++ b/web/src/index.css @@ -3,64 +3,13 @@ /* Tailwind v4 暗色模式配置 */ @variant dark (&:where(.dark, .dark *)); -/* 全局样式 */ -* { - scrollbar-width: thin; -} - /* 全局背景色 */ body { background-color: white; - scrollbar-gutter: stable; } body.dark { - background-color: #141414; -} - -/* 滚动条样式 */ -::-webkit-scrollbar { - width: 10px; - height: 10px; -} - -::-webkit-scrollbar-track { - background: rgb(241, 245, 249); - border-radius: 5px; - margin: 2px; -} - -::-webkit-scrollbar-thumb { - background: rgb(203, 213, 225); - border-radius: 5px; - border: 2px solid rgb(241, 245, 249); - transition: background-color 0.2s; -} - -::-webkit-scrollbar-thumb:hover { - background: rgb(148, 163, 184); -} - -::-webkit-scrollbar-thumb:active { - background: rgb(100, 116, 139); -} - -/* 暗色模式滚动条 */ -.dark ::-webkit-scrollbar-track { - background: rgb(30, 41, 59); -} - -.dark ::-webkit-scrollbar-thumb { - background: rgb(71, 85, 105); - border-color: rgb(30, 41, 59); -} - -.dark ::-webkit-scrollbar-thumb:hover { - background: rgb(100, 116, 139); -} - -.dark ::-webkit-scrollbar-thumb:active { - background: rgb(148, 163, 184); + background-color: #05050a; } /* 标签过滤器滚动条样式 */ diff --git a/web/src/portal/components/Card.tsx b/web/src/portal/components/Card.tsx index 5607956..d185709 100644 --- a/web/src/portal/components/Card.tsx +++ b/web/src/portal/components/Card.tsx @@ -1,5 +1,4 @@ import type {ReactNode} from 'react'; -import {cn} from '@/lib/utils'; import CyberCard from "@portal/components/CyberCard.tsx"; interface CardProps { @@ -7,7 +6,7 @@ interface CardProps { description?: string; action?: ReactNode; children: ReactNode; - variant?: 'light' | 'dark'; + className?: string; } export const Card = ({ @@ -15,30 +14,20 @@ export const Card = ({ description, action, children, - variant = 'light', + className, }: CardProps) => { - const isDark = variant === 'dark'; - return ( - + {(title || description || action) && ( -
+
{title && ( -

+

{title}

)} {description && ( -

+

{description}

)} diff --git a/web/src/portal/components/ChartPlaceholder.tsx b/web/src/portal/components/ChartPlaceholder.tsx index 17ad087..71e2026 100644 --- a/web/src/portal/components/ChartPlaceholder.tsx +++ b/web/src/portal/components/ChartPlaceholder.tsx @@ -2,43 +2,31 @@ import {TrendingUp} from 'lucide-react'; import {cn} from '@/lib/utils'; interface ChartPlaceholderProps { - variant?: 'light' | 'dark'; icon?: typeof TrendingUp; title?: string; subtitle?: string; heightClass?: string; + className?: string; } export const ChartPlaceholder = ({ - variant = 'light', icon: Icon = TrendingUp, title = '暂无数据', subtitle = '等待采集新数据后展示图表', heightClass = 'h-52', + className, }: ChartPlaceholderProps) => { - const isDark = variant === 'dark'; - return (
- -

{title}

+ +

{title}

{subtitle && ( -

+

{subtitle}

)} diff --git a/web/src/portal/components/CustomTooltip.tsx b/web/src/portal/components/CustomTooltip.tsx index f64c72f..2414980 100644 --- a/web/src/portal/components/CustomTooltip.tsx +++ b/web/src/portal/components/CustomTooltip.tsx @@ -14,41 +14,30 @@ type CustomTooltipProps = { }; }>; label?: string | number; - variant?: 'light' | 'dark'; unit?: string; + className?: string; }; -export const CustomTooltip = ({active, payload, label, variant = 'light', unit = '%'}: CustomTooltipProps) => { +export const CustomTooltip = ({active, payload, label, unit = '%', className}: CustomTooltipProps) => { if (!active || !payload || payload.length === 0) { return null; } - const isDark = variant === 'dark'; - // 从 payload 中获取完整的时间戳信息(如果有的话) const fullTimestamp = payload[0]?.payload?.timestamp; const displayLabel = fullTimestamp - ? dayjs(fullTimestamp).format(isDark ? 'YYYY-MM-DD HH:mm:ss' : 'MM-DD HH:mm') + ? dayjs(fullTimestamp).format('MM-DD HH:mm') : label; return (
-

+

{displayLabel}

-
+
{payload.map((entry, index) => { if (!entry) { return null; @@ -63,18 +52,13 @@ export const CustomTooltip = ({active, payload, label, variant = 'light', unit = : entry.value; return ( -

+

- - {title}: {value}{unit} + + {title}: {value}{unit}

); diff --git a/web/src/portal/components/EmptyState.tsx b/web/src/portal/components/EmptyState.tsx index 6787f10..1d7dcb5 100644 --- a/web/src/portal/components/EmptyState.tsx +++ b/web/src/portal/components/EmptyState.tsx @@ -1,38 +1,26 @@ -import {AlertCircle, Server} from 'lucide-react'; +import {AlertCircle} from 'lucide-react'; import {cn} from '@/lib/utils'; interface EmptyStateProps { - variant?: 'light' | 'dark'; message?: string; showBackButton?: boolean; + className?: string; } -export const EmptyState = ({variant = 'light', message, showBackButton = false}: EmptyStateProps) => { - const isDark = variant === 'dark'; - const Icon = isDark ? Server : AlertCircle; - const defaultMessage = isDark ? '服务器不存在或已离线' : '监控数据不存在'; - +export const EmptyState = ({message = '监控数据不存在', showBackButton = false, className}: EmptyStateProps) => { return (
-
- +
+
-

- {message || defaultMessage} +

+ {message}

- {showBackButton && !isDark && ( + {showBackButton && (