Clean up dead toolbox code and harden routing and static serving
This commit is contained in:
parent
184314d913
commit
cce3f3c7f8
9 changed files with 25 additions and 98 deletions
|
|
@ -1,5 +1,5 @@
|
|||
// Rôle : choisit la page à rendre selon la route active.
|
||||
import { lazy, Suspense } from "react";
|
||||
import { lazy, Suspense, useEffect } from "react";
|
||||
import { AboutPage } from "../pages/AboutPage.jsx";
|
||||
import { HomePage } from "../pages/HomePage.jsx";
|
||||
import { navigate } from "./hashRouter.js";
|
||||
|
|
@ -17,6 +17,13 @@ function RouteLoader() {
|
|||
return <section className="empty nds-empty-state"><p>Chargement...</p></section>;
|
||||
}
|
||||
|
||||
function UnknownRouteRedirect() {
|
||||
useEffect(() => {
|
||||
navigate("/");
|
||||
}, []);
|
||||
return <RouteLoader />;
|
||||
}
|
||||
|
||||
export function RouteContent(props) {
|
||||
const { route } = props;
|
||||
if (route === "/") return <HomePage {...props} />;
|
||||
|
|
@ -27,6 +34,5 @@ export function RouteContent(props) {
|
|||
if (route.startsWith("/toolbox/")) return <Suspense fallback={<RouteLoader />}><ToolboxPage {...props} toolboxId={route.split("/")[2]} /></Suspense>;
|
||||
if (route === "/games") return <Suspense fallback={<RouteLoader />}><GamesPage {...props} /></Suspense>;
|
||||
if (route.startsWith("/games/")) return <Suspense fallback={<RouteLoader />}><GameRoute {...props} gameId={route.split("/")[2]} category={route.split("/")[3] || ""} /></Suspense>;
|
||||
navigate("/");
|
||||
return null;
|
||||
return <UnknownRouteRedirect />;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue