to:sync
This commit is contained in:
parent
57cdbdba50
commit
b3ec0d8073
@ -34,7 +34,13 @@ define(function (require, exports, module) {
|
|||||||
|
|
||||||
//set 1rem = curClientW / designWidth (支持响应式)
|
//set 1rem = curClientW / designWidth (支持响应式)
|
||||||
let nowFrontSize = curClientW / designWidth + 'px';
|
let nowFrontSize = curClientW / designWidth + 'px';
|
||||||
curDoc.style.fontSize = nowFrontSize;
|
if (ctx.isTablet || ctx.isMobile || ctx.isIOS || ctx.isAndroid) {
|
||||||
|
let dpr = getDpr();
|
||||||
|
curDoc.style.fontSize = dpr * nowFrontSize;
|
||||||
|
} else {
|
||||||
|
curDoc.style.fontSize = nowFrontSize;
|
||||||
|
}
|
||||||
|
|
||||||
console.log("curClientW :", curClientW, "designWidth: ", designWidth, "-> ", nowFrontSize);
|
console.log("curClientW :", curClientW, "designWidth: ", designWidth, "-> ", nowFrontSize);
|
||||||
let testDiv = document.getElementById("testDevice");
|
let testDiv = document.getElementById("testDevice");
|
||||||
testDiv.innerText += "\ncurClientW: " + curClientW;
|
testDiv.innerText += "\ncurClientW: " + curClientW;
|
||||||
@ -54,21 +60,12 @@ define(function (require, exports, module) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDpr() {
|
||||||
function refreshEditFrontSize() {
|
|
||||||
const ctx = require("../../common/ctx");
|
|
||||||
let curClientW = ctx.getScreenWidth();
|
|
||||||
if (!curClientW) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
//字体尺寸 https://www.shejidaren.com/zihao-daxiao-sheji-bilv.html
|
|
||||||
//12~72 px 建议最大字体是48px
|
|
||||||
|
|
||||||
//获取屏幕像素密度
|
//获取屏幕像素密度
|
||||||
let dpr = window.devicePixelRatio || 1;//当前设置下 物理像素和虚拟像素的比值
|
let dpr = window.devicePixelRatio || 1;//当前设置下 物理像素和虚拟像素的比值
|
||||||
if (!dpr) {
|
if (!dpr) {
|
||||||
//devicePixelRatio这个属性是可以获取到设备的dpr
|
//devicePixelRatio这个属性是可以获取到设备的dpr
|
||||||
let devicePixelRatio = win?.devicePixelRatio;
|
let devicePixelRatio = window?.devicePixelRatio;
|
||||||
//判断dpr是否为整数
|
//判断dpr是否为整数
|
||||||
let isRegularDpr = devicePixelRatio.toString().match(/^[1-9]\d*$/g)
|
let isRegularDpr = devicePixelRatio.toString().match(/^[1-9]\d*$/g)
|
||||||
if (isRegularDpr) {
|
if (isRegularDpr) {
|
||||||
@ -85,14 +82,21 @@ define(function (require, exports, module) {
|
|||||||
dpr = 1;
|
dpr = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return dpr;
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshEditFrontSize() {
|
||||||
|
const ctx = require("../../common/ctx");
|
||||||
|
let curClientW = ctx.getScreenWidth();
|
||||||
|
if (!curClientW) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//字体尺寸 https://www.shejidaren.com/zihao-daxiao-sheji-bilv.html
|
||||||
|
//12~72 px 建议最大字体是48px
|
||||||
|
|
||||||
|
let dpr = getDpr();
|
||||||
|
|
||||||
let myEditFrontSize = document.getElementById("myEdit_main");
|
let myEditFrontSize = document.getElementById("myEdit_main");
|
||||||
// if (document.documentElement.clientWidth <= 720) {
|
|
||||||
// myEditFrontSize.style.fontSize = (window.myEdit.ctx.editFrontSize + 6) + 'px';
|
|
||||||
// } else {
|
|
||||||
// myEditFrontSize.style.fontSize = window.myEdit.ctx.editFrontSize * dpr + 'px';
|
|
||||||
// }
|
|
||||||
// myEditFrontSize.style.fontSize = window.myEdit.ctx.editFrontSize * dpr + 'px';
|
|
||||||
if (ctx.isTablet) {
|
if (ctx.isTablet) {
|
||||||
myEditFrontSize.style.fontSize = ctx.editFrontSize * dpr + 'px';
|
myEditFrontSize.style.fontSize = ctx.editFrontSize * dpr + 'px';
|
||||||
} else {
|
} else {
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
<header>
|
<header>
|
||||||
<!-- 顶部 -->
|
<!-- 顶部 -->
|
||||||
<div id="head_top" style="font-size: 16rem">
|
<div id="head_top" style="font-size: 12rem">
|
||||||
<div style="width:20%">测试</div>
|
<div style="width:20%">测试</div>
|
||||||
<div style="width: 60%"></div>
|
<div style="width: 60%"></div>
|
||||||
<div style="width:20%">
|
<div style="width:20%">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user