Przeglądaj źródła

图片预览可在viewjs中大图预览&翻页

陈精华 6 lat temu
rodzic
commit
a49ee9d726

+ 7 - 2
jodconverter-web/src/main/java/cn/keking/service/impl/OfficeFilePreviewImpl.java

@@ -41,6 +41,7 @@ public class OfficeFilePreviewImpl implements FilePreview {
 
     public static final String OFFICE_PREVIEW_TYPE_PDF = "pdf";
     public static final String OFFICE_PREVIEW_TYPE_IMAGE = "image";
+    public static final String OFFICE_PREVIEW_TYPE_ALLIMAGES = "allImages";
 
     @Override
     public String filePreviewHandle(String url, Model model) {
@@ -78,7 +79,7 @@ public class OfficeFilePreviewImpl implements FilePreview {
                 fileUtils.addConvertedFile(pdfName, fileUtils.getRelativePath(outFilePath));
             }
         }
-        if (OFFICE_PREVIEW_TYPE_IMAGE.equals(officePreviewType)) {
+        if (OFFICE_PREVIEW_TYPE_IMAGE.equals(officePreviewType) || OFFICE_PREVIEW_TYPE_ALLIMAGES.equals(officePreviewType)) {
             List<String> imageUrls = pdfUtils.pdf2jpg(outFilePath, pdfName, url);
             if (imageUrls == null || imageUrls.size() < 1) {
                 model.addAttribute("msg", "office转图片异常,请联系管理员");
@@ -87,7 +88,11 @@ public class OfficeFilePreviewImpl implements FilePreview {
             }
             model.addAttribute("imgurls", imageUrls);
             model.addAttribute("currentUrl", imageUrls.get(0));
-            return "officePicture";
+            if (OFFICE_PREVIEW_TYPE_IMAGE.equals(officePreviewType)) {
+                return "officePicture";
+            } else {
+                return "picture";
+            }
         }
         model.addAttribute("pdfUrl", pdfName);
         return isHtml ? "html" : "pdf";

+ 5 - 5
jodconverter-web/src/main/resources/web/officePicture.ftl

@@ -18,20 +18,20 @@
 <div class="container">
     <#list imgurls as img>
         <div class="img-area">
-            <img class="my-photo" alt="loading" data-src="${img}" src="images/loading.gif">
+            <img class="my-photo" alt="loading" title="查看大图" style="cursor: pointer;" data-src="${img}" src="images/loading.gif" onclick="changePreviewType('allImages')">
         </div>
     </#list>
 </div>
-<img src="images/left.png" style="position: fixed; cursor: pointer; top: 40%; left: 50px; z-index: 999;" alt="PDF预览" onclick="goForPdf()"/>
+<img src="images/right.png" style="position: fixed; cursor: pointer; top: 40%; right: 70px; z-index: 999;" alt="使用PDF预览" title="使用PDF预览" onclick="changePreviewType('pdf')"/>
 <script>
     window.onload=checkImgs;
     window.onscroll = throttle(checkImgs);
-    function goForPdf() {
+    function changePreviewType(previewType) {
         var url = window.location.href;
         if (url.indexOf("officePreviewType=image") != -1) {
-            url = url.replace("officePreviewType=image", "officePreviewType=pdf");
+            url = url.replace("officePreviewType=image", "officePreviewType="+previewType);
         } else {
-            url = url + "&officePreviewType=pdf";
+            url = url + "&officePreviewType="+previewType;
         }
         window.location.href=url;
     }

+ 1 - 1
jodconverter-web/src/main/resources/web/pdf.ftl

@@ -18,7 +18,7 @@
     </#if>
     <iframe src="/pdfjs/web/viewer.html?file=${finalUrl}" width="100%" frameborder="0"></iframe>
 
-    <img src="images/right.png" style="position: fixed; cursor: pointer; top: 40%; right: 50px; z-index: 999;" alt="图片预览" onclick="goForImage()"/>
+    <img src="images/left.png" style="position: fixed; cursor: pointer; top: 40%; right: 70px; z-index: 999;" alt="使用图片预览" title="使用图片预览" onclick="goForImage()"/>
 
 </body>
 <script type="text/javascript">