!209 优化OFD 移动端预览 页面不自适应

Merge pull request !209 from 高雄/N/A
pull/208/MERGE
kailing 2023-08-14 11:26:12 +00:00 committed by Gitee
commit 36672da026
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 12 additions and 2 deletions

View File

@ -4,7 +4,7 @@
<head> <head>
<meta charset="utf-8"/> <meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0"> <meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0">
<title>OFD</title> <title>${file.name}OFD</title>
<#include "*/commonHeader.ftl"> <#include "*/commonHeader.ftl">
<script src="js/base64.min.js" type="text/javascript"></script> <script src="js/base64.min.js" type="text/javascript"></script>
</head> </head>
@ -22,7 +22,11 @@
if (!url.startsWith(baseUrl)) { if (!url.startsWith(baseUrl)) {
url = baseUrl + 'getCorsFile?urlPath=' + encodeURIComponent(Base64.encode(url)); url = baseUrl + 'getCorsFile?urlPath=' + encodeURIComponent(Base64.encode(url));
} }
if(IsPhone()){
document.getElementsByTagName('iframe')[0].src = "${baseUrl}ofd/index.html?file=" + encodeURIComponent(url)+"&scale=width";
}else{
document.getElementsByTagName('iframe')[0].src = "${baseUrl}ofd/index.html?file="+ encodeURIComponent(url)+""; document.getElementsByTagName('iframe')[0].src = "${baseUrl}ofd/index.html?file="+ encodeURIComponent(url)+"";
}
document.getElementsByTagName('iframe')[0].height = document.documentElement.clientHeight - 10; document.getElementsByTagName('iframe')[0].height = document.documentElement.clientHeight - 10;
/** /**
* *
@ -32,7 +36,13 @@
fm.height = window.document.documentElement.clientHeight - 10; fm.height = window.document.documentElement.clientHeight - 10;
} }
function IsPhone() {
var info = navigator.userAgent;
//通过正则表达式的test方法判断是否包含“Mobile”字符串
var isPhone = /mobile/i.test(info);
//如果包含“Mobile”是手机设备则返回true
return isPhone;
}
/*初始化水印*/ /*初始化水印*/
window.onload = function () { window.onload = function () {
initWaterMark(); initWaterMark();