Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// console.log(_route.component);
// console.log(_route.component.loadData);
if (_route.loadData) {
context = await _route.loadData({ store, match: _match })
// console.log(context);
}
await _route.component.preload()
// await Loadable.preloadAll();
// 获取路由dom
const _Router = router.dom
const metaTagsInstance = MetaTagsServer()
let _mainContent = (
<_Router />
)
// html
let html = ReactDOMServer.renderToString(_mainContent)
// 获取页面的meta,嵌套到模版中
let meta = metaTagsInstance.renderToString()
const Page: any = router.dom;
let _p = await route.body.preload();
if (_p.default.loadDataOnServer) {
let { code, redirect } = await _p.default.loadDataOnServer({
store, match, res, req, user
});
params.code = code;
params.redirect = redirect;
}
// console.log(_p);
// context={params.context}
let metaTagsInstance = MetaTagsServer();
// html
params.html = ReactDOMServer.renderToString(
);
// 获取页面的meta,嵌套到模版中
params.meta = metaTagsInstance.renderToString();
// redux
params.reduxState = JSON.stringify(store.getState()).replace(/
return
} else if (route.enter == 'member' && !user) {
// 注册会员
params.context = { code: 403, redirect: '/' }
resolve(params)
return
}
if (route.loadData) {
// 服务端加载数据,并返回页面的状态
params.context = await route.loadData({ store, match, res, req, user })
}
// 获取路由dom
const Router = router.dom
const metaTagsInstance = MetaTagsServer()
await route.component.preload()
// html
params.html = ReactDOMServer.renderToString(
)
// 获取页面的meta,嵌套到模版中
params.meta = metaTagsInstance.renderToString()
router.get('/*', async ctx => {
const stream = new Readable();
const metaTagsInstance = MetaTagsServer();
const context = {};
const history = createMemoryHistory();
const store = createStore(history);
const css = new Set();
const insertCss = (...styles) => styles.forEach(style => css.add(style._getCss()));
const jsx = webExtractor.collectChunks(
);