diff --git a/src/components/sections/Header.tsx b/src/components/sections/Header.tsx index cb2452e..8f2f039 100644 --- a/src/components/sections/Header.tsx +++ b/src/components/sections/Header.tsx @@ -203,19 +203,59 @@ export const Header = ({ )} {isInstancePage && ( <> - - {enableAdminButton && ( - - + + + + {theme === "dark" ? ( + + ) : ( + + )} + {theme === "dark" ? "浅色模式" : "深色模式"} + + {enableAdminButton && ( + + + + 管理员 + + + )} + + + ) : ( + <> + - + {enableAdminButton && ( + + + + )} + )} )} diff --git a/src/components/ui/chart.tsx b/src/components/ui/chart.tsx index d83b953..4a95f8c 100644 --- a/src/components/ui/chart.tsx +++ b/src/components/ui/chart.tsx @@ -55,12 +55,17 @@ function ChartContainer({ data-slot="chart" data-chart={chartId} className={cn( - "[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden", + "[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border flex justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden", className )} + style={{ position: "relative", overflow: "hidden" }} {...props}> - + {children} diff --git a/src/pages/instance/Instance.tsx b/src/pages/instance/Instance.tsx index b489c13..09d20d6 100644 --- a/src/pages/instance/Instance.tsx +++ b/src/pages/instance/Instance.tsx @@ -116,7 +116,7 @@ const Instance = memo(({ node }: InstanceProps) => {

总流量

-

+

{node.traffic_limit && isOnline && ( { )}

-

+

负载

diff --git a/src/pages/instance/LoadCharts.tsx b/src/pages/instance/LoadCharts.tsx index 8557596..45be96d 100644 --- a/src/pages/instance/LoadCharts.tsx +++ b/src/pages/instance/LoadCharts.tsx @@ -65,8 +65,8 @@ const LoadCharts = memo(({ node, hours, liveData }: LoadChartsProps) => { ); // 样式和颜色 - const cn = "flex flex-col w-full h-full gap-4 justify-between"; - const chartMargin = { top: 10, right: 16, bottom: 10, left: 16 }; + const cn = "flex flex-col w-full overflow-hidden"; + const chartMargin = { top: 8, right: 16, bottom: 8, left: 16 }; const colors = ["#F38181", "#FCE38A", "#EAFFD0", "#95E1D3"]; // 图表配置 @@ -266,6 +266,12 @@ const LoadCharts = memo(({ node, hours, liveData }: LoadChartsProps) => { const DataComponent = config.type === "area" ? Area : (Line as React.ComponentType); + // 只指定高度,让宽度自适应 + const chartProps = { + height: 140, // 更小的高度以确保完全适应容器 + style: { overflow: "visible" }, // 通过内联样式解决Safari溢出问题 + }; + const chartConfig = config.series ? config.series.reduce((acc: any, series: any) => { acc[series.dataKey] = { @@ -282,62 +288,73 @@ const LoadCharts = memo(({ node, hours, liveData }: LoadChartsProps) => { }; return ( - - + + {config.title} - {config.value} +
+ {config.value} +
- - - - - - ( - - )} - /> - {config.series ? ( - config.series.map((series: any) => ( +
+ + + + + + ( + + )} + /> + {config.series ? ( + config.series.map((series: any) => ( + + )) + ) : ( - )) - ) : ( - - )} - - + )} + + +
); }; @@ -354,7 +371,9 @@ const LoadCharts = memo(({ node, hours, liveData }: LoadChartsProps) => {

{error}

)} -
+
{chartConfigs.map(renderChart)}