From 1b1f565e2cba26049e21a66309187663a7ca21b7 Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Wed, 27 Nov 2024 20:46:49 +0800 Subject: [PATCH] refactor!: not-found --- .../ClientComponents/ServerDetailClient.tsx | 6 ++- app/(main)/{ => server}/[id]/page.tsx | 0 app/not-found.tsx | 37 ++++++++---------- components/ServerCard.tsx | 9 +---- messages/en.json | 3 +- messages/ja.json | 3 +- messages/zh-t.json | 3 +- messages/zh.json | 3 +- public/tardis.jpg | Bin 584635 -> 0 bytes 9 files changed, 27 insertions(+), 37 deletions(-) rename app/(main)/{ => server}/[id]/page.tsx (100%) delete mode 100644 public/tardis.jpg diff --git a/app/(main)/ClientComponents/ServerDetailClient.tsx b/app/(main)/ClientComponents/ServerDetailClient.tsx index 006e821..7f4a10b 100644 --- a/app/(main)/ClientComponents/ServerDetailClient.tsx +++ b/app/(main)/ClientComponents/ServerDetailClient.tsx @@ -9,7 +9,7 @@ import { Card, CardContent } from "@/components/ui/card"; import getEnv from "@/lib/env-entry"; import { cn, formatBytes, nezhaFetcher } from "@/lib/utils"; import { useTranslations } from "next-intl"; -import { useRouter } from "next/navigation"; +import { notFound, useRouter } from "next/navigation"; import { useEffect, useState } from "react"; import useSWR from "swr"; import useSWRImmutable from "swr/immutable"; @@ -51,6 +51,10 @@ export default function ServerDetailClient({ (item) => item.id === server_id, ); + if (!fallbackData) { + notFound(); + } + const { data, error } = useSWR( `/api/detail?server_id=${server_id}`, nezhaFetcher, diff --git a/app/(main)/[id]/page.tsx b/app/(main)/server/[id]/page.tsx similarity index 100% rename from app/(main)/[id]/page.tsx rename to app/(main)/server/[id]/page.tsx diff --git a/app/not-found.tsx b/app/not-found.tsx index c16c1ee..7b51dd5 100644 --- a/app/not-found.tsx +++ b/app/not-found.tsx @@ -2,30 +2,25 @@ import { useTranslations } from "next-intl"; import Image from "next/image"; import Link from "next/link"; +import Footer from "./(main)/footer"; +import Header from "./(main)/header"; + export default function NotFoundPage() { const t = useTranslations("NotFoundPage"); return ( -
-
- TARDIS -
-

- {t("h1_490-590_404NotFound")} -

-

- {t("p_601-665_TARDISERROR")} -

- - {t("Link_676-775_Doctor")} +
+
+
+
+

{t("h1_490-590_404NotFound")}

+ +

+ {t("h1_490-590_404NotFoundBack")} +

-
-
-
+ +