mirror of
https://github.com/Buriburizaem0n/nezha-dash-v1.git
synced 2026-02-04 20:50:08 +00:00
fix: rename model
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user