温华: 添加404路由到常驻路由表
This commit is contained in:
@@ -24,7 +24,7 @@ export default function SideBar() {
|
|||||||
const goPage = (val: any) => {
|
const goPage = (val: any) => {
|
||||||
console.log(val);
|
console.log(val);
|
||||||
|
|
||||||
navigate(val.key)
|
navigate(val.key, { replace: true })
|
||||||
}
|
}
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
getMenu()
|
getMenu()
|
||||||
@@ -36,6 +36,7 @@ export default function SideBar() {
|
|||||||
theme="dark"
|
theme="dark"
|
||||||
mode="inline"
|
mode="inline"
|
||||||
defaultSelectedKeys={[location.pathname]}
|
defaultSelectedKeys={[location.pathname]}
|
||||||
|
selectedKeys={[location.pathname]}
|
||||||
items={menuItem}
|
items={menuItem}
|
||||||
onClick={goPage}
|
onClick={goPage}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { getToken } from '../utils/auth'
|
import { getToken } from '../utils/auth'
|
||||||
import LayOut from '../layout/index'
|
import LayOut from '../layout/index'
|
||||||
import Home from '../view/home'
|
|
||||||
import { Suspense, lazy } from 'react'
|
import { Suspense, lazy } from 'react'
|
||||||
import Loading from '../Loading'
|
import Loading from '../Loading'
|
||||||
import RouteInterception from './RouteInterception'
|
import RouteInterception from './RouteInterception'
|
||||||
|
import Notfound from '../Notfound'
|
||||||
interface Meta {
|
interface Meta {
|
||||||
title: string,
|
title: string,
|
||||||
redirect?: boolean
|
redirect?: boolean
|
||||||
@@ -21,6 +21,10 @@ const lazyLoad = (viewName: string) => {
|
|||||||
const LoginView = lazy(()=>import('../Login'))
|
const LoginView = lazy(()=>import('../Login'))
|
||||||
return <LoginView />
|
return <LoginView />
|
||||||
}
|
}
|
||||||
|
if(viewName === 'home') {
|
||||||
|
const Home = lazy(()=>import('../view/home'))
|
||||||
|
return <Home />
|
||||||
|
}
|
||||||
const View = lazy(()=>import(`../view/${viewName}.tsx`))
|
const View = lazy(()=>import(`../view/${viewName}.tsx`))
|
||||||
return <View/>
|
return <View/>
|
||||||
}
|
}
|
||||||
@@ -29,11 +33,15 @@ const lazyLoad = (viewName: string) => {
|
|||||||
const currentRouter: Array<route> = [
|
const currentRouter: Array<route> = [
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
element: <RouteInterception><Suspense fallback={<Loading />}><LayOut /></Suspense></RouteInterception>,
|
element: <RouteInterception><LayOut /></RouteInterception>,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: "", //登录后默认跳转路径
|
path: "", //登录后默认跳转路径
|
||||||
element : <Home/>
|
element : <Suspense fallback={<Loading />}>{lazyLoad('home')}</Suspense>
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "*",
|
||||||
|
element: <Notfound />
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user