Browse Source

BI-48301 & BI-48300 & BI-48309:修复部分问题

feature/10.0
Fay 5 years ago
parent
commit
33bcdd9ffb
  1. 14
      src/main/resources/com/finebi/plugin/web/plugin.screen_adaptive.js
  2. 14
      src/main/resources/com/finebi/plugin/web/scripts/entry.js

14
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"] = "scale(" + bounds.scale+ ")";
document.body.style["-ms-transform-origin"] = "top left"; document.body.style["-ms-transform-origin"] = "top left";
html.style.overflowY = "auto"; html.style.overflowY = "auto";
html.style.backgroundColor = "#2c3d59"; html.style.backgroundColor = "#ffffff";
if (bounds.height * bounds.scale < html.clientHeight) { if (bounds.height * bounds.scale < html.clientHeight) {
transformY = (html.clientHeight - bounds.height * bounds.scale) / 2; transformY = (html.clientHeight - bounds.height * bounds.scale) / 2;
@ -56,8 +56,8 @@
document.body.style.top = "0px"; document.body.style.top = "0px";
html.style.backgroundColor = "#ffffff"; html.style.backgroundColor = "#ffffff";
window.scale = window.devicePixelRatio / scale;
scale = 1; scale = 1;
window.scale = window.devicePixelRatio / scale;
} }
// 获取缩放倍数,原模板宽高 // 获取缩放倍数,原模板宽高
@ -83,13 +83,13 @@
} }
}); });
var templateWidth = Math.round((right / (layoutRatio.x || 1)) || (freeRight / (freeLayoutRatio.x || 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))); var templateHeight = (Math.round((bottom / (layoutRatio.y || 1)) || (freeBottom / (freeLayoutRatio.y || 1)))) + 30;
var scaleRatio = parseFloat((html.clientWidth / templateWidth).toFixed(1)); var scaleRatio = parseFloat((html.clientWidth / templateWidth).toFixed(1));
return { return {
scale: scaleRatio, scale: scaleRatio,
width: html.clientWidth / scaleRatio, width: html.clientWidth / scaleRatio,
height: templateHeight height: scaleRatio === 1 ? html.clientHeight : templateHeight
}; };
} }
@ -167,6 +167,8 @@
} }
window.addEventListener('resize', updateScale); window.addEventListener('resize', updateScale);
window.matchMedia && window.matchMedia('screen and (min-resolution: 2dppx)').
addListener(selectHandler);
} }
function restoreEnv() { function restoreEnv() {
@ -177,6 +179,8 @@
} }
window.removeEventListener('resize', updateScale); window.removeEventListener('resize', updateScale);
window.matchMedia && window.matchMedia('screen and (min-resolution: 2dppx)').
removeListener(selectHandler);
} }
function selectHandler () { function selectHandler () {

14
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"] = "scale(" + bounds.scale+ ")";
document.body.style["-ms-transform-origin"] = "top left"; document.body.style["-ms-transform-origin"] = "top left";
html.style.overflowY = "auto"; html.style.overflowY = "auto";
html.style.backgroundColor = "#2c3d59"; html.style.backgroundColor = "#ffffff";
if (bounds.height * bounds.scale < html.clientHeight) { if (bounds.height * bounds.scale < html.clientHeight) {
transformY = (html.clientHeight - bounds.height * bounds.scale) / 2; transformY = (html.clientHeight - bounds.height * bounds.scale) / 2;
@ -56,8 +56,8 @@
document.body.style.top = "0px"; document.body.style.top = "0px";
html.style.backgroundColor = "#ffffff"; html.style.backgroundColor = "#ffffff";
window.scale = window.devicePixelRatio / scale;
scale = 1; scale = 1;
window.scale = window.devicePixelRatio / scale;
} }
// 获取缩放倍数,原模板宽高 // 获取缩放倍数,原模板宽高
@ -83,13 +83,13 @@
} }
}); });
var templateWidth = Math.round((right / (layoutRatio.x || 1)) || (freeRight / (freeLayoutRatio.x || 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))); var templateHeight = (Math.round((bottom / (layoutRatio.y || 1)) || (freeBottom / (freeLayoutRatio.y || 1)))) + 30;
var scaleRatio = parseFloat((html.clientWidth / templateWidth).toFixed(1)); var scaleRatio = parseFloat((html.clientWidth / templateWidth).toFixed(1));
return { return {
scale: scaleRatio, scale: scaleRatio,
width: html.clientWidth / scaleRatio, width: html.clientWidth / scaleRatio,
height: templateHeight height: scaleRatio === 1 ? html.clientHeight : templateHeight
}; };
} }
@ -167,6 +167,8 @@
} }
window.addEventListener('resize', updateScale); window.addEventListener('resize', updateScale);
window.matchMedia && window.matchMedia('screen and (min-resolution: 2dppx)').
addListener(selectHandler);
} }
function restoreEnv() { function restoreEnv() {
@ -177,6 +179,8 @@
} }
window.removeEventListener('resize', updateScale); window.removeEventListener('resize', updateScale);
window.matchMedia && window.matchMedia('screen and (min-resolution: 2dppx)').
removeListener(selectHandler);
} }
function selectHandler () { function selectHandler () {

Loading…
Cancel
Save