1,优化URL报错,2,更新OFD组件 3,美化Excel 4,文本方法关闭字节流 5,新增多种类型文件预览 (#419)
1,优化URL报错
2,更新OFD组件
3,美化Excel
4,文本方法关闭字节流
5,新增xmind、eml、epub、"obj", "3ds", "stl", "ply", "off", "3dm", "fbx", "dae", "wrl", "3mf", "ifc","glb","o3dv","gltf","stp","bim","fcstd","step","iges","brep"格式
Co-authored-by: gaoxiongzaq <admin@cxcp.com>
2022-12-28 10:17:06 +08:00
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
|
|
|
|
|
|
|
<html lang="en">
|
|
|
|
|
|
<head>
|
|
|
|
|
|
<title>${file.name}文件预览</title>
|
|
|
|
|
|
<meta charset="utf-8" />
|
|
|
|
|
|
<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0">
|
|
|
|
|
|
<#include "*/commonHeader.ftl">
|
2023-08-14 03:34:44 +00:00
|
|
|
|
<script src="js/base64.min.js" type="text/javascript"></script>
|
1,优化URL报错,2,更新OFD组件 3,美化Excel 4,文本方法关闭字节流 5,新增多种类型文件预览 (#419)
1,优化URL报错
2,更新OFD组件
3,美化Excel
4,文本方法关闭字节流
5,新增xmind、eml、epub、"obj", "3ds", "stl", "ply", "off", "3dm", "fbx", "dae", "wrl", "3mf", "ifc","glb","o3dv","gltf","stp","bim","fcstd","step","iges","brep"格式
Co-authored-by: gaoxiongzaq <admin@cxcp.com>
2022-12-28 10:17:06 +08:00
|
|
|
|
<script src="js/jszip.min.js"></script>
|
2023-08-14 03:34:44 +00:00
|
|
|
|
<script src="epub/epub.js"></script>
|
1,优化URL报错,2,更新OFD组件 3,美化Excel 4,文本方法关闭字节流 5,新增多种类型文件预览 (#419)
1,优化URL报错
2,更新OFD组件
3,美化Excel
4,文本方法关闭字节流
5,新增xmind、eml、epub、"obj", "3ds", "stl", "ply", "off", "3dm", "fbx", "dae", "wrl", "3mf", "ifc","glb","o3dv","gltf","stp","bim","fcstd","step","iges","brep"格式
Co-authored-by: gaoxiongzaq <admin@cxcp.com>
2022-12-28 10:17:06 +08:00
|
|
|
|
<link rel="stylesheet" type="text/css" href="epub/examples.css">
|
|
|
|
|
|
</head>
|
|
|
|
|
|
<#if currentUrl?contains("http://") || currentUrl?contains("https://") || currentUrl?contains("file://")>
|
|
|
|
|
|
<#assign finalUrl="${currentUrl}">
|
|
|
|
|
|
<#elseif currentUrl?contains("ftp://") >
|
|
|
|
|
|
<#assign finalUrl="${currentUrl}">
|
|
|
|
|
|
<#else>
|
|
|
|
|
|
<#assign finalUrl="${baseUrl}${currentUrl}">
|
|
|
|
|
|
</#if>
|
|
|
|
|
|
<body>
|
|
|
|
|
|
<select id="toc"></select>
|
|
|
|
|
|
<div id="viewer" class="scrolled"></div>
|
|
|
|
|
|
<div id="prev" class="arrow">‹</div>
|
|
|
|
|
|
<div id="next" class="arrow">›</div>
|
|
|
|
|
|
</body>
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
var url = '${finalUrl}';
|
|
|
|
|
|
var baseUrl = '${baseUrl}'.endsWith('/') ? '${baseUrl}' : '${baseUrl}' + '/';
|
|
|
|
|
|
if (!url.startsWith(baseUrl)) {
|
|
|
|
|
|
url = baseUrl + 'getCorsFile?urlPath=' + encodeURIComponent(Base64.encode(url));
|
|
|
|
|
|
}
|
2023-08-03 07:16:00 +00:00
|
|
|
|
|
|
|
|
|
|
function blobToArrayBuffer(blob) {
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
|
const reader = new FileReader();
|
|
|
|
|
|
reader.onerror = reject;
|
|
|
|
|
|
reader.onload = () => {
|
|
|
|
|
|
resolve(reader.result);
|
|
|
|
|
|
};
|
|
|
|
|
|
reader.readAsArrayBuffer(blob);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
let xhr = new XMLHttpRequest();
|
|
|
|
|
|
xhr.open('GET',url); //文件所在地址
|
|
|
|
|
|
xhr.responseType = 'blob';
|
|
|
|
|
|
xhr.onload = () => {
|
|
|
|
|
|
var currentSectionIndex = 100;
|
|
|
|
|
|
var book = ePub();
|
|
|
|
|
|
let content = xhr.response;
|
|
|
|
|
|
let blob = new Blob([content]);
|
|
|
|
|
|
var bookData = blobToArrayBuffer(blob);
|
|
|
|
|
|
book.open(bookData, "binary");
|
1,优化URL报错,2,更新OFD组件 3,美化Excel 4,文本方法关闭字节流 5,新增多种类型文件预览 (#419)
1,优化URL报错
2,更新OFD组件
3,美化Excel
4,文本方法关闭字节流
5,新增xmind、eml、epub、"obj", "3ds", "stl", "ply", "off", "3dm", "fbx", "dae", "wrl", "3mf", "ifc","glb","o3dv","gltf","stp","bim","fcstd","step","iges","brep"格式
Co-authored-by: gaoxiongzaq <admin@cxcp.com>
2022-12-28 10:17:06 +08:00
|
|
|
|
var rendition = book.renderTo("viewer", {
|
|
|
|
|
|
flow: "scrolled-doc",
|
2023-08-03 07:16:00 +00:00
|
|
|
|
width: "100%",
|
|
|
|
|
|
allowScriptedContent: true
|
1,优化URL报错,2,更新OFD组件 3,美化Excel 4,文本方法关闭字节流 5,新增多种类型文件预览 (#419)
1,优化URL报错
2,更新OFD组件
3,美化Excel
4,文本方法关闭字节流
5,新增xmind、eml、epub、"obj", "3ds", "stl", "ply", "off", "3dm", "fbx", "dae", "wrl", "3mf", "ifc","glb","o3dv","gltf","stp","bim","fcstd","step","iges","brep"格式
Co-authored-by: gaoxiongzaq <admin@cxcp.com>
2022-12-28 10:17:06 +08:00
|
|
|
|
// height: 600
|
|
|
|
|
|
});
|
2023-08-03 07:16:00 +00:00
|
|
|
|
|
|
|
|
|
|
var displayed = rendition.display();
|
1,优化URL报错,2,更新OFD组件 3,美化Excel 4,文本方法关闭字节流 5,新增多种类型文件预览 (#419)
1,优化URL报错
2,更新OFD组件
3,美化Excel
4,文本方法关闭字节流
5,新增xmind、eml、epub、"obj", "3ds", "stl", "ply", "off", "3dm", "fbx", "dae", "wrl", "3mf", "ifc","glb","o3dv","gltf","stp","bim","fcstd","step","iges","brep"格式
Co-authored-by: gaoxiongzaq <admin@cxcp.com>
2022-12-28 10:17:06 +08:00
|
|
|
|
var params = URLSearchParams && new URLSearchParams(document.location.search.substring(1));
|
|
|
|
|
|
var currentSectionIndex = (params && params.get("loc")) ? params.get("loc") : undefined;
|
|
|
|
|
|
rendition.display(currentSectionIndex);
|
|
|
|
|
|
var next = document.getElementById("next");
|
|
|
|
|
|
next.addEventListener("click", function(e){
|
|
|
|
|
|
rendition.next();
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
}, false);
|
|
|
|
|
|
|
|
|
|
|
|
var prev = document.getElementById("prev");
|
|
|
|
|
|
prev.addEventListener("click", function(e){
|
|
|
|
|
|
rendition.prev();
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
}, false);
|
|
|
|
|
|
|
|
|
|
|
|
rendition.on("rendered", function(section){
|
|
|
|
|
|
var nextSection = section.next();
|
|
|
|
|
|
var prevSection = section.prev();
|
|
|
|
|
|
|
|
|
|
|
|
if(nextSection) {
|
|
|
|
|
|
nextNav = book.navigation.get(nextSection.href);
|
|
|
|
|
|
|
|
|
|
|
|
if(nextNav) {
|
|
|
|
|
|
nextLabel = nextNav.label;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
nextLabel = "next";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
next.textContent = " »";
|
|
|
|
|
|
} else {
|
|
|
|
|
|
next.textContent = "";
|
|
|
|
|
|
}
|
|
|
|
|
|
if(prevSection) {
|
|
|
|
|
|
prevNav = book.navigation.get(prevSection.href);
|
|
|
|
|
|
|
|
|
|
|
|
if(prevNav) {
|
|
|
|
|
|
prevLabel = prevNav.label;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
prevLabel = "previous";
|
|
|
|
|
|
}
|
|
|
|
|
|
prev.textContent = "« " ;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
prev.textContent = "";
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
rendition.on("rendered", function(section){
|
|
|
|
|
|
var current = book.navigation && book.navigation.get(section.href);
|
|
|
|
|
|
|
|
|
|
|
|
if (current) {
|
|
|
|
|
|
var $select = document.getElementById("toc");
|
|
|
|
|
|
var $selected = $select.querySelector("option[selected]");
|
|
|
|
|
|
if ($selected) {
|
|
|
|
|
|
$selected.removeAttribute("selected");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var $options = $select.querySelectorAll("option");
|
|
|
|
|
|
for (var i = 0; i < $options.length; ++i) {
|
|
|
|
|
|
let selected = $options[i].getAttribute("ref") === current.href;
|
|
|
|
|
|
if (selected) {
|
|
|
|
|
|
$options[i].setAttribute("selected", "");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
book.loaded.navigation.then(function(toc){
|
|
|
|
|
|
var $select = document.getElementById("toc"),
|
|
|
|
|
|
docfrag = document.createDocumentFragment();
|
|
|
|
|
|
|
|
|
|
|
|
toc.forEach(function(chapter) {
|
|
|
|
|
|
var option = document.createElement("option");
|
|
|
|
|
|
option.textContent = chapter.label;
|
|
|
|
|
|
option.setAttribute("ref", chapter.href);
|
|
|
|
|
|
|
|
|
|
|
|
docfrag.appendChild(option);
|
|
|
|
|
|
});
|
|
|
|
|
|
$select.appendChild(docfrag);
|
|
|
|
|
|
$select.onchange = function(){
|
2023-08-03 07:16:00 +00:00
|
|
|
|
var index = $select.selectedIndex,
|
|
|
|
|
|
url = $select.options[index].getAttribute("ref");
|
|
|
|
|
|
rendition.display(url);
|
|
|
|
|
|
return false;
|
1,优化URL报错,2,更新OFD组件 3,美化Excel 4,文本方法关闭字节流 5,新增多种类型文件预览 (#419)
1,优化URL报错
2,更新OFD组件
3,美化Excel
4,文本方法关闭字节流
5,新增xmind、eml、epub、"obj", "3ds", "stl", "ply", "off", "3dm", "fbx", "dae", "wrl", "3mf", "ifc","glb","o3dv","gltf","stp","bim","fcstd","step","iges","brep"格式
Co-authored-by: gaoxiongzaq <admin@cxcp.com>
2022-12-28 10:17:06 +08:00
|
|
|
|
};
|
|
|
|
|
|
});
|
2023-08-03 07:16:00 +00:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
xhr.send();
|
|
|
|
|
|
|
|
|
|
|
|
|
1,优化URL报错,2,更新OFD组件 3,美化Excel 4,文本方法关闭字节流 5,新增多种类型文件预览 (#419)
1,优化URL报错
2,更新OFD组件
3,美化Excel
4,文本方法关闭字节流
5,新增xmind、eml、epub、"obj", "3ds", "stl", "ply", "off", "3dm", "fbx", "dae", "wrl", "3mf", "ifc","glb","o3dv","gltf","stp","bim","fcstd","step","iges","brep"格式
Co-authored-by: gaoxiongzaq <admin@cxcp.com>
2022-12-28 10:17:06 +08:00
|
|
|
|
/*初始化水印*/
|
|
|
|
|
|
if (!!window.ActiveXObject || "ActiveXObject" in window)
|
|
|
|
|
|
{
|
|
|
|
|
|
}else{
|
|
|
|
|
|
initWaterMark();
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
</html>
|