mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
Compare commits
No commits in common. "084f71e4a6a425c201ba5334dd55d82f7d7783ed" and "23a32612510b390b52f60240a6a811bd27e091cf" have entirely different histories.
084f71e4a6
...
23a3261251
@ -15,6 +15,7 @@ import { Label } from "@/components/ui/label"
|
|||||||
import { Switch } from "@/components/ui/switch"
|
import { Switch } from "@/components/ui/switch"
|
||||||
import getEnv from "@/lib/env-entry"
|
import getEnv from "@/lib/env-entry"
|
||||||
import { formatTime, nezhaFetcher } from "@/lib/utils"
|
import { formatTime, nezhaFetcher } from "@/lib/utils"
|
||||||
|
import { formatRelativeTime } from "@/lib/utils"
|
||||||
import { useTranslations } from "next-intl"
|
import { useTranslations } from "next-intl"
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import { useCallback, useMemo } from "react"
|
import { useCallback, useMemo } from "react"
|
||||||
@ -284,22 +285,12 @@ export const NetworkChart = React.memo(function NetworkChart({
|
|||||||
<CartesianGrid vertical={false} />
|
<CartesianGrid vertical={false} />
|
||||||
<XAxis
|
<XAxis
|
||||||
dataKey="created_at"
|
dataKey="created_at"
|
||||||
tickLine={true}
|
tickLine={false}
|
||||||
tickSize={3}
|
|
||||||
axisLine={false}
|
axisLine={false}
|
||||||
tickMargin={8}
|
tickMargin={8}
|
||||||
minTickGap={80}
|
minTickGap={32}
|
||||||
interval={0}
|
interval={"preserveStartEnd"}
|
||||||
ticks={processedData
|
tickFormatter={(value) => formatRelativeTime(value)}
|
||||||
.filter((item) => {
|
|
||||||
const date = new Date(item.created_at)
|
|
||||||
return date.getMinutes() === 0 && date.getHours() % 3 === 0
|
|
||||||
})
|
|
||||||
.map((item) => item.created_at)}
|
|
||||||
tickFormatter={(value) => {
|
|
||||||
const date = new Date(value)
|
|
||||||
return `${date.getHours()}:00`
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<YAxis
|
<YAxis
|
||||||
tickLine={false}
|
tickLine={false}
|
||||||
|
@ -164,7 +164,7 @@ const ChartTooltipContent = React.forwardRef<
|
|||||||
<div
|
<div
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn(
|
className={cn(
|
||||||
"grid min-w-[8rem] items-start overflow-hidden gap-1.5 rounded-sm border border-border/50 bg-stone-100 dark:bg-stone-900 text-xs",
|
"grid min-w-[8rem] items-start overflow-hidden gap-1.5 rounded-sm border border-border/50 bg-stone-100 dark:bg-stone-900 text-xs shadow-xl",
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
@ -233,14 +233,13 @@ const ChartTooltipContent = React.forwardRef<
|
|||||||
{item.value && (
|
{item.value && (
|
||||||
<span
|
<span
|
||||||
className={cn(
|
className={cn(
|
||||||
"ml-2 font-medium tabular-nums text-foreground",
|
"ml-2 font-mono font-medium tabular-nums text-foreground",
|
||||||
payload.length === 1 && "-ml-9",
|
payload.length === 1 && "-ml-9",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{typeof item.value === "number"
|
{typeof item.value === "number"
|
||||||
? item.value.toFixed(2).toLocaleString()
|
? item.value.toFixed(3).toLocaleString()
|
||||||
: item.value}{" "}
|
: item.value}
|
||||||
ms
|
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
10
lib/utils.ts
10
lib/utils.ts
@ -125,13 +125,3 @@ export function formatTime(timestamp: number): string {
|
|||||||
const seconds = date.getSeconds().toString().padStart(2, "0")
|
const seconds = date.getSeconds().toString().padStart(2, "0")
|
||||||
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatTime12(timestamp: number): string {
|
|
||||||
// example: 3:45 PM
|
|
||||||
const date = new Date(timestamp)
|
|
||||||
const hours = date.getHours()
|
|
||||||
const minutes = date.getMinutes()
|
|
||||||
const ampm = hours >= 12 ? "PM" : "AM"
|
|
||||||
const hours12 = hours % 12 || 12
|
|
||||||
return `${hours12}:${minutes.toString().padStart(2, "0")} ${ampm}`
|
|
||||||
}
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nezha-dash",
|
"name": "nezha-dash",
|
||||||
"version": "2.7.2",
|
"version": "2.7.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev -p 3040",
|
"dev": "next dev -p 3040",
|
||||||
@ -64,7 +64,7 @@
|
|||||||
"@biomejs/biome": "1.9.4",
|
"@biomejs/biome": "1.9.4",
|
||||||
"@next/bundle-analyzer": "^15.1.7",
|
"@next/bundle-analyzer": "^15.1.7",
|
||||||
"@tailwindcss/postcss": "^4.0.6",
|
"@tailwindcss/postcss": "^4.0.6",
|
||||||
"@types/node": "^22.13.4",
|
"@types/node": "^22.13.1",
|
||||||
"@types/react": "^19.0.8",
|
"@types/react": "^19.0.8",
|
||||||
"@types/react-dom": "^19.0.3",
|
"@types/react-dom": "^19.0.3",
|
||||||
"postcss": "^8.5.2",
|
"postcss": "^8.5.2",
|
||||||
|
Loading…
Reference in New Issue
Block a user