diff --git a/admin-core/src/main/java/com/ibeetl/admin/core/web/FileSystemContorller.java b/admin-core/src/main/java/com/ibeetl/admin/core/web/FileSystemContorller.java index 028e01d6aa1aad5d886ac25f9ddfb2a4ffc00bbc..712c72737efb64e145fc1333f47ccdaaa8358274 100644 --- a/admin-core/src/main/java/com/ibeetl/admin/core/web/FileSystemContorller.java +++ b/admin-core/src/main/java/com/ibeetl/admin/core/web/FileSystemContorller.java @@ -3,6 +3,7 @@ package com.ibeetl.admin.core.web; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.net.URLEncoder; import javax.servlet.http.HttpServletResponse; @@ -59,7 +60,7 @@ public class FileSystemContorller { @GetMapping(MODEL + "/download/{fileId}/{batchFileUUID}/{name}") public ModelAndView download(HttpServletResponse response,@PathVariable Long fileId,@PathVariable String batchFileUUID ) throws IOException { FileItem item = fileService.getFileItemById(fileId,batchFileUUID); - response.setHeader("Content-Disposition", "attachment; filename="+item.getName()); + response.setHeader("Content-Disposition", "attachment; filename="+URLEncoder.encode(item.getName(),"UTF-8")); item.copy(response.getOutputStream()); return null; } diff --git a/admin-core/src/main/resources/static/js/common.js b/admin-core/src/main/resources/static/js/common.js index 078c2c84755201ee70fab923eede39f7c4e8a140..e3af2b8697598b02b172f1ebb887adc7bb612046 100644 --- a/admin-core/src/main/resources/static/js/common.js +++ b/admin-core/src/main/resources/static/js/common.js @@ -78,6 +78,16 @@ var Common = { }); layer.full(index); }, + topOpenDlg:function(url,title){ + var index = top.layer.open({ + type: 2, + content: Common.ctxPath+url, + title: title, + area:['100%', '100%'], + maxmin: false + }); + layer.full(index); + }, openConfirm:function(content,callback,callBackNo){ var index = layer.confirm(content, { btn: ['确认','取消'] //按钮 diff --git a/admin-core/src/main/resources/templates/common/tag/attachment.tag.html b/admin-core/src/main/resources/templates/common/tag/attachment.tag.html index 8d5975eb4aa79d29b8c966ff92d071f28af56b93..b0b197ac4d395c825bc77ab4412b4b156c8ce234 100644 --- a/admin-core/src/main/resources/templates/common/tag/attachment.tag.html +++ b/admin-core/src/main/resources/templates/common/tag/attachment.tag.html @@ -135,11 +135,10 @@ function() { tr.find('.demo-preview').on('click', function() { //文件下载地址 - var file = encodeURIComponent("http://localhost:8080/core/file/download/"+fileId+"/${batchFileUUID}/"+fileName); - + var file = encodeURIComponent("http://" + window.location.host+"/core/file/download/"+fileId+"/${batchFileUUID}/"+fileName); //8012为预览服务器地址,参考 https://gitee.com/kekingcn/file-online-preview 安装 - Common.openDlg("${env('file.previewURL')}?url="+file,fileName+"预览") - //window.open("http://localhost:8012/onlinePreview?url="+file); + Common.topOpenDlg("${env('file.previewURL')}?url="+file,fileName+"预览"); + //window.open("${env('file.previewURL')}?url="+file,fileName+"预览"); return false; });