-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathHtml.js
More file actions
88 lines (81 loc) · 2.91 KB
/
Copy pathHtml.js
File metadata and controls
88 lines (81 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// @flow
import * as React from "react";
import Head from "react-helmet";
export default ({ App, render }: PhenomicHtmlPropsType) => {
// if needed, you can know if you are in development or in static rendering
// const isDev = process.env.PHENOMIC_ENV === "development"
const { Main, State, Script, Style } = render(<App />);
const helmet = Head.renderStatic();
return (
// $FlowFixMe helmet is fine
<html {...helmet.htmlAttributes.toComponent()}>
<head>
{helmet.meta.toComponent()}
{helmet.title.toComponent()}
{helmet.base.toComponent()}
<Style />
{helmet.link.toComponent()}
{helmet.style.toComponent()}
{helmet.script.toComponent()}
{helmet.noscript.toComponent()}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossOrigin="anonymous"/>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossOrigin="anonymous"></script>
{/* <script
dangerouslySetInnerHTML={{
__html: `
(function(designWidth, maxWidth) {
var doc = document,
win = window,
docEl = doc.documentElement,
remStyle = document.createElement("style"),
tid;
function refreshRem() {
var width = docEl.getBoundingClientRect().width;
maxWidth = maxWidth || 540;
width>maxWidth && (width=maxWidth);
var rem = width * 10 / designWidth;
console.log('rem: '+ rem)
remStyle.innerHTML = 'html{font-size: ' + rem + 'px !important; }';
}
if (docEl.firstElementChild) {
docEl.firstElementChild.appendChild(remStyle);
} else {
var wrap = doc.createElement("div");
wrap.appendChild(remStyle);
doc.write(wrap.innerHTML);
wrap = null;
}
//要等 wiewport 设置好后才能执行 refreshRem,不然 refreshRem 会执行2次;
refreshRem();
win.addEventListener("resize", function() {
clearTimeout(tid); //防止执行两次
tid = setTimeout(refreshRem, 300);
}, false);
win.addEventListener("pageshow", function(e) {
if (e.persisted) { // 浏览器后退的时候重新计算
clearTimeout(tid);
tid = setTimeout(refreshRem, 300);
}
}, false);
if (doc.readyState === "complete") {
doc.body.style.fontSize = "16px";
} else {
doc.addEventListener("DOMContentLoaded", function (e) {
doc.body.style.fontSize = "16px";
}, false);
}
})(1920, 1920);
`
}}
/> */}
</head>
{/* // $FlowFixMe it works on my machine */}
<body {...helmet.bodyAttributes.toComponent()}>
<Main />
<State />
<Script />
</body>
</html>
);
};