@@ -2,7 +2,7 @@ import './AppLayout.less';
2
2
3
3
import * as React from 'react' ;
4
4
5
- import { Redirect , Switch } from 'react-router-dom' ;
5
+ import { Redirect , Switch , Route } from 'react-router-dom' ;
6
6
7
7
import DocumentTitle from 'react-document-title' ;
8
8
import Footer from '../../components/Footer' ;
@@ -12,6 +12,7 @@ import ProtectedRoute from '../../components/Router/ProtectedRoute';
12
12
import SiderMenu from '../../components/SiderMenu' ;
13
13
import { appRouters } from '../Router/router.config' ;
14
14
import utils from '../../utils/utils' ;
15
+ import NotFoundRoute from '../Router/NotFoundRoute' ;
15
16
16
17
const { Content } = Layout ;
17
18
@@ -48,13 +49,18 @@ class AppLayout extends React.Component<any> {
48
49
</ Layout . Header >
49
50
< Content style = { { margin : 16 } } >
50
51
< Switch >
52
+ { this . props . location . pathname === '/' && < Redirect from = "/" to = "/dashboard" /> }
51
53
{ appRouters
52
54
. filter ( ( item : any ) => ! item . isLayout )
53
55
. map ( ( route : any , index : any ) => (
54
- < ProtectedRoute key = { index } path = { route . path } component = { route . component } permission = { route . permission } />
56
+ < Route
57
+ exact
58
+ key = { index }
59
+ path = { route . path }
60
+ render = { props => < ProtectedRoute component = { route . component } permission = { route . permission } /> }
61
+ />
55
62
) ) }
56
-
57
- < Redirect from = "/" to = "/dashboard" />
63
+ { pathname !== '/' && < NotFoundRoute /> }
58
64
</ Switch >
59
65
</ Content >
60
66
< Layout . Footer style = { { textAlign : 'center' } } >
0 commit comments