@@ -2,64 +2,47 @@ import './App.css';
22
33import { Layout } from 'antd' ;
44import { connect } from 'dva' ;
5- import React , { Component } from 'react' ;
6- import DocumentTitle from 'react-document-title' ;
5+ import React , { FC } from 'react' ;
76
87import { Content , ErrorBoundary , Footer , Header , SideBar } from './components' ;
98import { Auth } from './models/global' ;
109import AppRoutes from './routes' ;
1110import routesConfig from './routes/config' ;
1211import { getFlatMenuKeys } from './utils/utils' ;
1312
13+ const menu = routesConfig . app ;
14+ const flatMenuKeys = getFlatMenuKeys ( menu ) ;
15+
1416interface DvaProps {
1517 auth : Auth ;
1618 location : Location ;
1719 collapsed : boolean ;
1820 onCollapse : ( collapsed : boolean ) => void ;
1921}
2022
21- interface InternalProps extends DvaProps {
23+ interface Props extends DvaProps {
2224 app : any ;
2325}
2426
25- interface InternalState {
26- title : string ;
27- }
28-
29- class App extends Component < InternalProps , InternalState > {
30- private menu = routesConfig . app ;
31- private flatMenuKeys = getFlatMenuKeys ( this . menu ) ;
32-
33- private constructor ( props : InternalProps ) {
34- super ( props ) ;
35- this . state = {
36- title : '' ,
37- } ;
38- }
27+ const App : FC < Props > = ( props : Props ) => {
28+ const { app, auth, collapsed, location, onCollapse } = props ;
3929
40- public render ( ) {
41- const { title } = this . state ;
42- const { app, auth, collapsed, location, onCollapse } = this . props ;
43-
44- return (
45- < DocumentTitle title = { title } >
46- < Layout className = "App" >
47- < SideBar collapsed = { collapsed } menu = { this . menu } onCollapse = { onCollapse }
48- flatMenuKeys = { this . flatMenuKeys } location = { location } />
49- < Layout >
50- < Header />
51- < Content >
52- < ErrorBoundary >
53- < AppRoutes app = { app } auth = { auth } />
54- </ ErrorBoundary >
55- </ Content >
56- < Footer className = "Footer" />
57- </ Layout >
58- </ Layout >
59- </ DocumentTitle >
60- ) ;
61- }
62- }
30+ return (
31+ < Layout className = "App" >
32+ < SideBar collapsed = { collapsed } menu = { menu } onCollapse = { onCollapse }
33+ flatMenuKeys = { flatMenuKeys } location = { location } />
34+ < Layout >
35+ < Header />
36+ < Content >
37+ < ErrorBoundary >
38+ < AppRoutes app = { app } auth = { auth } />
39+ </ ErrorBoundary >
40+ </ Content >
41+ < Footer className = "Footer" />
42+ </ Layout >
43+ </ Layout >
44+ ) ;
45+ } ;
6346
6447const mapStateToProps = ( { global } : any ) => {
6548 return {
0 commit comments