yxk-20260721

bug修复,kk的在线预览报错:原因是生产环境前后端隔离,但是配置还是localhost
This commit is contained in:
ye1023
2026-07-21 10:07:57 +08:00
parent 9ae0e8172c
commit 82acda9e24
@@ -58,6 +58,8 @@ public class FileController {
private BaseCommonService baseCommonService; private BaseCommonService baseCommonService;
@Value(value = "${jeecg.appName}") @Value(value = "${jeecg.appName}")
private String applicationName; private String applicationName;
@Value(value = "${jeecg.file-preview-download-domain:}")
private String filePreviewDownloadDomain;
private static final String FILE_PREVIEW_REDIS_PREFIX = "sys:file:preview:"; private static final String FILE_PREVIEW_REDIS_PREFIX = "sys:file:preview:";
private static final long FILE_PREVIEW_TOKEN_EXPIRE_SECONDS = 600L; private static final long FILE_PREVIEW_TOKEN_EXPIRE_SECONDS = 600L;
@@ -619,7 +621,22 @@ public class FileController {
private String buildPreviewDownloadUrl(HttpServletRequest request, String token, String fileName) { private String buildPreviewDownloadUrl(HttpServletRequest request, String token, String fileName) {
// kkFileView judges the preview handler by file suffix; stream APIs without suffix need fullfilename. // kkFileView judges the preview handler by file suffix; stream APIs without suffix need fullfilename.
return buildRequestBaseUrl(request) + "/sys/file/previewDownload?token=" + token + "&fullfilename=" + encodeUrlParam(fileName); return getPreviewDownloadBaseUrl(request) + "/sys/file/previewDownload?token=" + token + "&fullfilename=" + encodeUrlParam(fileName);
}
private String getPreviewDownloadBaseUrl(HttpServletRequest request) {
if (!StringUtils.isEmpty(filePreviewDownloadDomain) && !StringUtils.isEmpty(filePreviewDownloadDomain.trim())) {
// kkFileView may run on another host, so its download address must not depend on proxy headers.
return trimTrailingSlash(filePreviewDownloadDomain.trim());
}
return buildRequestBaseUrl(request);
}
private String trimTrailingSlash(String value) {
while (value.endsWith("/")) {
value = value.substring(0, value.length() - 1);
}
return value;
} }
private JSONObject parsePreviewInfo(Object cache) { private JSONObject parsePreviewInfo(Object cache) {