feat: init

This commit is contained in:
2025-09-05 15:18:10 +08:00
parent ddbee614e8
commit 85244a451e
126 changed files with 3020 additions and 10278 deletions

View File

@@ -1,27 +1,48 @@
import {Route, Routes} from 'react-router-dom';
import {routes, AppRoute} from './routes';
import AuthRoute from './auth.tsx';
import { Route, Routes } from "react-router-dom";
import { routes, AppRoute } from "./routes";
import AuthRoute from "./auth.tsx";
import { Suspense } from "react";
import { DotLoading } from "antd-mobile";
/**
* 渲染路由
* @constructor RenderRoutes
*/
export const RenderRoutes = () => {
const renderRoutes = (routes: AppRoute[]) => {
return routes.map(route => (
<Route
key={route.path}
path={route.path}
element={
<AuthRoute auth={route.auth}>
{route.element}
</AuthRoute>
}
>
{route.children && renderRoutes(route.children)}
</Route>
));
};
const renderRoutes = (routes: AppRoute[]) => {
return routes.map((route) => (
<Route
key={route.path}
path={route.path}
element={
<AuthRoute auth={route.auth} path={route.path} meta={route.meta}>
{route.element}
</AuthRoute>
}
>
{route.children && renderRoutes(route.children)}
</Route>
));
};
return <Routes>{renderRoutes(routes)}</Routes>;
return (
<Suspense
fallback={
<div
style={{
height: "100%",
width: "100%",
display: "flex",
alignItems: "center",
justifyContent: "center",
fontSize: "12px",
}}
>
<DotLoading />
</div>
}
>
<Routes>{renderRoutes(routes)}</Routes>
</Suspense>
);
};