mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
fix: fix server conditional judgment on route.ts
This commit is contained in:
parent
ad6454c8fd
commit
652e9ec137
@ -2,6 +2,7 @@
|
|||||||
import { NezhaAPI, ServerApi } from "@/app/types/nezha-api";
|
import { NezhaAPI, ServerApi } from "@/app/types/nezha-api";
|
||||||
import { MakeOptional } from "@/app/types/utils";
|
import { MakeOptional } from "@/app/types/utils";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
import { DateTime } from "luxon";
|
||||||
|
|
||||||
export async function GET(_: Request) {
|
export async function GET(_: Request) {
|
||||||
if (!process.env.NezhaBaseUrl) {
|
if (!process.env.NezhaBaseUrl) {
|
||||||
@ -33,10 +34,10 @@ export async function GET(_: Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
data.result = nezhaData.map((element: MakeOptional<NezhaAPI, "ipv4" | "ipv6" | "valid_ip">) => {
|
data.result = nezhaData.map((element: MakeOptional<NezhaAPI, "ipv4" | "ipv6" | "valid_ip">) => {
|
||||||
if (element.status.Uptime !== 0) {
|
if (DateTime.now().toUnixInteger() - element.last_active > 300) {
|
||||||
data.live_servers += 1;
|
|
||||||
} else {
|
|
||||||
data.offline_servers += 1;
|
data.offline_servers += 1;
|
||||||
|
} else {
|
||||||
|
data.live_servers += 1;
|
||||||
}
|
}
|
||||||
data.total_bandwidth += element.status.NetOutTransfer;
|
data.total_bandwidth += element.status.NetOutTransfer;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user