pref: 代码打包优化
This commit is contained in:
@@ -6,10 +6,11 @@ import PanelContainer from "components/Layout/PanelContainer";
|
||||
import PanelContent from "components/Layout/PanelContent";
|
||||
import Sidebar from "components/Sidebar/Sidebar.js";
|
||||
import { SidebarContext } from "contexts/SidebarContext";
|
||||
import React, { useState } from "react";
|
||||
import React, { useState, Suspense } from "react";
|
||||
|
||||
import { Route, Routes, Navigate } from "react-router-dom";
|
||||
import routes from "routes.js";
|
||||
import PageLoader from "components/Loading/PageLoader";
|
||||
|
||||
const Landing = () => {
|
||||
const [toggleSidebar, setToggleSidebar] = useState(false);
|
||||
@@ -18,10 +19,15 @@ const Landing = () => {
|
||||
const getRoutes = (routes) => {
|
||||
return routes.map((route, key) => {
|
||||
if (route.layout === "/landing") {
|
||||
const Component = route.component;
|
||||
return (
|
||||
<Route
|
||||
path={ route.path}
|
||||
element={route.component}
|
||||
path={route.path}
|
||||
element={
|
||||
<Suspense fallback={<PageLoader message="加载中..." />}>
|
||||
<Component />
|
||||
</Suspense>
|
||||
}
|
||||
key={key}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user