This commit is contained in:
yangy
2026-05-26 19:16:42 +08:00
parent 47ea7d7b56
commit 517036439c
4 changed files with 69 additions and 42 deletions
+33 -6
View File
@@ -1,16 +1,16 @@
import { lazy, Suspense } from "react";
import { Toaster } from "@/components/ui/sonner";
import { TooltipProvider } from "@/components/ui/tooltip";
import { Route, Switch, Router } from "wouter";
import { useHashLocation } from "wouter/use-hash-location";
import ErrorBoundary from "./components/ErrorBoundary";
import PageLoader from "./components/PageLoader";
import { ThemeProvider } from "./contexts/ThemeContext";
import { DeviceProvider } from "./contexts/DeviceContext";
import Home from "./pages/Home";
import NotFound from "./pages/NotFound";
import Dashboard from "./pages/Dashboard";
import AudioPage from "./pages/AudioPage";
import EQPage from "./pages/EQPage";
import EffectsPage from "./pages/EffectsPage";
import BluetoothPage from "./pages/BluetoothPage";
import DspPage from "./pages/DspPage";
import DisplayPage from "./pages/DisplayPage";
@@ -18,14 +18,41 @@ import SystemPage from "./pages/SystemPage";
import IOPage from "./pages/IOPage";
import VUPage from "./pages/VUPage";
import SelectPage from "./pages/SelectPage";
import AIPage from "./pages/AIPage";
import CommunityPage from "./pages/CommunityPage";
import { AIDrawerProvider } from "./contexts/AIDrawerContext";
import DesktopAIShell from "./components/DesktopAIShell";
import { appShellColumnClass, appShellGutterClass } from "./lib/appShell";
const EQPage = lazy(() => import("./pages/EQPage"));
const EffectsPage = lazy(() => import("./pages/EffectsPage"));
const AIPage = lazy(() => import("./pages/AIPage"));
function LazyRoute({ children }: { children: React.ReactNode }) {
return <Suspense fallback={<PageLoader />}>{children}</Suspense>;
}
function AIPageRoute() {
return <AIPage />;
return (
<LazyRoute>
<AIPage />
</LazyRoute>
);
}
function EQPageRoute() {
return (
<LazyRoute>
<EQPage />
</LazyRoute>
);
}
function EffectsPageRoute() {
return (
<LazyRoute>
<EffectsPage />
</LazyRoute>
);
}
function AppRouter() {
@@ -34,8 +61,8 @@ function AppRouter() {
<Route path="/" component={Home} />
<Route path="/dashboard" component={Dashboard} />
<Route path="/audio" component={AudioPage} />
<Route path="/eq" component={EQPage} />
<Route path="/effects" component={EffectsPage} />
<Route path="/eq" component={EQPageRoute} />
<Route path="/effects" component={EffectsPageRoute} />
<Route path="/bluetooth" component={BluetoothPage} />
<Route path="/dsp" component={DspPage} />
<Route path="/display" component={DisplayPage} />
+7 -2
View File
@@ -1,4 +1,5 @@
import AIPage from "@/pages/AIPage";
import { lazy, Suspense } from "react";
import PageLoader from "@/components/PageLoader";
import { useAIDrawer } from "@/contexts/AIDrawerContext";
import { useIsLgUp } from "@/hooks/useIsLgUp";
import { cn } from "@/lib/utils";
@@ -11,6 +12,8 @@ import {
type RefObject,
} from "react";
const AIPage = lazy(() => import("@/pages/AIPage"));
function SplitDivider({
containerRef,
onResize,
@@ -114,7 +117,9 @@ export default function DesktopAIShell({ children }: { children: ReactNode }) {
className="flex h-full min-h-0 min-w-0 flex-col overflow-hidden border-l border-white/[0.08] bg-[#0d1117]"
style={{ flex: `${splitPercent} 1 0%` }}
>
<AIPage variant="split" onClose={() => setOpen(false)} />
<Suspense fallback={<PageLoader />}>
<AIPage variant="split" onClose={() => setOpen(false)} />
</Suspense>
</div>
</>
)}
+8
View File
@@ -0,0 +1,8 @@
/** Lightweight fallback while lazy-loaded routes fetch their chunks. */
export default function PageLoader() {
return (
<div className="flex min-h-[40vh] items-center justify-center">
<span className="text-sm text-white/40">Loading</span>
</div>
);
}