Commit 988cd561 authored by Chunchi Che's avatar Chunchi Che

fix

parent 0ba53828
...@@ -4,5 +4,4 @@ const LazyLoad = (props: { lazy: React.ReactNode }) => { ...@@ -4,5 +4,4 @@ const LazyLoad = (props: { lazy: React.ReactNode }) => {
return <Suspense fallback={<div>Loading...</div>}>{props.lazy}</Suspense>; return <Suspense fallback={<div>Loading...</div>}>{props.lazy}</Suspense>;
}; };
export const lazyImport = (module: string) => React.lazy(() => import(module));
export default LazyLoad; export default LazyLoad;
import React from "react"; import React, { Suspense } from "react";
import { Routes, Route } from "react-router-dom"; import { Routes, Route } from "react-router-dom";
import LazyLoad, { lazyImport } from "./LazyLoad"; import LazyLoad from "./LazyLoad";
const Login = lazyImport("./Login"); const Login = React.lazy(() => import("./Login"));
const WaitRoom = lazyImport("./WaitRoom"); const WaitRoom = React.lazy(() => import("./WaitRoom"));
const Mora = lazyImport("./Mora"); const Mora = React.lazy(() => import("./Mora"));
const NeosDuel = lazyImport("./Duel/main"); const NeosDuel = React.lazy(() => import("./Duel/main"));
export default function () { export default function () {
// FIXME: 这里Mora/Duel路由应该由每个房间指定一个路径 // FIXME: 这里Mora/Duel路由应该由每个房间指定一个路径
...@@ -14,15 +14,15 @@ export default function () { ...@@ -14,15 +14,15 @@ export default function () {
<Route path="/" element={<LazyLoad lazy={<Login />} />} /> <Route path="/" element={<LazyLoad lazy={<Login />} />} />
<Route <Route
path="/room/:player/:passWd/:ip" path="/room/:player/:passWd/:ip"
element={<LazyLoad lazy={<WaitRoom />} />} element={<Suspense fallback={<div>Loading...</div>}><WaitRoom /></Suspense>}
/> />
<Route <Route
path="/mora/:player/:passWd/:ip" path="/mora/:player/:passWd/:ip"
element={<LazyLoad lazy={<Mora />} />} element={<Suspense fallback={<div>Loading...</div>}><Mora /></Suspense>}
/> />
<Route <Route
path="/duel/:player/:passWd/:ip" path="/duel/:player/:passWd/:ip"
element={<LazyLoad lazy={<NeosDuel />} />} element={<Suspense fallback={<div>Loading...</div>}><NeosDuel /></Suspense>}
/> />
</Routes> </Routes>
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment