提交 7c012420 编写于 作者: Q qiang

feat: App、H5 端 root-font-size 改为与微信小程序一致

上级 56530ddf
......@@ -4,10 +4,7 @@
<head>
<meta charset="UTF-8" />
<script>
var __UniViewStartTime__ = Date.now();
document.addEventListener('DOMContentLoaded', function() {
document.documentElement.style.fontSize = document.documentElement.clientWidth / 20 + 'px'
})
var __UniViewStartTime__ = Date.now();
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)'))
document.write(
......@@ -19,10 +16,10 @@
</head>
<body>
<div id="app"></div>
<script src="__uniappes6.js"></script>
<script src="view.umd.min.js"></script>
<div id="app"></div>
<script src="__uniappes6.js"></script>
<script src="view.umd.min.js"></script>
<script src="app-view.js"></script>
</body>
</html>
</html>
......@@ -4,10 +4,7 @@
<head>
<meta charset="UTF-8" />
<script>
var __UniViewStartTime__ = Date.now();
document.addEventListener('DOMContentLoaded', function() {
document.documentElement.style.fontSize = document.documentElement.clientWidth / 20 + 'px'
})
var __UniViewStartTime__ = Date.now();
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)'))
document.write(
......@@ -19,10 +16,10 @@
</head>
<body>
<div id="app"></div>
<script src="__uniappes6.js"></script>
<script src="view.umd.min.js"></script>
<div id="app"></div>
<script src="__uniappes6.js"></script>
<script src="view.umd.min.js"></script>
<script src="app-view.js"></script>
</body>
</html>
</html>
import Vue from 'vue'
import {
import {
VD_SYNC,
PAGE_CREATE,
MOUNTED_DATA,
......@@ -34,8 +34,6 @@ const handleData = {
const [pageId, pagePath, pageOptions] = data
document.title = `${pagePath}[${pageId}]`
updateRootFontSize()
// 设置当前页面伪对象,方便其他地方使用 getCurrentPages 获取当前页面 id,route
setCurrentPage(pageId, pagePath)
// 通知页面创建,根据当前页面配置信息,初始化部分事件
......@@ -88,20 +86,7 @@ function updateView () {
)
}
function updateRootFontSize () {
// 页面存在横竖屏切换时,预加载的 webview 的 fontSize 需要再次校正一下
const oldFontSize = document.documentElement.style.fontSize
const newFontSize = document.documentElement.clientWidth / 20 + 'px'
if (oldFontSize !== newFontSize) {
document.documentElement.style.fontSize = newFontSize
}
}
window.addEventListener('resize', () => {
// TODO 与之前逻辑保持一致,仅当前 webview 未被使用时,校准 fontSize,后续考虑动态旋转,调整rootfontSize
if (!getCurrentPages().length) {
updateRootFontSize()
}
updateView()
})
......@@ -173,4 +158,4 @@ export function initData (Vue) {
}
}
})
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册