From 7b60a3b7c4206b0dbc49221c5db9ca4192a1233b Mon Sep 17 00:00:00 2001 From: wkj <278599135@qq.com> Date: Tue, 2 Aug 2022 14:58:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/web/src/App.tsx | 100 ++++++++---------- .../web/src/{utils => template}/Loading.tsx | 0 template/web/src/template/console/index.tsx | 15 --- template/web/src/utils/lazyLoad.tsx | 13 --- 4 files changed, 47 insertions(+), 81 deletions(-) rename template/web/src/{utils => template}/Loading.tsx (100%) delete mode 100644 template/web/src/utils/lazyLoad.tsx diff --git a/template/web/src/App.tsx b/template/web/src/App.tsx index 690bb0f..794890e 100644 --- a/template/web/src/App.tsx +++ b/template/web/src/App.tsx @@ -1,30 +1,32 @@ -import React, { useState } from 'react'; +import React from 'react'; import { Routes, Route } from 'react-router-dom'; -import { Button, Drawer } from 'tdesign-react'; -import { ChevronUpIcon } from 'tdesign-icons-react' import './App.less'; -import LazyLoad from './utils/lazyLoad'; -const Console = LazyLoad(() => import('./template/console')); -const Frontend = LazyLoad(() => import('./template/frontend')); -const NotFound = LazyLoad(() => import('./template/notFound')); -const Message = LazyLoad(() => import('@oak-general-business/components/message')); -const DebugPanel = LazyLoad(() => import('@oak-general-business/components/Func/debugPanel')); +import Loading from './template/Loading'; +const Console = React.lazy(() => import('./template/console')); +const Frontend = React.lazy(() => import('./template/frontend')); +const NotFound = React.lazy(() => import('./template/notFound')); +const Message = React.lazy(() => import('@oak-general-business/components/message')); +const DebugPanel = React.lazy(() => import('@oak-general-business/components/func/debugPanel')); type Router = { path: string; - element: ReturnType; + element: React.LazyExoticComponent>; title: string; -} +}; function getRoutes(routers2: Router[], namespace?: string) { return routers2.map((router, index) => { - const { path, element } = router; + const { path, element: Component } = router; return ( }> + + + } > ); }); @@ -33,54 +35,46 @@ function getRoutes(routers2: Router[], namespace?: string) { let routers: Router[] = []; function App() { - const [visible, setVisible] = useState(false); - - const handleClick = () => { - setVisible(true); - }; - const handleClose = () => { - setVisible(false); - }; return ( - {Message} + + + - + }> + + + } + > {getRoutes(routers, 'console')} - + }> + + + } + > {getRoutes(routers)} - + }> + + + } + /> - { - process.env.NODE_ENV === "development" && ( - -