* 新增:JSON 文件格式化预览功能

* 优化:优化 JSON 文件格式化预览效果
This commit is contained in:
kl
2025-10-11 17:54:17 +08:00
committed by GitHub
parent a9787b0add
commit 51653483b9
3 changed files with 286 additions and 52 deletions

View File

@@ -47,7 +47,7 @@ public class SimTextFilePreviewImpl implements FilePreview {
}
try {
String fileData = HtmlUtils.htmlEscape(textData(filePath,fileName));
model.addAttribute("textData", Base64.encodeBase64String(fileData.getBytes()));
model.addAttribute("textData", Base64.encodeBase64String(fileData.getBytes(StandardCharsets.UTF_8)));
} catch (IOException e) {
return otherFilePreview.notSupportedFile(model, fileAttribute, e.getLocalizedMessage());
}
@@ -59,7 +59,7 @@ public class SimTextFilePreviewImpl implements FilePreview {
} catch (IOException e) {
e.printStackTrace();
}
model.addAttribute("textData", Base64.encodeBase64String(fileData.getBytes()));
model.addAttribute("textData", Base64.encodeBase64String(fileData.getBytes(StandardCharsets.UTF_8)));
return TXT_FILE_PREVIEW_PAGE;
}