From 50b0824b5a08242fae055021bd42a58029365dab Mon Sep 17 00:00:00 2001 From: shaoyongjun Date: Thu, 31 Oct 2024 16:11:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9B=9E=E8=BD=A6=E8=B7=B3=E5=88=B0?= =?UTF-8?q?=E5=A4=9A=E8=A1=8C=E4=B9=8B=E5=90=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/js/lib/biz/MyBiz.js | 21 ++++++++++++++++++--- static/js/lib/common/MyUtils.js | 14 ++++++++------ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/static/js/lib/biz/MyBiz.js b/static/js/lib/biz/MyBiz.js index 66b20a9..6db02fa 100644 --- a/static/js/lib/biz/MyBiz.js +++ b/static/js/lib/biz/MyBiz.js @@ -163,7 +163,21 @@ export class MyBiz { let rowNo = 0; let emptyRowNoList = window.myEdit.ctx.MyDocMap.get("emptyRowNoList"); console.log(emptyRowNoList); - if (emptyRowNoList === undefined || emptyRowNoList === null) { + let empListIsEmpty = (emptyRowNoList === undefined || emptyRowNoList === null || emptyRowNoList.length <= 0); + if (!empListIsEmpty) { + let tmpArr = []; + for (let i = 0; i < emptyRowNoList.length; i++) { + let tmpNo = emptyRowNoList[i]; + if (window.myEdit.ctx.getMapItem(tmpNo).getHidden()) { + tmpArr.push(emptyRowNoList[i]); + } + } + window.myEdit.ctx.MyDocMap.set("emptyRowNoList", tmpArr); + empListIsEmpty = tmpArr.length <= 0; + emptyRowNoList = tmpArr + } + + if (empListIsEmpty) { rowNo = window.myEdit.ctx.incrementNumThenReturn(); //添加新元素 let newParagraph = document.createElement("p") @@ -213,7 +227,8 @@ export class MyBiz { return } - mapItem.setSource(curP.innerText) + mapItem.setSource(curP.innerText); + mapItem.setHidden(false); // console.log("curPTx: ", curP.innerText, "MyDocMap : ", utils.MyDocMap) //显示用户的输入内容 @@ -305,7 +320,7 @@ export class MyBiz { mapNode.getStyle().setPreStyle("ol", preContent) //clean - let historyContent = curP.innerHTML.replace(preContent+".", ""); + let historyContent = curP.innerHTML.replace(preContent + ".", ""); mapNode.setSource(curP.innerText) //todo curP.setAttribute("style", "padding-left: 1rem;") diff --git a/static/js/lib/common/MyUtils.js b/static/js/lib/common/MyUtils.js index d5816d7..4ab01da 100644 --- a/static/js/lib/common/MyUtils.js +++ b/static/js/lib/common/MyUtils.js @@ -297,14 +297,16 @@ export class MyUtils { RefreshBodyFrontSize() { let dpr = window.devicePixelRatio || 1;//当前设置下 物理像素和虚拟像素的比值 let defaultFrontSize = window.myEdit.ctx.bodyFrontSize; - if(!dpr){ - let isAndroid = win.navigator.appVersion.match(/android/gi); - let isIPhone = win.navigator.appVersion.match(/iphone/gi); - if (isIPhone) {//只对iPhone做了处理!!!! - // iOS下,对于2和3的屏,用2倍的方案,其余的用1倍方案 + if (!dpr) { + //devicePixelRatio这个属性是可以获取到设备的dpr + let devicePixelRatio = win.devicePixelRatio; + //判断dpr是否为整数 + let isRegularDpr = devicePixelRatio.toString().match(/^[1-9]\d*$/g) + if (isRegularDpr) { + // 对于是整数的dpr,对dpr进行操作 if (devicePixelRatio >= 3 && (!dpr || dpr >= 3)) { dpr = 3; - } else if (devicePixelRatio >= 2 && (!dpr || dpr >= 2)){ + } else if (devicePixelRatio >= 2 && (!dpr || dpr >= 2)) { dpr = 2; } else { dpr = 1;