1
- 'use strict'
1
+ 'use strict' ;
2
2
3
3
import express from 'express'
4
4
import React from 'react'
5
- import { renderToString } from 'react-dom/server'
6
- import mapAssets from '../utils/mapAssets'
5
+ import { toSream , setResHeaders } from '../react'
6
+ import Skeleton from '../react/skeleton'
7
+ import mapReactAssets from '../utils/mapReactAssets'
7
8
import { StaticRouter } from 'react-router'
8
9
import { Provider } from 'react-redux'
9
10
import store from '../../client/pages/tools/store/forServer'
@@ -14,20 +15,24 @@ import Integration from '../../client/pages/integration/App'
14
15
const router = express . Router ( )
15
16
router . get ( '*' , ( req , res , next ) => {
16
17
const location = `${ req . baseUrl } ${ req . path } `
17
- const content = renderToString ( < Provider store = { store ( reducers ) } >
18
- < StaticRouter
19
- location = { location }
20
- context = { { } }
21
- basename = { req . baseUrl }
18
+ const Html = ( props ) => (
19
+ < Skeleton
20
+ title = "整合redux"
21
+ links = { mapReactAssets ( 'integration/index.css' ) }
22
+ scripts = { mapReactAssets ( 'integration/index.js' ) }
22
23
>
23
- < Content component = { Integration } />
24
- </ StaticRouter >
25
- </ Provider > )
26
- res . render ( 'integration' , {
27
- app : content ,
28
- links : mapAssets ( 'integration/index.css' ) ,
29
- scripts : mapAssets ( 'integration/index.js' )
30
- } )
24
+ < Provider store = { store ( reducers ) } >
25
+ < StaticRouter
26
+ location = { location }
27
+ context = { { } }
28
+ basename = { req . baseUrl }
29
+ >
30
+ < Content component = { Integration } />
31
+ </ StaticRouter >
32
+ </ Provider >
33
+ </ Skeleton >
34
+ )
35
+ toSream ( < Html /> ) . pipe ( setResHeaders ( res ) )
31
36
} )
32
37
33
38
export default {
0 commit comments