mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-10 17:26:38 +08:00
style(wavelet): 节点网络/磁盘趋势图对齐原版 ECharts
改用 TrendChart 组件,恢复系列摘要卡与平滑面积折线图样式。
This commit is contained in:
@@ -1,31 +1,16 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import {Area, AreaChart, CartesianGrid, Line, XAxis, YAxis} from 'recharts';
|
import {TrendChart} from '@/components/data/trend-chart';
|
||||||
|
|
||||||
import {Card, CardContent, CardDescription, CardHeader, CardTitle} from '@/components/ui/card';
|
|
||||||
import {
|
import {
|
||||||
ChartConfig,
|
Card,
|
||||||
ChartContainer,
|
CardContent,
|
||||||
ChartLegend,
|
CardDescription,
|
||||||
ChartLegendContent,
|
CardHeader,
|
||||||
ChartTooltip,
|
CardTitle,
|
||||||
ChartTooltipContent,
|
} from '@/components/ui/card';
|
||||||
} from '@/components/ui/chart';
|
|
||||||
import type {DiskIOTrendPoint} from '@/lib/services/openflare';
|
import type {DiskIOTrendPoint} from '@/lib/services/openflare';
|
||||||
|
|
||||||
import {formatTrendHour} from '../../components/dashboard/dashboard-utils';
|
import {formatBytes, formatTrendHour} from '../../components/dashboard/dashboard-utils';
|
||||||
import {formatBytes} from './node-utils';
|
|
||||||
|
|
||||||
const chartConfig = {
|
|
||||||
diskRead: {
|
|
||||||
label: '磁盘读',
|
|
||||||
color: 'hsl(var(--chart-3))',
|
|
||||||
},
|
|
||||||
diskWrite: {
|
|
||||||
label: '磁盘写',
|
|
||||||
color: 'hsl(var(--chart-5))',
|
|
||||||
},
|
|
||||||
} satisfies ChartConfig;
|
|
||||||
|
|
||||||
export function DiskIOTrendChart({
|
export function DiskIOTrendChart({
|
||||||
points,
|
points,
|
||||||
@@ -36,91 +21,33 @@ export function DiskIOTrendChart({
|
|||||||
title?: string;
|
title?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
}) {
|
}) {
|
||||||
const data = points.map((point) => ({
|
|
||||||
hour: formatTrendHour(point.bucket_started_at),
|
|
||||||
diskRead: point.disk_read_bytes,
|
|
||||||
diskWrite: point.disk_write_bytes,
|
|
||||||
}));
|
|
||||||
|
|
||||||
if (data.length === 0) {
|
|
||||||
return (
|
|
||||||
<Card className="border-dashed shadow-none">
|
|
||||||
<CardHeader>
|
|
||||||
<CardTitle className="text-sm font-semibold">{title}</CardTitle>
|
|
||||||
<CardDescription className="text-xs">{description}</CardDescription>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent>
|
|
||||||
<div className="flex h-[280px] items-center justify-center text-xs text-muted-foreground">
|
|
||||||
暂无趋势数据
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className="border-dashed shadow-none">
|
<Card className="border-dashed shadow-none">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="text-sm font-semibold">{title}</CardTitle>
|
<CardTitle className="text-sm font-semibold">{title}</CardTitle>
|
||||||
<CardDescription className="text-xs">{description}</CardDescription>
|
<CardDescription className="text-xs">{description}</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="pl-2 pr-4">
|
<CardContent>
|
||||||
<div className="h-[280px] w-full">
|
<TrendChart
|
||||||
<ChartContainer config={chartConfig} className="h-full w-full">
|
labels={points.map((point) => formatTrendHour(point.bucket_started_at))}
|
||||||
<AreaChart data={data} margin={{ top: 10, right: 10, left: 0, bottom: 0 }}>
|
yAxisValueFormatter={formatBytes}
|
||||||
<defs>
|
series={[
|
||||||
<linearGradient id="nodeDiskReadFill" x1="0" y1="0" x2="0" y2="1">
|
{
|
||||||
<stop offset="5%" stopColor="var(--color-diskRead)" stopOpacity={0.2} />
|
label: '磁盘读',
|
||||||
<stop offset="95%" stopColor="var(--color-diskRead)" stopOpacity={0.02} />
|
color: '#a78bfa',
|
||||||
</linearGradient>
|
fillColor: 'rgba(167, 139, 250, 0.14)',
|
||||||
</defs>
|
variant: 'area',
|
||||||
<CartesianGrid strokeDasharray="3 3" vertical={false} />
|
values: points.map((point) => point.disk_read_bytes),
|
||||||
<XAxis
|
valueFormatter: formatBytes,
|
||||||
dataKey="hour"
|
},
|
||||||
tickLine={false}
|
{
|
||||||
axisLine={false}
|
label: '磁盘写',
|
||||||
tickMargin={8}
|
color: '#fb7185',
|
||||||
minTickGap={24}
|
values: points.map((point) => point.disk_write_bytes),
|
||||||
/>
|
valueFormatter: formatBytes,
|
||||||
<YAxis
|
},
|
||||||
tickLine={false}
|
]}
|
||||||
axisLine={false}
|
/>
|
||||||
tickMargin={8}
|
|
||||||
tickFormatter={(value) => formatBytes(Number(value))}
|
|
||||||
/>
|
|
||||||
<ChartTooltip
|
|
||||||
cursor={false}
|
|
||||||
content={
|
|
||||||
<ChartTooltipContent
|
|
||||||
formatter={(value, name) => (
|
|
||||||
<span className="font-mono tabular-nums">
|
|
||||||
{formatBytes(Number(value))}
|
|
||||||
<span className="ml-1 text-muted-foreground">
|
|
||||||
{name === 'diskRead' ? '读' : '写'}
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Area
|
|
||||||
type="monotone"
|
|
||||||
dataKey="diskRead"
|
|
||||||
stroke="var(--color-diskRead)"
|
|
||||||
fill="url(#nodeDiskReadFill)"
|
|
||||||
strokeWidth={2}
|
|
||||||
/>
|
|
||||||
<Line
|
|
||||||
type="monotone"
|
|
||||||
dataKey="diskWrite"
|
|
||||||
stroke="var(--color-diskWrite)"
|
|
||||||
strokeWidth={2}
|
|
||||||
dot={false}
|
|
||||||
/>
|
|
||||||
<ChartLegend content={<ChartLegendContent />} />
|
|
||||||
</AreaChart>
|
|
||||||
</ChartContainer>
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,31 +1,19 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import {Area, AreaChart, CartesianGrid, Line, XAxis, YAxis} from 'recharts';
|
import {TrendChart} from '@/components/data/trend-chart';
|
||||||
|
|
||||||
import {Card, CardContent, CardDescription, CardHeader, CardTitle} from '@/components/ui/card';
|
|
||||||
import {
|
import {
|
||||||
ChartConfig,
|
Card,
|
||||||
ChartContainer,
|
CardContent,
|
||||||
ChartLegend,
|
CardDescription,
|
||||||
ChartLegendContent,
|
CardHeader,
|
||||||
ChartTooltip,
|
CardTitle,
|
||||||
ChartTooltipContent,
|
} from '@/components/ui/card';
|
||||||
} from '@/components/ui/chart';
|
|
||||||
import type {NetworkTrendPoint} from '@/lib/services/openflare';
|
import type {NetworkTrendPoint} from '@/lib/services/openflare';
|
||||||
|
|
||||||
import {formatTrendHour} from '../../components/dashboard/dashboard-utils';
|
import {
|
||||||
import {formatBytesPerSecond} from './node-utils';
|
formatBytesPerSecond,
|
||||||
|
formatTrendHour,
|
||||||
const chartConfig = {
|
} from '../../components/dashboard/dashboard-utils';
|
||||||
openrestyRx: {
|
|
||||||
label: 'OpenResty 入站',
|
|
||||||
color: 'hsl(var(--chart-2))',
|
|
||||||
},
|
|
||||||
openrestyTx: {
|
|
||||||
label: 'OpenResty 出站',
|
|
||||||
color: 'hsl(var(--chart-4))',
|
|
||||||
},
|
|
||||||
} satisfies ChartConfig;
|
|
||||||
|
|
||||||
export function NetworkTrendChart({
|
export function NetworkTrendChart({
|
||||||
points,
|
points,
|
||||||
@@ -36,91 +24,33 @@ export function NetworkTrendChart({
|
|||||||
title?: string;
|
title?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
}) {
|
}) {
|
||||||
const data = points.map((point) => ({
|
|
||||||
hour: formatTrendHour(point.bucket_started_at),
|
|
||||||
openrestyRx: point.openresty_rx_bytes,
|
|
||||||
openrestyTx: point.openresty_tx_bytes,
|
|
||||||
}));
|
|
||||||
|
|
||||||
if (data.length === 0) {
|
|
||||||
return (
|
|
||||||
<Card className="border-dashed shadow-none">
|
|
||||||
<CardHeader>
|
|
||||||
<CardTitle className="text-sm font-semibold">{title}</CardTitle>
|
|
||||||
<CardDescription className="text-xs">{description}</CardDescription>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent>
|
|
||||||
<div className="flex h-[280px] items-center justify-center text-xs text-muted-foreground">
|
|
||||||
暂无趋势数据
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className="border-dashed shadow-none">
|
<Card className="border-dashed shadow-none">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle className="text-sm font-semibold">{title}</CardTitle>
|
<CardTitle className="text-sm font-semibold">{title}</CardTitle>
|
||||||
<CardDescription className="text-xs">{description}</CardDescription>
|
<CardDescription className="text-xs">{description}</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="pl-2 pr-4">
|
<CardContent>
|
||||||
<div className="h-[280px] w-full">
|
<TrendChart
|
||||||
<ChartContainer config={chartConfig} className="h-full w-full">
|
labels={points.map((point) => formatTrendHour(point.bucket_started_at))}
|
||||||
<AreaChart data={data} margin={{ top: 10, right: 10, left: 0, bottom: 0 }}>
|
yAxisValueFormatter={(value) => formatBytesPerSecond(value, 3600)}
|
||||||
<defs>
|
series={[
|
||||||
<linearGradient id="nodeOpenrestyRxFill" x1="0" y1="0" x2="0" y2="1">
|
{
|
||||||
<stop offset="5%" stopColor="var(--color-openrestyRx)" stopOpacity={0.2} />
|
label: 'OpenResty 入站',
|
||||||
<stop offset="95%" stopColor="var(--color-openrestyRx)" stopOpacity={0.02} />
|
color: '#22c55e',
|
||||||
</linearGradient>
|
fillColor: 'rgba(34, 197, 94, 0.14)',
|
||||||
</defs>
|
variant: 'area',
|
||||||
<CartesianGrid strokeDasharray="3 3" vertical={false} />
|
values: points.map((point) => point.openresty_rx_bytes),
|
||||||
<XAxis
|
valueFormatter: (value) => formatBytesPerSecond(value, 3600),
|
||||||
dataKey="hour"
|
},
|
||||||
tickLine={false}
|
{
|
||||||
axisLine={false}
|
label: 'OpenResty 出站',
|
||||||
tickMargin={8}
|
color: '#38bdf8',
|
||||||
minTickGap={24}
|
values: points.map((point) => point.openresty_tx_bytes),
|
||||||
/>
|
valueFormatter: (value) => formatBytesPerSecond(value, 3600),
|
||||||
<YAxis
|
},
|
||||||
tickLine={false}
|
]}
|
||||||
axisLine={false}
|
/>
|
||||||
tickMargin={8}
|
|
||||||
tickFormatter={(value) => formatBytesPerSecond(Number(value), 3600)}
|
|
||||||
/>
|
|
||||||
<ChartTooltip
|
|
||||||
cursor={false}
|
|
||||||
content={
|
|
||||||
<ChartTooltipContent
|
|
||||||
formatter={(value, name) => (
|
|
||||||
<span className="font-mono tabular-nums">
|
|
||||||
{formatBytesPerSecond(Number(value), 3600)}
|
|
||||||
<span className="ml-1 text-muted-foreground">
|
|
||||||
{name === 'openrestyRx' ? '入站' : '出站'}
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Area
|
|
||||||
type="monotone"
|
|
||||||
dataKey="openrestyRx"
|
|
||||||
stroke="var(--color-openrestyRx)"
|
|
||||||
fill="url(#nodeOpenrestyRxFill)"
|
|
||||||
strokeWidth={2}
|
|
||||||
/>
|
|
||||||
<Line
|
|
||||||
type="monotone"
|
|
||||||
dataKey="openrestyTx"
|
|
||||||
stroke="var(--color-openrestyTx)"
|
|
||||||
strokeWidth={2}
|
|
||||||
dot={false}
|
|
||||||
/>
|
|
||||||
<ChartLegend content={<ChartLegendContent />} />
|
|
||||||
</AreaChart>
|
|
||||||
</ChartContainer>
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ sidebar: false
|
|||||||
- 修复开发模式下 `/api/*` 尾斜杠引发 Next.js 308 与 Gin 301 循环重定向:前端 Service 与 `api-client` 请求拦截器规范化路径、强制浏览器同源代理、Next `skipTrailingSlashRedirect`、后端 `RegisterCollection` 双路径注册;Access Token 管理员权限校验对齐 `token_admin`。
|
- 修复开发模式下 `/api/*` 尾斜杠引发 Next.js 308 与 Gin 301 循环重定向:前端 Service 与 `api-client` 请求拦截器规范化路径、强制浏览器同源代理、Next `skipTrailingSlashRedirect`、后端 `RegisterCollection` 双路径注册;Access Token 管理员权限校验对齐 `token_admin`。
|
||||||
- 补全 Wavelet 边缘节点详情数据看板:迁移运行诊断摘要、系统信息、实时资源、网络流量、24 小时请求/容量/网络/磁盘趋势、请求结构分布与健康事件时间线。
|
- 补全 Wavelet 边缘节点详情数据看板:迁移运行诊断摘要、系统信息、实时资源、网络流量、24 小时请求/容量/网络/磁盘趋势、请求结构分布与健康事件时间线。
|
||||||
- 节点详情页改为 Tabs 布局(概览 / 数据看板 / 配置与部署),统一 Edge/Relay/Tunnel 详情壳层并支持 `tab` URL 参数深链。
|
- 节点详情页改为 Tabs 布局(概览 / 数据看板 / 配置与部署),统一 Edge/Relay/Tunnel 详情壳层并支持 `tab` URL 参数深链。
|
||||||
|
- 节点详情 24 小时网络/磁盘 IO 趋势图对齐原版 ECharts 样式,恢复系列摘要卡与平滑面积折线图。
|
||||||
- OpenFlare 前端路由去除 `/openflare` 前缀,业务页面直接挂载于 `/`(如 `/nodes`、`/websites`);侧栏移除「首页」「我的文件」;旧路径 `/openflare/*`、`/home` 永久重定向至新路径。
|
- OpenFlare 前端路由去除 `/openflare` 前缀,业务页面直接挂载于 `/`(如 `/nodes`、`/websites`);侧栏移除「首页」「我的文件」;旧路径 `/openflare/*`、`/home` 永久重定向至新路径。
|
||||||
|
|
||||||
## [v2.3.4] - 2026-06-17
|
## [v2.3.4] - 2026-06-17
|
||||||
|
|||||||
Reference in New Issue
Block a user