/* eslint-disable no-use-before-define */ // 待渲染完整的页面 // 这里的页面建议以最简形式,如果需要复杂的头设定使用react-helmet组件 /** * @function 生成同构直出的HTML界面模板 * @param html * @param initialState * @param scripts * @param styles * @return {string} */ export default (html, initialState = {}, scripts = [], styles = []) => { return ` ${styleMapper(styles)}
${html}
${scriptMapper(scripts)} `; }; /** * @function 将输入的样式文件路径转化为Link标签 * @param styles * @return {*} */ const styleMapper = styles => { return styles.map(style => { return ``; }); }; const scriptMapper = scripts => { const scriptTags = []; for (let i = 0; i < scripts.length; i = i + 1) { scriptTags.push(``); } return scriptTags; };