mirror of
https://gitee.com/kekingcn/file-online-preview.git
synced 2026-03-20 08:03:50 +08:00
新增配置项office.preview.switch.disabled,控制offic文件预览切换开关
This commit is contained in:
@@ -54,6 +54,7 @@ public class OfficeFilePreviewImpl implements FilePreview {
|
||||
boolean isHtml = suffix.equalsIgnoreCase("xls") || suffix.equalsIgnoreCase("xlsx");
|
||||
String pdfName = fileName.substring(0, fileName.lastIndexOf(".") + 1) + (isHtml ? "html" : "pdf");
|
||||
String outFilePath = FILE_DIR + pdfName;
|
||||
model.addAttribute("switchDisabled", ConfigConstants.getOfficePreviewSwitchDisabled());
|
||||
// 判断之前是否已转换过,如果转换过,直接返回,否则执行转换
|
||||
if (!fileUtils.listConvertedFiles().containsKey(pdfName) || !ConfigConstants.isCacheEnabled()) {
|
||||
String filePath;
|
||||
|
||||
@@ -44,6 +44,7 @@ public class PdfFilePreviewImpl implements FilePreview {
|
||||
String baseUrl = BaseUrlFilter.getBaseUrl();
|
||||
String pdfName = fileName.substring(0, fileName.lastIndexOf(".") + 1) + "pdf";
|
||||
String outFilePath = FILE_DIR + pdfName;
|
||||
model.addAttribute("switchDisabled", ConfigConstants.getOfficePreviewSwitchDisabled());
|
||||
if (OfficeFilePreviewImpl.OFFICE_PREVIEW_TYPE_IMAGE.equals(officePreviewType) || OfficeFilePreviewImpl.OFFICE_PREVIEW_TYPE_ALL_IMAGES.equals(officePreviewType)) {
|
||||
//当文件不存在时,就去下载
|
||||
if (!fileUtils.listConvertedFiles().containsKey(pdfName) || !ConfigConstants.isCacheEnabled()) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.keking.service.impl;
|
||||
|
||||
import cn.keking.config.ConfigConstants;
|
||||
import cn.keking.model.FileAttribute;
|
||||
import cn.keking.model.ReturnResponse;
|
||||
import cn.keking.service.FilePreview;
|
||||
@@ -33,6 +34,7 @@ public class PictureFilePreviewImpl implements FilePreview {
|
||||
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
|
||||
String fileKey = (String) RequestContextHolder.currentRequestAttributes().getAttribute("fileKey",0);
|
||||
List<String> imgUrls = Lists.newArrayList(url);
|
||||
model.addAttribute("switchDisabled", ConfigConstants.getOfficePreviewSwitchDisabled());
|
||||
try {
|
||||
imgUrls.clear();
|
||||
imgUrls.addAll(fileUtils.getImgCache(fileKey));
|
||||
|
||||
Reference in New Issue
Block a user