style(系统设置): 优化文件管理svg图标的预览模式

This commit is contained in:
song-tianyang 2023-11-17 17:34:31 +08:00 committed by 刘瑞斌
parent d0ba083172
commit abfd9cff52
3 changed files with 25 additions and 1 deletions

View File

@ -480,7 +480,9 @@ public class FileMetadataService {
public ResponseEntity<byte[]> downloadPreviewImgById(String id) throws Exception { public ResponseEntity<byte[]> downloadPreviewImgById(String id) throws Exception {
FileMetadata fileMetadata = fileMetadataMapper.selectByPrimaryKey(id); FileMetadata fileMetadata = fileMetadataMapper.selectByPrimaryKey(id);
String previewImgPath = null; String previewImgPath = null;
if (TempFileUtils.isImage(fileMetadata.getType())) { if (StringUtils.equalsIgnoreCase(fileMetadata.getType(), "svg")) {
return this.downloadById(id);
} else if (TempFileUtils.isImage(fileMetadata.getType())) {
if (TempFileUtils.isImgPreviewFileExists(fileMetadata.getId())) { if (TempFileUtils.isImgPreviewFileExists(fileMetadata.getId())) {
previewImgPath = TempFileUtils.getPreviewImgFilePath(fileMetadata.getId()); previewImgPath = TempFileUtils.getPreviewImgFilePath(fileMetadata.getId());
} else { } else {

View File

@ -440,6 +440,17 @@ public class FileManagementControllerTests extends BaseTest {
fileUploadRequest.setEnable(false); fileUploadRequest.setEnable(false);
//小型图片文件用于测试预览图下载 //小型图片文件用于测试预览图下载
filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/icon_file-unknow_colorful.svg")).getPath();
file = new MockMultipartFile("file", "icon_file-unknow_colorful.svg", MediaType.APPLICATION_OCTET_STREAM_VALUE, FileManagementBaseUtils.getFileBytes(filePath));
paramMap = new LinkedMultiValueMap<>();
paramMap.add("file", file);
paramMap.add("request", JSON.toJSONString(fileUploadRequest));
mvcResult = this.requestMultipartWithOkAndReturn(FileManagementRequestUtils.URL_FILE_UPLOAD, paramMap);
returnId = JSON.parseObject(mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData().toString();
checkLog(returnId, OperationLogType.ADD, FileManagementRequestUtils.URL_FILE_UPLOAD);
FILE_ID_PATH.put(returnId, filePath);
//svg文件用于测试预览图下载
filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/1182937072541700.jpg")).getPath(); filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/1182937072541700.jpg")).getPath();
file = new MockMultipartFile("file", "1182937072541700.jpg", MediaType.APPLICATION_OCTET_STREAM_VALUE, FileManagementBaseUtils.getFileBytes(filePath)); file = new MockMultipartFile("file", "1182937072541700.jpg", MediaType.APPLICATION_OCTET_STREAM_VALUE, FileManagementBaseUtils.getFileBytes(filePath));
paramMap = new LinkedMultiValueMap<>(); paramMap = new LinkedMultiValueMap<>();
@ -449,6 +460,7 @@ public class FileManagementControllerTests extends BaseTest {
returnId = JSON.parseObject(mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData().toString(); returnId = JSON.parseObject(mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData().toString();
checkLog(returnId, OperationLogType.ADD, FileManagementRequestUtils.URL_FILE_UPLOAD); checkLog(returnId, OperationLogType.ADD, FileManagementRequestUtils.URL_FILE_UPLOAD);
FILE_ID_PATH.put(returnId, filePath); FILE_ID_PATH.put(returnId, filePath);
uploadedFileTypes.add("svg");
//检查文件类型获取接口有没有获取到数据 //检查文件类型获取接口有没有获取到数据
fileTypes = this.getFileType(); fileTypes = this.getFileType();

View File

@ -0,0 +1,10 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_40_79324)">
<path d="M16 1C16.3038 1 16.5911 1.13809 16.7809 1.3753L20.7727 6.3652C20.8021 6.40093 20.8291 6.43874 20.8533 6.47837L20.7809 6.37531C20.8151 6.41816 20.8457 6.46352 20.8722 6.51088L20.9278 6.62692L20.9667 6.74397C20.9789 6.78946 20.9878 6.83591 20.9933 6.88338L21 7V22C21 22.5523 20.5523 23 20 23H4C3.44772 23 3 22.5523 3 22V2C3 1.44772 3.44772 1 4 1H16ZM14 3H5V21H19V8H15C14.4477 8 14 7.55228 14 7V3ZM12 17.3542C12.5369 17.3542 12.9722 17.7895 12.9722 18.3264C12.9722 18.8633 12.5369 19.2986 12 19.2986C11.4631 19.2986 11.0278 18.8633 11.0278 18.3264C11.0278 17.7895 11.4631 17.3542 12 17.3542ZM12 8.57639C13.8409 8.57639 15.3333 10.0688 15.3333 11.9097C15.3333 13.3825 14.3782 14.6322 13.0536 15.0731L12.9997 15.0884L13 15.7986C13 16.3114 12.614 16.7341 12.1166 16.7919L12 16.7986C11.4477 16.7986 11 16.3509 11 15.7986V14.2431C11 13.7302 11.386 13.3075 11.8834 13.2498L12 13.2431C12.7364 13.2431 13.3333 12.6461 13.3333 11.9097C13.3333 11.1733 12.7364 10.5764 12 10.5764C11.3069 10.5764 10.7374 11.1052 10.6728 11.7813L10.6667 11.9097C10.6667 12.462 10.219 12.9097 9.66667 12.9097C9.11438 12.9097 8.66667 12.462 8.66667 11.9097C8.66667 10.0688 10.1591 8.57639 12 8.57639ZM17.92 6L16 3.6V6H17.92Z" fill="#646466"/>
</g>
<defs>
<clipPath id="clip0_40_79324">
<rect width="24" height="24" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB