diff --git a/server/src/main/java/cn/keking/model/FileType.java b/server/src/main/java/cn/keking/model/FileType.java index f3255e2a..48033312 100644 --- a/server/src/main/java/cn/keking/model/FileType.java +++ b/server/src/main/java/cn/keking/model/FileType.java @@ -24,12 +24,10 @@ public enum FileType { FLV("flvFilePreviewImpl"), CAD("cadFilePreviewImpl"), TIFF("tiffFilePreviewImpl"), - PPT("pptFilePreviewImpl"), OFD("ofdFilePreviewImpl"); - private static final String[] OFFICE_TYPES = {"docx", "wps", "doc", "xls", "xlsx"}; - private static final String[] PPT_TYPES = {"ppt", "pptx"}; + private static final String[] OFFICE_TYPES = {"docx", "wps", "doc", "xls", "xlsx", "ppt", "pptx"}; private static final String[] PICTURE_TYPES = {"jpg", "jpeg", "png", "gif", "bmp", "ico", "raw"}; private static final String[] ARCHIVE_TYPES = {"rar", "zip", "jar", "7-zip", "tar", "gzip", "7z"}; private static final String[] TIFF_TYPES = {"tif", "tiff"}; @@ -68,9 +66,6 @@ public enum FileType { for (String ofd : OFD_TYPES) { FILE_TYPE_MAPPER.put(ofd, FileType.OFD); } - for (String ppt : PPT_TYPES) { - FILE_TYPE_MAPPER.put(ppt, FileType.PPT); - } FILE_TYPE_MAPPER.put("md", FileType.MARKDOWN); FILE_TYPE_MAPPER.put("xml", FileType.XML); FILE_TYPE_MAPPER.put("pdf", FileType.PDF); diff --git a/server/src/main/java/cn/keking/service/FileConvertQueueTask.java b/server/src/main/java/cn/keking/service/FileConvertQueueTask.java index dac039e2..e5d62485 100644 --- a/server/src/main/java/cn/keking/service/FileConvertQueueTask.java +++ b/server/src/main/java/cn/keking/service/FileConvertQueueTask.java @@ -81,7 +81,7 @@ public class FileConvertQueueTask { } public boolean isNeedConvert(FileType fileType) { - return fileType.equals(FileType.COMPRESS) || fileType.equals(FileType.OFFICE) || fileType.equals(FileType.CAD) || fileType.equals(FileType.PPT); + return fileType.equals(FileType.COMPRESS) || fileType.equals(FileType.OFFICE) || fileType.equals(FileType.CAD); } } diff --git a/server/src/main/java/cn/keking/service/impl/OfficeFilePreviewImpl.java b/server/src/main/java/cn/keking/service/impl/OfficeFilePreviewImpl.java index dc6977f5..1853a322 100644 --- a/server/src/main/java/cn/keking/service/impl/OfficeFilePreviewImpl.java +++ b/server/src/main/java/cn/keking/service/impl/OfficeFilePreviewImpl.java @@ -73,6 +73,8 @@ public class OfficeFilePreviewImpl implements FilePreview { } static String getPreviewType(Model model, FileAttribute fileAttribute, String officePreviewType, String baseUrl, String pdfName, String outFilePath, FileHandlerService fileHandlerService, String officePreviewTypeImage, OtherFilePreviewImpl otherFilePreview) { + String suffix = fileAttribute.getSuffix(); + boolean isPPT = suffix.equalsIgnoreCase("ppt") || suffix.equalsIgnoreCase("pptx"); List imageUrls = fileHandlerService.pdf2jpg(outFilePath, pdfName, baseUrl); if (imageUrls == null || imageUrls.size() < 1) { return otherFilePreview.notSupportedFile(model, fileAttribute, "office转图片异常,请联系管理员"); @@ -80,7 +82,8 @@ public class OfficeFilePreviewImpl implements FilePreview { model.addAttribute("imgurls", imageUrls); model.addAttribute("currentUrl", imageUrls.get(0)); if (officePreviewTypeImage.equals(officePreviewType)) { - return OFFICE_PICTURE_FILE_PREVIEW_PAGE; + // PPT 图片模式使用专用预览页面 + return (isPPT ? PPT_FILE_PREVIEW_PAGE : OFFICE_PICTURE_FILE_PREVIEW_PAGE); } else { return PICTURE_FILE_PREVIEW_PAGE; } diff --git a/server/src/main/java/cn/keking/service/impl/PptFilePreviewImpl.java b/server/src/main/java/cn/keking/service/impl/PptFilePreviewImpl.java deleted file mode 100644 index c365eee0..00000000 --- a/server/src/main/java/cn/keking/service/impl/PptFilePreviewImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.keking.service.impl; - -import cn.keking.model.FileAttribute; -import cn.keking.service.FilePreview; -import org.springframework.stereotype.Service; -import org.springframework.ui.Model; - -/** - * @author kl (http://kailing.pub) - * @since 2021/6/17 - */ -@Service -public class PptFilePreviewImpl implements FilePreview { - - private final OfficeFilePreviewImpl officeFilePreview; - - public PptFilePreviewImpl(OfficeFilePreviewImpl officeFilePreview) { - this.officeFilePreview = officeFilePreview; - } - - @Override - public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) { - officeFilePreview.filePreviewHandle(url,model,fileAttribute); - return PPT_FILE_PREVIEW_PAGE; - } -}