fix: rename model

This commit is contained in:
hamster1963 2024-11-28 14:49:38 +08:00
parent ee9419cccc
commit 5f2e9fe38a
10 changed files with 28 additions and 107 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -19,14 +19,14 @@
"@radix-ui/react-progress": "^1.1.0", "@radix-ui/react-progress": "^1.1.0",
"@radix-ui/react-separator": "^1.1.0", "@radix-ui/react-separator": "^1.1.0",
"@radix-ui/react-slot": "^1.1.0", "@radix-ui/react-slot": "^1.1.0",
"@tanstack/react-query": "^5.61.4", "@tanstack/react-query": "^5.61.5",
"@tanstack/react-query-devtools": "^5.61.4", "@tanstack/react-query-devtools": "^5.61.5",
"@tanstack/react-table": "^8.20.5", "@tanstack/react-table": "^8.20.5",
"@types/luxon": "^3.4.2", "@types/luxon": "^3.4.2",
"class-variance-authority": "^0.7.1", "class-variance-authority": "^0.7.1",
"clsx": "^2.1.1", "clsx": "^2.1.1",
"country-flag-icons": "^1.5.13", "country-flag-icons": "^1.5.13",
"framer-motion": "^11.11.17", "framer-motion": "^11.12.0",
"i18next": "^24.0.2", "i18next": "^24.0.2",
"lucide-react": "^0.460.0", "lucide-react": "^0.460.0",
"luxon": "^3.5.0", "luxon": "^3.5.0",
@ -42,7 +42,7 @@
}, },
"devDependencies": { "devDependencies": {
"@eslint/js": "^9.15.0", "@eslint/js": "^9.15.0",
"@types/node": "^22.10.0", "@types/node": "^22.10.1",
"@types/react": "^18.3.12", "@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1", "@types/react-dom": "^18.3.1",
"@vitejs/plugin-react-swc": "^3.7.2", "@vitejs/plugin-react-swc": "^3.7.2",

View File

@ -2,12 +2,12 @@ import ServerFlag from "@/components/ServerFlag";
import ServerUsageBar from "@/components/ServerUsageBar"; import ServerUsageBar from "@/components/ServerUsageBar";
import { cn, formatNezhaInfo } from "@/lib/utils"; import { cn, formatNezhaInfo } from "@/lib/utils";
import { NezhaAPI } from "@/types/nezha-api"; import { NezhaServer } from "@/types/nezha-api";
import { Card } from "./ui/card"; import { Card } from "./ui/card";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
export default function ServerCard({ serverInfo }: { serverInfo: NezhaAPI }) { export default function ServerCard({ serverInfo }: { serverInfo: NezhaServer }) {
const { t } = useTranslation(); const { t } = useTranslation();
const navigate = useNavigate(); const navigate = useNavigate();
const { name, country_code, online, cpu, up, down, mem, stg } = const { name, country_code, online, cpu, up, down, mem, stg } =

View File

@ -1,7 +1,7 @@
import { Card, CardContent } from "@/components/ui/card"; import { Card, CardContent } from "@/components/ui/card";
import { ChartConfig, ChartContainer } from "@/components/ui/chart"; import { ChartConfig, ChartContainer } from "@/components/ui/chart";
import { formatNezhaInfo, formatRelativeTime } from "@/lib/utils"; 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 { useEffect, useState } from "react";
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
import { import {
@ -60,7 +60,7 @@ export default function ServerDetailChart() {
} }
const nezhaWsData = lastMessage const nezhaWsData = lastMessage
? (JSON.parse(lastMessage.data) as NezhaAPIResponse) ? (JSON.parse(lastMessage.data) as NezhaWebsocketResponse)
: null; : null;
if (!nezhaWsData) { 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 [cpuChartData, setCpuChartData] = useState([] as cpuChartData[]);
const { cpu } = formatNezhaInfo(data); 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 { t } = useTranslation();
const [processChartData, setProcessChartData] = useState( const [processChartData, setProcessChartData] = useState(
[] as processChartData[], [] 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 { t } = useTranslation();
const [memChartData, setMemChartData] = useState([] as memChartData[]); 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 { t } = useTranslation();
const [diskChartData, setDiskChartData] = useState([] as diskChartData[]); 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 { t } = useTranslation();
const [networkChartData, setNetworkChartData] = useState( const [networkChartData, setNetworkChartData] = useState(
[] as networkChartData[], [] 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( const [connectChartData, setConnectChartData] = useState(
[] as connectChartData[], [] as connectChartData[],
); );

View File

@ -5,7 +5,7 @@ import { Badge } from "@/components/ui/badge";
import { Card, CardContent } from "@/components/ui/card"; import { Card, CardContent } from "@/components/ui/card";
import { useWebSocketContext } from "@/hooks/use-websocket-context"; import { useWebSocketContext } from "@/hooks/use-websocket-context";
import { cn, formatBytes, formatNezhaInfo } from "@/lib/utils"; 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 { useNavigate, useParams } from "react-router-dom";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
@ -20,7 +20,7 @@ export default function ServerDetailOverview() {
} }
const nezhaWsData = lastMessage const nezhaWsData = lastMessage
? (JSON.parse(lastMessage.data) as NezhaAPIResponse) ? (JSON.parse(lastMessage.data) as NezhaWebsocketResponse)
: null; : null;
if (!nezhaWsData) { if (!nezhaWsData) {

View File

@ -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;
}

View File

@ -1,4 +1,4 @@
import { NezhaAPI } from "@/types/nezha-api"; import { NezhaServer } from "@/types/nezha-api";
import { type ClassValue, clsx } from "clsx"; import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge"; import { twMerge } from "tailwind-merge";
@ -6,7 +6,7 @@ export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs)); return twMerge(clsx(inputs));
} }
export function formatNezhaInfo(serverInfo: NezhaAPI) { export function formatNezhaInfo(serverInfo: NezhaServer) {
const lastActiveTime = parseISOTimestamp(serverInfo.last_active); const lastActiveTime = parseISOTimestamp(serverInfo.last_active);
return { return {
...serverInfo, ...serverInfo,

View File

@ -1,4 +1,4 @@
import { NezhaAPIResponse } from "@/types/nezha-api"; import { NezhaWebsocketResponse } from "@/types/nezha-api";
import ServerCard from "@/components/ServerCard"; import ServerCard from "@/components/ServerCard";
import { formatNezhaInfo } from "@/lib/utils"; import { formatNezhaInfo } from "@/lib/utils";
import ServerOverview from "@/components/ServerOverview"; import ServerOverview from "@/components/ServerOverview";
@ -41,7 +41,7 @@ export default function Servers() {
} }
const nezhaWsData = lastMessage const nezhaWsData = lastMessage
? (JSON.parse(lastMessage.data) as NezhaAPIResponse) ? (JSON.parse(lastMessage.data) as NezhaWebsocketResponse)
: null; : null;
if (!nezhaWsData) { if (!nezhaWsData) {

View File

@ -1,18 +1,18 @@
export interface NezhaAPIResponse { export interface NezhaWebsocketResponse {
now: number; now: number;
servers: NezhaAPI[]; servers: NezhaServer[];
} }
export interface NezhaAPI { export interface NezhaServer {
id: number; id: number;
name: string; name: string;
last_active: string; last_active: string;
country_code: string; country_code: string;
host: NezhaAPIHost; host: NezhaServerHost;
state: NezhaAPIStatus; state: NezhaServerStatus;
} }
export interface NezhaAPIHost { export interface NezhaServerHost {
platform: string; platform: string;
platform_version: string; platform_version: string;
cpu: string[]; cpu: string[];
@ -25,7 +25,7 @@ export interface NezhaAPIHost {
version: string; version: string;
} }
export interface NezhaAPIStatus { export interface NezhaServerStatus {
cpu: number; cpu: number;
mem_used: number; mem_used: number;
swap_used: number; swap_used: number;

View File

@ -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"} {"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"}