File size: 1,113 Bytes
d757506
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Switch ,NavLink,withRouter} from 'react-router-dom';
import RouterView from '@/router/routerConfig'
import {useState,useEffect,Suspense} from 'react'
import routerMap from './router/router'
import style from './App.module.less'

function App(props:any) {
  const [footerShow, setFooterShow] = useState(false)
  const routerChange = () => {
    const targetRouter = routerMap.find((item: any) => item.path === props.location.pathname);
    setFooterShow(targetRouter?.footerShow)
  }
  useEffect(() => {
    routerChange()
  }, [props.location])
  return (
    <div className={style.page}>
      <div className={style.content}>
        <Suspense fallback={<div>Loading...</div>}>
          <Switch>
            <RouterView />
          </Switch>
        </Suspense>
      </div>
      {/* {footerShow ? <div className={style.footer}>
        <NavLink to="/home" className={style.item} activeClassName={style.active}>首页</NavLink>
        <NavLink to="/about" className={style.item} activeClassName={style.active}>关于</NavLink>
      </div> : ''} */}
    </div>
  )
}

export default withRouter(App)