From 4bf63e13062764f02f758924fd384769f645bfc0 Mon Sep 17 00:00:00 2001 From: wenhua <1084668738@qq.com> Date: Mon, 16 Oct 2023 14:28:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=A9=E5=8D=8E:=20=E6=B7=BB=E5=8A=A0404?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E5=88=B0=E5=B8=B8=E9=A9=BB=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/sidebar/index.tsx | 3 ++- src/router/index.tsx | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/layout/sidebar/index.tsx b/src/layout/sidebar/index.tsx index 6778349..b28ca06 100644 --- a/src/layout/sidebar/index.tsx +++ b/src/layout/sidebar/index.tsx @@ -24,7 +24,7 @@ export default function SideBar() { const goPage = (val: any) => { console.log(val); - navigate(val.key) + navigate(val.key, { replace: true }) } useEffect(()=>{ getMenu() @@ -36,6 +36,7 @@ export default function SideBar() { theme="dark" mode="inline" defaultSelectedKeys={[location.pathname]} + selectedKeys={[location.pathname]} items={menuItem} onClick={goPage} /> diff --git a/src/router/index.tsx b/src/router/index.tsx index 8c8851c..b7ecb3b 100644 --- a/src/router/index.tsx +++ b/src/router/index.tsx @@ -1,9 +1,9 @@ import { getToken } from '../utils/auth' import LayOut from '../layout/index' -import Home from '../view/home' import { Suspense, lazy } from 'react' import Loading from '../Loading' import RouteInterception from './RouteInterception' +import Notfound from '../Notfound' interface Meta { title: string, redirect?: boolean @@ -21,6 +21,10 @@ const lazyLoad = (viewName: string) => { const LoginView = lazy(()=>import('../Login')) return } + if(viewName === 'home') { + const Home = lazy(()=>import('../view/home')) + return + } const View = lazy(()=>import(`../view/${viewName}.tsx`)) return } @@ -29,11 +33,15 @@ const lazyLoad = (viewName: string) => { const currentRouter: Array = [ { path: '/', - element: }>, + element: , children: [ { path: "", //登录后默认跳转路径 - element : + element : }>{lazyLoad('home')} + }, + { + path: "*", + element: } ] },