1- 'use strict'
1+ 'use strict' ;
22
33import express from 'express'
44import 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'
78import { StaticRouter } from 'react-router'
89import { Provider } from 'react-redux'
910import store from '../../client/pages/tools/store/forServer'
@@ -14,20 +15,24 @@ import Integration from '../../client/pages/integration/App'
1415const router = express . Router ( )
1516router . get ( '*' , ( req , res , next ) => {
1617 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' ) }
2223 >
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 ) )
3136} )
3237
3338export default {
0 commit comments