diff --git a/framework/gateway/src/main/java/io/metersphere/gateway/controller/LoginController.java b/framework/gateway/src/main/java/io/metersphere/gateway/controller/LoginController.java index 0067883250..4d1f784d5b 100644 --- a/framework/gateway/src/main/java/io/metersphere/gateway/controller/LoginController.java +++ b/framework/gateway/src/main/java/io/metersphere/gateway/controller/LoginController.java @@ -109,6 +109,13 @@ public class LoginController { return Mono.just(image); } + @GetMapping("display/file/css") + public Mono> cssFile() throws IOException { + ResponseEntity css = baseDisplayService.getCss(); + return Mono.just(css); + } + + @GetMapping("display/info") public Mono uiInfo() { return Mono.just(ResultHolder.success(baseDisplayService.uiInfo("ui"))); diff --git a/framework/gateway/src/main/java/io/metersphere/gateway/service/BaseDisplayService.java b/framework/gateway/src/main/java/io/metersphere/gateway/service/BaseDisplayService.java index e56d61a00b..bd9a49f47f 100644 --- a/framework/gateway/src/main/java/io/metersphere/gateway/service/BaseDisplayService.java +++ b/framework/gateway/src/main/java/io/metersphere/gateway/service/BaseDisplayService.java @@ -96,4 +96,21 @@ public class BaseDisplayService { dtoList.sort(Comparator.comparingInt(SystemParameter::getSort)); return dtoList; } + + public ResponseEntity getCss() { + byte[] bytes = new byte[0]; + List paramList = getParamList("ui.css"); + if (!CollectionUtils.isEmpty(paramList)) { + SystemParameter sp = paramList.get(0); + String paramValue = sp.getParamValue(); + if (StringUtils.isNotBlank(paramValue)) { + bytes = loadFileAsBytes(paramValue); + } + } + + return ResponseEntity.ok() + .contentType(MediaType.parseMediaType("text/css")) + .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=css") + .body(bytes); + } } diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/controller/LoginController.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/controller/LoginController.java index 3019330f15..a7a0a1e23f 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/controller/LoginController.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/controller/LoginController.java @@ -112,6 +112,11 @@ public class LoginController { return baseDisplayService.getImage(imageName); } + @GetMapping("display/file/css") + public ResponseEntity cssFile() throws IOException { + return baseDisplayService.getCss(); + } + @GetMapping(value = "/services") public List services() { return List.of(new ServiceDTO(serviceId, port)); diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/service/BaseDisplayService.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/service/BaseDisplayService.java index 449fa47d6c..fb26b2fc3a 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/service/BaseDisplayService.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/service/BaseDisplayService.java @@ -4,6 +4,7 @@ import io.metersphere.base.domain.SystemParameter; import io.metersphere.base.domain.SystemParameterExample; import io.metersphere.base.mapper.SystemParameterMapper; import io.metersphere.metadata.service.FileMetadataService; +import jakarta.annotation.Resource; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; @@ -14,7 +15,6 @@ import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import jakarta.annotation.Resource; import java.io.IOException; import java.util.List; @@ -77,4 +77,21 @@ public class BaseDisplayService { .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + imageName + "\"") .body(bytes); } + + public ResponseEntity getCss() { + byte[] bytes = new byte[0]; + List paramList = getParamList("ui.css"); + if (!CollectionUtils.isEmpty(paramList)) { + SystemParameter sp = paramList.get(0); + String paramValue = sp.getParamValue(); + if (StringUtils.isNotBlank(paramValue)) { + bytes = loadFileAsBytes(paramValue); + } + } + + return ResponseEntity.ok() + .contentType(MediaType.parseMediaType("text/css")) + .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=css") + .body(bytes); + } }