mirror of
https://github.com/woodchen-ink/nezha-dash-v1.git
synced 2025-07-18 17:41:56 +08:00
feat: gpu info
This commit is contained in:
parent
a4bdf10c72
commit
3d4bd79ad5
@ -111,28 +111,27 @@ export const NetworkChartClient = React.memo(function NetworkChart({
|
|||||||
|
|
||||||
const defaultChart = "All";
|
const defaultChart = "All";
|
||||||
|
|
||||||
const [activeCharts, setActiveCharts] = React.useState<string[]>([defaultChart]);
|
const [activeCharts, setActiveCharts] = React.useState<string[]>([
|
||||||
|
defaultChart,
|
||||||
|
]);
|
||||||
|
|
||||||
const handleButtonClick = useCallback(
|
const handleButtonClick = useCallback((chart: string) => {
|
||||||
(chart: string) => {
|
|
||||||
setActiveCharts((prev) => {
|
setActiveCharts((prev) => {
|
||||||
if (chart === defaultChart) {
|
if (chart === defaultChart) {
|
||||||
return [defaultChart];
|
return [defaultChart];
|
||||||
}
|
}
|
||||||
|
|
||||||
const newCharts = prev.filter(c => c !== defaultChart);
|
const newCharts = prev.filter((c) => c !== defaultChart);
|
||||||
const chartIndex = newCharts.indexOf(chart);
|
const chartIndex = newCharts.indexOf(chart);
|
||||||
|
|
||||||
if (chartIndex === -1) {
|
if (chartIndex === -1) {
|
||||||
return newCharts.length === 0 ? [chart] : [...newCharts, chart];
|
return newCharts.length === 0 ? [chart] : [...newCharts, chart];
|
||||||
} else {
|
} else {
|
||||||
const result = newCharts.filter(c => c !== chart);
|
const result = newCharts.filter((c) => c !== chart);
|
||||||
return result.length === 0 ? [defaultChart] : result;
|
return result.length === 0 ? [defaultChart] : result;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
}, []);
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
const getColorByIndex = useCallback(
|
const getColorByIndex = useCallback(
|
||||||
(chart: string) => {
|
(chart: string) => {
|
||||||
|
@ -179,8 +179,20 @@ export default function ServerDetailOverview({
|
|||||||
<CardContent className="px-1.5 py-1">
|
<CardContent className="px-1.5 py-1">
|
||||||
<section className="flex flex-col items-start gap-0.5">
|
<section className="flex flex-col items-start gap-0.5">
|
||||||
<p className="text-xs text-muted-foreground">{"CPU"}</p>
|
<p className="text-xs text-muted-foreground">{"CPU"}</p>
|
||||||
{server.host.cpu ? (
|
{server.host.cpu.length > 0 ? (
|
||||||
<div className="text-xs"> {server.host.cpu}</div>
|
<div className="text-xs"> {server.host.cpu.join(", ")}</div>
|
||||||
|
) : (
|
||||||
|
<div className="text-xs"> {t("serverDetail.unknown")}</div>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
<Card className="rounded-[10px] bg-transparent border-none shadow-none">
|
||||||
|
<CardContent className="px-1.5 py-1">
|
||||||
|
<section className="flex flex-col items-start gap-0.5">
|
||||||
|
<p className="text-xs text-muted-foreground">{"GPU"}</p>
|
||||||
|
{server.host.gpu.length > 0 ? (
|
||||||
|
<div className="text-xs">{server.host.gpu.join(", ")}</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="text-xs"> {t("serverDetail.unknown")}</div>
|
<div className="text-xs"> {t("serverDetail.unknown")}</div>
|
||||||
)}
|
)}
|
||||||
|
@ -16,6 +16,7 @@ export interface NezhaServerHost {
|
|||||||
platform: string;
|
platform: string;
|
||||||
platform_version: string;
|
platform_version: string;
|
||||||
cpu: string[];
|
cpu: string[];
|
||||||
|
gpu: string[];
|
||||||
mem_total: number;
|
mem_total: number;
|
||||||
disk_total: number;
|
disk_total: number;
|
||||||
swap_total: number;
|
swap_total: number;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user