From af558eb661987862a5ec97c8413d91c10a36cc5f Mon Sep 17 00:00:00 2001 From: stqfdyr <89149493+stqfdyr@users.noreply.github.com> Date: Tue, 29 Sep 2026 14:17:50 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E8=B5=84=E6=BA=90=E5=9B=BE?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E9=97=B4=E8=8C=83=E5=9B=B4=E6=8C=89=20hub=20?= =?UTF-8?q?=E7=9A=84=E4=BF=9D=E7=95=99=E5=A4=A9=E6=95=B0=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 档位取保留期以内的 1、6 小时和 1、7、30、90 天,再加上保留期本身;hub 没有 history_days 时按 7 天 - 刻度间距增加 14 天一档,更宽的窗口落在每月 1 日;刻度全在零点时只写日期 - 手机上档位按钮收窄,保留一年的 7 个档位在 360 宽的屏幕上排成一行 --- src/App.tsx | 6 ++-- src/components/NodeDetail.tsx | 31 ++++++++++--------- src/lib/format.test.ts | 27 ++++++++++++++++- src/lib/format.ts | 56 +++++++++++++++++++++++++++++++++-- 4 files changed, 98 insertions(+), 22 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 5572bc9..a77d841 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -8,7 +8,9 @@ import { Skeleton } from "@/components/ui/skeleton" import { api, useNodes } from "@/lib/api" import { Link, useNodeRoute } from "@/lib/route" -type Me = { authed: boolean; github: boolean; site_name: string; public_page: boolean } +// `history_days` is absent from hubs predating the hourly tier, which kept a +// week for anonymous callers. +type Me = { authed: boolean; github: boolean; site_name: string; public_page: boolean; history_days?: number } // Split out because recharts is most of the bundle and the list draws no chart. // Warmed as soon as the app starts, so the first chart opened does not wait on it. @@ -187,7 +189,7 @@ export default function App() {
}> - +
diff --git a/src/components/NodeDetail.tsx b/src/components/NodeDetail.tsx index 5758c75..0ca28a0 100644 --- a/src/components/NodeDetail.tsx +++ b/src/components/NodeDetail.tsx @@ -8,7 +8,7 @@ import { Skeleton } from "@/components/ui/skeleton" import { deployed, Dot, Flag } from "@/components/ServerTable" import { api, type Node } from "@/lib/api" import { - axisBytes, axisTop, bytes, clockFor, despike, quarters, rate, timeTicks, uptime, + axisBytes, axisTop, bytes, clockFor, despike, quarters, rate, tickClock, timeTicks, uptime, windows, } from "@/lib/format" import { cn } from "@/lib/utils" @@ -46,13 +46,6 @@ type Probes = Record */ type Loss = Record -const RANGES = [ - { hours: 1, label: "1 小时" }, - { hours: 6, label: "6 小时" }, - { hours: 24, label: "24 小时" }, - { hours: 168, label: "7 天" }, -] - // The expanded row's latency window: a day, the widest in which every ping // remains on the chart. const LATENCY_HOURS = 24 @@ -93,11 +86,13 @@ function Panel({ title, children }: { title: React.ReactNode; children: React.Re ) } +// Tighter on a phone, so the seven windows of a year of history fit one row of +// a 360px screen. function Tab({ active, onClick, children }: { active: boolean; onClick: () => void; children: string }) { return (