diff --git a/bun.lockb b/bun.lockb index 700decd..f4c650c 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index c0c9ace..3e2a241 100644 --- a/package.json +++ b/package.json @@ -19,14 +19,14 @@ "@radix-ui/react-progress": "^1.1.0", "@radix-ui/react-separator": "^1.1.0", "@radix-ui/react-slot": "^1.1.0", - "@tanstack/react-query": "^5.61.4", - "@tanstack/react-query-devtools": "^5.61.4", + "@tanstack/react-query": "^5.61.5", + "@tanstack/react-query-devtools": "^5.61.5", "@tanstack/react-table": "^8.20.5", "@types/luxon": "^3.4.2", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "country-flag-icons": "^1.5.13", - "framer-motion": "^11.11.17", + "framer-motion": "^11.12.0", "i18next": "^24.0.2", "lucide-react": "^0.460.0", "luxon": "^3.5.0", @@ -42,7 +42,7 @@ }, "devDependencies": { "@eslint/js": "^9.15.0", - "@types/node": "^22.10.0", + "@types/node": "^22.10.1", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", "@vitejs/plugin-react-swc": "^3.7.2", diff --git a/src/components/ServerCard.tsx b/src/components/ServerCard.tsx index e10571b..dabc0c6 100644 --- a/src/components/ServerCard.tsx +++ b/src/components/ServerCard.tsx @@ -2,12 +2,12 @@ import ServerFlag from "@/components/ServerFlag"; import ServerUsageBar from "@/components/ServerUsageBar"; import { cn, formatNezhaInfo } from "@/lib/utils"; -import { NezhaAPI } from "@/types/nezha-api"; +import { NezhaServer } from "@/types/nezha-api"; import { Card } from "./ui/card"; import { useNavigate } from "react-router-dom"; import { useTranslation } from "react-i18next"; -export default function ServerCard({ serverInfo }: { serverInfo: NezhaAPI }) { +export default function ServerCard({ serverInfo }: { serverInfo: NezhaServer }) { const { t } = useTranslation(); const navigate = useNavigate(); const { name, country_code, online, cpu, up, down, mem, stg } = diff --git a/src/components/ServerDetailChart.tsx b/src/components/ServerDetailChart.tsx index 46311bb..174eb4e 100644 --- a/src/components/ServerDetailChart.tsx +++ b/src/components/ServerDetailChart.tsx @@ -1,7 +1,7 @@ import { Card, CardContent } from "@/components/ui/card"; import { ChartConfig, ChartContainer } from "@/components/ui/chart"; import { formatNezhaInfo, formatRelativeTime } from "@/lib/utils"; -import { NezhaAPI, NezhaAPIResponse } from "@/types/nezha-api"; +import { NezhaServer, NezhaWebsocketResponse } from "@/types/nezha-api"; import { useEffect, useState } from "react"; import { useParams } from "react-router-dom"; import { @@ -60,7 +60,7 @@ export default function ServerDetailChart() { } const nezhaWsData = lastMessage - ? (JSON.parse(lastMessage.data) as NezhaAPIResponse) + ? (JSON.parse(lastMessage.data) as NezhaWebsocketResponse) : null; if (!nezhaWsData) { @@ -85,7 +85,7 @@ export default function ServerDetailChart() { ); } -function CpuChart({ data }: { data: NezhaAPI }) { +function CpuChart({ data }: { data: NezhaServer }) { const [cpuChartData, setCpuChartData] = useState([] as cpuChartData[]); const { cpu } = formatNezhaInfo(data); @@ -181,7 +181,7 @@ function CpuChart({ data }: { data: NezhaAPI }) { ); } -function ProcessChart({ data }: { data: NezhaAPI }) { +function ProcessChart({ data }: { data: NezhaServer }) { const { t } = useTranslation(); const [processChartData, setProcessChartData] = useState( [] as processChartData[], @@ -274,7 +274,7 @@ function ProcessChart({ data }: { data: NezhaAPI }) { ); } -function MemChart({ data }: { data: NezhaAPI }) { +function MemChart({ data }: { data: NezhaServer }) { const { t } = useTranslation(); const [memChartData, setMemChartData] = useState([] as memChartData[]); @@ -404,7 +404,7 @@ function MemChart({ data }: { data: NezhaAPI }) { ); } -function DiskChart({ data }: { data: NezhaAPI }) { +function DiskChart({ data }: { data: NezhaServer }) { const { t } = useTranslation(); const [diskChartData, setDiskChartData] = useState([] as diskChartData[]); @@ -501,7 +501,7 @@ function DiskChart({ data }: { data: NezhaAPI }) { ); } -function NetworkChart({ data }: { data: NezhaAPI }) { +function NetworkChart({ data }: { data: NezhaServer }) { const { t } = useTranslation(); const [networkChartData, setNetworkChartData] = useState( [] as networkChartData[], @@ -630,7 +630,7 @@ function NetworkChart({ data }: { data: NezhaAPI }) { ); } -function ConnectChart({ data }: { data: NezhaAPI }) { +function ConnectChart({ data }: { data: NezhaServer }) { const [connectChartData, setConnectChartData] = useState( [] as connectChartData[], ); diff --git a/src/components/ServerDetailOverview.tsx b/src/components/ServerDetailOverview.tsx index fd8ceb3..34c4034 100644 --- a/src/components/ServerDetailOverview.tsx +++ b/src/components/ServerDetailOverview.tsx @@ -5,7 +5,7 @@ import { Badge } from "@/components/ui/badge"; import { Card, CardContent } from "@/components/ui/card"; import { useWebSocketContext } from "@/hooks/use-websocket-context"; import { cn, formatBytes, formatNezhaInfo } from "@/lib/utils"; -import { NezhaAPIResponse } from "@/types/nezha-api"; +import { NezhaWebsocketResponse } from "@/types/nezha-api"; import { useNavigate, useParams } from "react-router-dom"; import { useTranslation } from "react-i18next"; @@ -20,7 +20,7 @@ export default function ServerDetailOverview() { } const nezhaWsData = lastMessage - ? (JSON.parse(lastMessage.data) as NezhaAPIResponse) + ? (JSON.parse(lastMessage.data) as NezhaWebsocketResponse) : null; if (!nezhaWsData) { diff --git a/src/lib/nezha-model.ts b/src/lib/nezha-model.ts deleted file mode 100644 index 9e049c5..0000000 --- a/src/lib/nezha-model.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * model.Server - */ -export interface ModelServer { - created_at: string; - /** - * DDNS配置 - */ - ddns_profiles: number[]; - deleted_at: string; - /** - * 展示排序,越大越靠前 - */ - display_index: number; - /** - * 启用DDNS - */ - enable_ddns: boolean; - /** - * 对游客隐藏 - */ - hide_for_guest?: boolean; - host?: ModelHost; - id: number; - last_active?: string; - name: string; - /** - * 管理员可见备注 - */ - note: string; - /** - * 公开备注 - */ - public_note: string; - state: ModelHostState; - updated_at: string; - uuid: string; -} - -export interface ModelHost { - arch?: string; - boot_time?: number; - country_code?: string; - cpu?: string[]; - disk_total?: number; - gpu?: string[]; - ip?: string; - mem_total?: number; - platform?: string; - platform_version?: string; - swap_total?: number; - version?: string; - virtualization?: string; -} - -export interface ModelHostState { - cpu?: number; - disk_used?: number; - gpu?: number[]; - load_1?: number; - load_15?: number; - load_5?: number; - mem_used?: number; - net_in_speed?: number; - net_in_transfer?: number; - net_out_speed?: number; - net_out_transfer?: number; - process_count?: number; - swap_used?: number; - tcp_conn_count?: number; - temperatures?: ModelSensorTemperature[]; - udp_conn_count?: number; - uptime?: number; -} - -export interface ModelSensorTemperature { - name?: string; - temperature?: number; -} diff --git a/src/lib/utils.ts b/src/lib/utils.ts index ab11cfc..1de7a9f 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,4 +1,4 @@ -import { NezhaAPI } from "@/types/nezha-api"; +import { NezhaServer } from "@/types/nezha-api"; import { type ClassValue, clsx } from "clsx"; import { twMerge } from "tailwind-merge"; @@ -6,7 +6,7 @@ export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } -export function formatNezhaInfo(serverInfo: NezhaAPI) { +export function formatNezhaInfo(serverInfo: NezhaServer) { const lastActiveTime = parseISOTimestamp(serverInfo.last_active); return { ...serverInfo, diff --git a/src/pages/Server.tsx b/src/pages/Server.tsx index 194a663..fb1dc14 100644 --- a/src/pages/Server.tsx +++ b/src/pages/Server.tsx @@ -1,4 +1,4 @@ -import { NezhaAPIResponse } from "@/types/nezha-api"; +import { NezhaWebsocketResponse } from "@/types/nezha-api"; import ServerCard from "@/components/ServerCard"; import { formatNezhaInfo } from "@/lib/utils"; import ServerOverview from "@/components/ServerOverview"; @@ -41,7 +41,7 @@ export default function Servers() { } const nezhaWsData = lastMessage - ? (JSON.parse(lastMessage.data) as NezhaAPIResponse) + ? (JSON.parse(lastMessage.data) as NezhaWebsocketResponse) : null; if (!nezhaWsData) { diff --git a/src/types/nezha-api.ts b/src/types/nezha-api.ts index 9699bbc..b3b5ed8 100644 --- a/src/types/nezha-api.ts +++ b/src/types/nezha-api.ts @@ -1,18 +1,18 @@ -export interface NezhaAPIResponse { +export interface NezhaWebsocketResponse { now: number; - servers: NezhaAPI[]; + servers: NezhaServer[]; } -export interface NezhaAPI { +export interface NezhaServer { id: number; name: string; last_active: string; country_code: string; - host: NezhaAPIHost; - state: NezhaAPIStatus; + host: NezhaServerHost; + state: NezhaServerStatus; } -export interface NezhaAPIHost { +export interface NezhaServerHost { platform: string; platform_version: string; cpu: string[]; @@ -25,7 +25,7 @@ export interface NezhaAPIHost { version: string; } -export interface NezhaAPIStatus { +export interface NezhaServerStatus { cpu: number; mem_used: number; swap_used: number; diff --git a/tsconfig.app.tsbuildinfo b/tsconfig.app.tsbuildinfo index 9937362..fcc3e2f 100644 --- a/tsconfig.app.tsbuildinfo +++ b/tsconfig.app.tsbuildinfo @@ -1 +1 @@ -{"root":["./src/app.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/components/footer.tsx","./src/components/groupswitch.tsx","./src/components/header.tsx","./src/components/icon.tsx","./src/components/languageswitcher.tsx","./src/components/servercard.tsx","./src/components/serverdetailchart.tsx","./src/components/serverdetailoverview.tsx","./src/components/serverflag.tsx","./src/components/serveroverview.tsx","./src/components/serverusagebar.tsx","./src/components/themeprovider.tsx","./src/components/themeswitcher.tsx","./src/components/loading/loader.tsx","./src/components/loading/serverdetailloading.tsx","./src/components/motion/framer-lazy-feature.ts","./src/components/motion/motion-provider.tsx","./src/components/ui/animated-circular-progress-bar.tsx","./src/components/ui/badge.tsx","./src/components/ui/button.tsx","./src/components/ui/card.tsx","./src/components/ui/chart.tsx","./src/components/ui/checkbox.tsx","./src/components/ui/dialog.tsx","./src/components/ui/dropdown-menu.tsx","./src/components/ui/input.tsx","./src/components/ui/label.tsx","./src/components/ui/progress.tsx","./src/components/ui/separator.tsx","./src/components/ui/skeleton.tsx","./src/components/ui/table.tsx","./src/context/websocket-context.ts","./src/context/websocket-provider.tsx","./src/hooks/use-theme.ts","./src/hooks/use-websocket-context.ts","./src/lib/logo-class.tsx","./src/lib/nav-router.ts","./src/lib/nezha-api.ts","./src/lib/nezha-model.ts","./src/lib/utils.ts","./src/pages/notfound.tsx","./src/pages/server.tsx","./src/pages/serverdetail.tsx","./src/types/nezha-api.ts"],"version":"5.6.3"} \ No newline at end of file +{"root":["./src/app.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/components/footer.tsx","./src/components/groupswitch.tsx","./src/components/header.tsx","./src/components/icon.tsx","./src/components/languageswitcher.tsx","./src/components/servercard.tsx","./src/components/serverdetailchart.tsx","./src/components/serverdetailoverview.tsx","./src/components/serverflag.tsx","./src/components/serveroverview.tsx","./src/components/serverusagebar.tsx","./src/components/themeprovider.tsx","./src/components/themeswitcher.tsx","./src/components/loading/loader.tsx","./src/components/loading/serverdetailloading.tsx","./src/components/motion/framer-lazy-feature.ts","./src/components/motion/motion-provider.tsx","./src/components/ui/animated-circular-progress-bar.tsx","./src/components/ui/badge.tsx","./src/components/ui/button.tsx","./src/components/ui/card.tsx","./src/components/ui/chart.tsx","./src/components/ui/checkbox.tsx","./src/components/ui/dialog.tsx","./src/components/ui/dropdown-menu.tsx","./src/components/ui/input.tsx","./src/components/ui/label.tsx","./src/components/ui/progress.tsx","./src/components/ui/separator.tsx","./src/components/ui/skeleton.tsx","./src/components/ui/table.tsx","./src/context/websocket-context.ts","./src/context/websocket-provider.tsx","./src/hooks/use-theme.ts","./src/hooks/use-websocket-context.ts","./src/lib/logo-class.tsx","./src/lib/nav-router.ts","./src/lib/nezha-api.ts","./src/lib/utils.ts","./src/pages/notfound.tsx","./src/pages/server.tsx","./src/pages/serverdetail.tsx","./src/types/nezha-api.ts"],"version":"5.6.3"} \ No newline at end of file