diff --git a/src/App.tsx b/src/App.tsx index 02b2a74..4205103 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,6 +1,6 @@ import { useQuery } from "@tanstack/react-query"; import type React from "react"; -import { useEffect, useState } from "react"; +import { lazy, Suspense, useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { Route, BrowserRouter as Router, Routes } from "react-router-dom"; @@ -8,15 +8,39 @@ import { DashCommand } from "./components/DashCommand"; import ErrorBoundary from "./components/ErrorBoundary"; import Footer from "./components/Footer"; import Header, { RefreshToast } from "./components/Header"; +import { Skeleton } from "./components/ui/skeleton"; import { useBackground } from "./hooks/use-background"; import { useTheme } from "./hooks/use-theme"; import { InjectContext } from "./lib/inject"; import { fetchSetting } from "./lib/nezha-api"; import { cn } from "./lib/utils"; import ErrorPage from "./pages/ErrorPage"; -import NotFound from "./pages/NotFound"; import Server from "./pages/Server"; -import ServerDetail from "./pages/ServerDetail"; + +const NotFound = lazy(() => import("./pages/NotFound")); +const ServerDetail = lazy(() => import("./pages/ServerDetail")); + +function ServerDetailRouteFallback() { + return ( +
+
+
+ + +
+ +
+
+ + + + + + +
+
+ ); +} // Route checker component const RouteChecker: React.FC = () => { @@ -110,9 +134,23 @@ const MainApp: React.FC = () => { } /> - } /> + }> + + + } + /> } /> - } /> + + + + } + />