Compare commits

...

5 Commits

Author SHA1 Message Date
hamster1963
711ed79dc5 fix: v1.5.3-fix 2024-11-27 21:25:04 +08:00
hamster1963
e758ae137b fixL refresh 404 error 2024-11-27 21:24:48 +08:00
hamster1963
1e7e4c6678 fix: lint 2024-11-27 20:54:17 +08:00
hamster1963
a75aa209f2 update: v1.5.3 2024-11-27 20:47:12 +08:00
hamster1963
1b1f565e2c refactor!: not-found 2024-11-27 20:46:49 +08:00
10 changed files with 29 additions and 42 deletions

View File

@ -9,7 +9,7 @@ import { Card, CardContent } from "@/components/ui/card";
import getEnv from "@/lib/env-entry"; import getEnv from "@/lib/env-entry";
import { cn, formatBytes, nezhaFetcher } from "@/lib/utils"; import { cn, formatBytes, nezhaFetcher } from "@/lib/utils";
import { useTranslations } from "next-intl"; import { useTranslations } from "next-intl";
import { useRouter } from "next/navigation"; import { notFound, useRouter } from "next/navigation";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import useSWR from "swr"; import useSWR from "swr";
import useSWRImmutable from "swr/immutable"; import useSWRImmutable from "swr/immutable";
@ -43,7 +43,7 @@ export default function ServerDetailClient({
} }
}; };
const { data: allFallbackData } = useSWRImmutable<ServerApi>( const { data: allFallbackData, isLoading } = useSWRImmutable<ServerApi>(
"/api/server", "/api/server",
nezhaFetcher, nezhaFetcher,
); );
@ -51,6 +51,10 @@ export default function ServerDetailClient({
(item) => item.id === server_id, (item) => item.id === server_id,
); );
if (!fallbackData && !isLoading) {
notFound();
}
const { data, error } = useSWR<NezhaAPISafe>( const { data, error } = useSWR<NezhaAPISafe>(
`/api/detail?server_id=${server_id}`, `/api/detail?server_id=${server_id}`,
nezhaFetcher, nezhaFetcher,

View File

@ -1,31 +1,25 @@
import { useTranslations } from "next-intl"; import { useTranslations } from "next-intl";
import Image from "next/image";
import Link from "next/link"; import Link from "next/link";
import Footer from "./(main)/footer";
import Header from "./(main)/header";
export default function NotFoundPage() { export default function NotFoundPage() {
const t = useTranslations("NotFoundPage"); const t = useTranslations("NotFoundPage");
return ( return (
<main className="relative h-screen w-full"> <div className="flex min-h-screen w-full flex-col">
<div className="absolute inset-0 m-4 flex items-center justify-center"> <main className="flex min-h-[calc(100vh-calc(var(--spacing)*16))] flex-1 flex-col gap-4 bg-background p-4 md:p-10 md:pt-8">
<Image <Header />
priority <section className="flex flex-col items-center min-h-44 justify-center gap-2">
className="rounded-3xl object-cover" <p className="text-sm font-semibold">{t("h1_490-590_404NotFound")}</p>
src="/tardis.jpg" <Link href="/" className="flex items-center gap-1">
fill={true} <p className="text-sm font-medium opacity-40">
alt="TARDIS" {t("h1_490-590_404NotFoundBack")}
/> </p>
<div className="text-container absolute right-4 p-4 md:right-20">
<h1 className="text-2xl font-bold opacity-80 md:text-5xl">
{t("h1_490-590_404NotFound")}
</h1>
<p className="text-lg opacity-60 md:text-base">
{t("p_601-665_TARDISERROR")}
</p>
<Link href={"/"} className="text-2xl opacity-80 md:text-3xl">
{t("Link_676-775_Doctor")}
</Link> </Link>
</div> </section>
</div> <Footer />
</main> </main>
</div>
); );
} }

View File

@ -12,7 +12,6 @@ import {
import { cn, formatBytes, formatNezhaInfo } from "@/lib/utils"; import { cn, formatBytes, formatNezhaInfo } from "@/lib/utils";
import { useTranslations } from "next-intl"; import { useTranslations } from "next-intl";
import Link from "next/link"; import Link from "next/link";
import { useRouter } from "next/navigation";
export default function ServerCard({ export default function ServerCard({
serverInfo, serverInfo,
@ -20,7 +19,6 @@ export default function ServerCard({
serverInfo: NezhaAPISafe; serverInfo: NezhaAPISafe;
}) { }) {
const t = useTranslations("ServerCard"); const t = useTranslations("ServerCard");
const router = useRouter();
const { id, name, country_code, online, cpu, up, down, mem, stg, host } = const { id, name, country_code, online, cpu, up, down, mem, stg, host } =
formatNezhaInfo(serverInfo); formatNezhaInfo(serverInfo);
@ -34,7 +32,7 @@ export default function ServerCard({
}; };
return online ? ( return online ? (
<Link onClick={saveSession} href={`/${id}`} prefetch={true}> <Link onClick={saveSession} href={`/server/${id}`} prefetch={true}>
<Card <Card
className={cn( className={cn(
"flex flex-col items-center justify-start gap-3 p-3 md:px-5 cursor-pointer hover:bg-accent/50 transition-colors", "flex flex-col items-center justify-start gap-3 p-3 md:px-5 cursor-pointer hover:bg-accent/50 transition-colors",
@ -138,12 +136,7 @@ export default function ServerCard({
</div> </div>
</section> </section>
{showNetTransfer && ( {showNetTransfer && (
<section <section className={"flex items-center justify-between gap-1"}>
onClick={() => {
router.push(`/${id}`);
}}
className={"flex items-center justify-between gap-1"}
>
<Badge <Badge
variant="secondary" variant="secondary"
className="items-center flex-1 justify-center rounded-[8px] text-nowrap text-[11px] border-muted-50 shadow-md shadow-neutral-200/30 dark:shadow-none" className="items-center flex-1 justify-center rounded-[8px] text-nowrap text-[11px] border-muted-50 shadow-md shadow-neutral-200/30 dark:shadow-none"

View File

@ -98,7 +98,6 @@
}, },
"NotFoundPage": { "NotFoundPage": {
"h1_490-590_404NotFound": "404 Not Found", "h1_490-590_404NotFound": "404 Not Found",
"p_601-665_TARDISERROR": "TARDIS ERROR!", "h1_490-590_404NotFoundBack": " Press here to go back"
"Link_676-775_Doctor": "Doctor?"
} }
} }

View File

@ -98,7 +98,6 @@
}, },
"NotFoundPage": { "NotFoundPage": {
"h1_490-590_404NotFound": "404 見つかりませんでした", "h1_490-590_404NotFound": "404 見つかりませんでした",
"p_601-665_TARDISERROR": "ターディスエラー!", "h1_490-590_404NotFoundBack": "戻る"
"Link_676-775_Doctor": "Doctor?"
} }
} }

View File

@ -98,7 +98,6 @@
}, },
"NotFoundPage": { "NotFoundPage": {
"h1_490-590_404NotFound": "404 未找到", "h1_490-590_404NotFound": "404 未找到",
"p_601-665_TARDISERROR": "TARDIS 錯誤!", "h1_490-590_404NotFoundBack": "返回"
"Link_676-775_Doctor": "Doctor"
} }
} }

View File

@ -98,7 +98,6 @@
}, },
"NotFoundPage": { "NotFoundPage": {
"h1_490-590_404NotFound": "404 未找到", "h1_490-590_404NotFound": "404 未找到",
"p_601-665_TARDISERROR": "TARDIS 错误!", "h1_490-590_404NotFoundBack": "返回"
"Link_676-775_Doctor": "Doctor"
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "nezha-dash", "name": "nezha-dash",
"version": "1.5.2-fix", "version": "1.5.3-fix",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev -p 3040", "dev": "next dev -p 3040",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 571 KiB