@@ -10,10 +10,7 @@ import store from 'store';
10
10
import { syncHistoryWithStore } from 'react-router-redux' ;
11
11
12
12
import App from 'components/App' ;
13
- import Category from 'components/Category' ;
14
- import Categorys from 'components/Categorys' ;
15
- import Live from 'components/Screen' ;
16
- import Hot from 'components/Hot' ;
13
+
17
14
import Wiki from 'components/pageWiki' ;
18
15
import FourOhFour from 'components/FourOhFour' ;
19
16
import CategoryItem from 'components/CategoryItem' ;
@@ -26,28 +23,44 @@ const history = syncHistoryWithStore(browserHistory, store);
26
23
store . dispatch ( getMetadata ( ) ) ;
27
24
store . dispatch ( getCategory ( ) ) ;
28
25
26
+ const getAppComp = ( nextState , cb ) => {
27
+ require . ensure ( [ ] , ( require ) => {
28
+ cb ( null , require ( 'components/App' ) . default )
29
+ } , 'app' )
30
+ }
31
+
32
+ const getCategoryComp = ( nextState , cb ) => {
33
+ require . ensure ( [ ] , ( require ) => {
34
+ cb ( null , require ( 'components/Category' ) . default )
35
+ } , 'category' )
36
+ }
37
+ const getCategorysComp = ( nextState , cb ) => {
38
+ require . ensure ( [ ] , ( require ) => {
39
+ cb ( null , require ( 'components/Categorys' ) . default )
40
+ } , 'categorys' )
41
+ }
42
+ const getLiveComp = ( nextState , cb ) => {
43
+ require . ensure ( [ ] , ( require ) => {
44
+ cb ( null , require ( 'components/Screen' ) . default )
45
+ } , 'live' )
46
+ }
47
+ const getHotComp = ( nextState , cb ) => {
48
+ require . ensure ( [ ] , ( require ) => {
49
+ cb ( null , require ( 'components/Hot' ) . default )
50
+ } , 'hot' )
51
+ }
52
+
29
53
export default ( ) => (
30
54
< Provider store = { store } >
31
55
< Router history = { history } >
32
56
< Route path = "/" component = { App } >
33
- < IndexRoute component = { Category } />
34
- < Route path = "categorys" component = { Category } />
35
- < Route path = "categorys/:name" component = { Categorys } />
36
- < Route path = "hot" component = { Hot } />
37
- < Route path = "live" component = { Live } />
57
+ < IndexRoute getComponent = { getCategoryComp } />
58
+ < Route path = "categorys" getComponent = { getCategoryComp } />
59
+ < Route path = "categorys/:name" getComponent = { getCategorysComp } />
60
+ < Route path = "hot" getComponent = { getHotComp } />
61
+ < Route path = "live" getComponent = { getLiveComp } />
38
62
< Route path = "*" component = { FourOhFour } />
39
63
</ Route >
40
64
</ Router >
41
65
</ Provider >
42
66
) ;
43
-
44
- const checkStatus = ( nextState , replace , next ) => {
45
-
46
- next ( )
47
-
48
- }
49
-
50
- const checkFetchStatus = ( nextState , replace , next ) => {
51
- if ( store . getState ( ) . categorys . loading ) return ;
52
- next ( ) ;
53
- }
0 commit comments