mirror of
https://github.com/woodchen-ink/nezha-dash-v1.git
synced 2025-07-18 09:31:55 +08:00
fix: rename model
This commit is contained in:
parent
ee9419cccc
commit
5f2e9fe38a
@ -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",
|
||||
|
@ -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 } =
|
||||
|
@ -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[],
|
||||
);
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
@ -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,
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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"}
|
Loading…
x
Reference in New Issue
Block a user