diff --git a/src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js b/src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js index 92a6ab5..23768a8 100644 --- a/src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js +++ b/src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js @@ -30,7 +30,7 @@ document.body.style["-ms-transform"] = "scale(" + bounds.scale+ ")"; document.body.style["-ms-transform-origin"] = "top left"; html.style.overflowY = "auto"; - html.style.backgroundColor = "#2c3d59"; + html.style.backgroundColor = "#ffffff"; if (bounds.height * bounds.scale < html.clientHeight) { transformY = (html.clientHeight - bounds.height * bounds.scale) / 2; @@ -56,8 +56,8 @@ document.body.style.top = "0px"; html.style.backgroundColor = "#ffffff"; - window.scale = window.devicePixelRatio / scale; scale = 1; + window.scale = window.devicePixelRatio / scale; } // 获取缩放倍数,原模板宽高 @@ -83,13 +83,13 @@ } }); - var templateWidth = Math.round((right / (layoutRatio.x || 1)) || (freeRight / (freeLayoutRatio.x || 1))); - var templateHeight = Math.round((bottom / (layoutRatio.y || 1)) || (freeBottom / (freeLayoutRatio.y || 1))); + var templateWidth = (Math.round((right / (layoutRatio.x || 1)) || (freeRight / (freeLayoutRatio.x || 1)))) + 60; + var templateHeight = (Math.round((bottom / (layoutRatio.y || 1)) || (freeBottom / (freeLayoutRatio.y || 1)))) + 30; var scaleRatio = parseFloat((html.clientWidth / templateWidth).toFixed(1)); return { scale: scaleRatio, width: html.clientWidth / scaleRatio, - height: templateHeight + height: scaleRatio === 1 ? html.clientHeight : templateHeight }; } @@ -167,6 +167,8 @@ } window.addEventListener('resize', updateScale); + window.matchMedia && window.matchMedia('screen and (min-resolution: 2dppx)'). + addListener(selectHandler); } function restoreEnv() { @@ -177,6 +179,8 @@ } window.removeEventListener('resize', updateScale); + window.matchMedia && window.matchMedia('screen and (min-resolution: 2dppx)'). + removeListener(selectHandler); } function selectHandler () { diff --git a/src/main/resources/com/finebi/plugin/web/scripts/entry.js b/src/main/resources/com/finebi/plugin/web/scripts/entry.js index 92a6ab5..23768a8 100644 --- a/src/main/resources/com/finebi/plugin/web/scripts/entry.js +++ b/src/main/resources/com/finebi/plugin/web/scripts/entry.js @@ -30,7 +30,7 @@ document.body.style["-ms-transform"] = "scale(" + bounds.scale+ ")"; document.body.style["-ms-transform-origin"] = "top left"; html.style.overflowY = "auto"; - html.style.backgroundColor = "#2c3d59"; + html.style.backgroundColor = "#ffffff"; if (bounds.height * bounds.scale < html.clientHeight) { transformY = (html.clientHeight - bounds.height * bounds.scale) / 2; @@ -56,8 +56,8 @@ document.body.style.top = "0px"; html.style.backgroundColor = "#ffffff"; - window.scale = window.devicePixelRatio / scale; scale = 1; + window.scale = window.devicePixelRatio / scale; } // 获取缩放倍数,原模板宽高 @@ -83,13 +83,13 @@ } }); - var templateWidth = Math.round((right / (layoutRatio.x || 1)) || (freeRight / (freeLayoutRatio.x || 1))); - var templateHeight = Math.round((bottom / (layoutRatio.y || 1)) || (freeBottom / (freeLayoutRatio.y || 1))); + var templateWidth = (Math.round((right / (layoutRatio.x || 1)) || (freeRight / (freeLayoutRatio.x || 1)))) + 60; + var templateHeight = (Math.round((bottom / (layoutRatio.y || 1)) || (freeBottom / (freeLayoutRatio.y || 1)))) + 30; var scaleRatio = parseFloat((html.clientWidth / templateWidth).toFixed(1)); return { scale: scaleRatio, width: html.clientWidth / scaleRatio, - height: templateHeight + height: scaleRatio === 1 ? html.clientHeight : templateHeight }; } @@ -167,6 +167,8 @@ } window.addEventListener('resize', updateScale); + window.matchMedia && window.matchMedia('screen and (min-resolution: 2dppx)'). + addListener(selectHandler); } function restoreEnv() { @@ -177,6 +179,8 @@ } window.removeEventListener('resize', updateScale); + window.matchMedia && window.matchMedia('screen and (min-resolution: 2dppx)'). + removeListener(selectHandler); } function selectHandler () {