From b85542765637358cb1473629d0ea767ac076aec3 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期二, 23 九月 2025 13:36:26 +0800
Subject: [PATCH] 图片压缩
---
ycl-server/src/main/java/com/ycl/config/ResourcesConfig.java | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/ycl-server/src/main/java/com/ycl/config/ResourcesConfig.java b/ycl-server/src/main/java/com/ycl/config/ResourcesConfig.java
index 2531656..81afe43 100644
--- a/ycl-server/src/main/java/com/ycl/config/ResourcesConfig.java
+++ b/ycl-server/src/main/java/com/ycl/config/ResourcesConfig.java
@@ -1,26 +1,43 @@
package com.ycl.config;
+import constant.Constants;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.http.CacheControl;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
import java.util.Locale;
+import java.util.concurrent.TimeUnit;
/**
* 閫氱敤閰嶇疆
- *
+ *
* @author ruoyi
*/
@Configuration
public class ResourcesConfig implements WebMvcConfigurer
{
+
+ @Override
+ public void addResourceHandlers(ResourceHandlerRegistry registry)
+ {
+ /** 鏈湴鏂囦欢涓婁紶璺緞 */
+ registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**")
+ .addResourceLocations("file:" + PlatformConfig.getProfile() + "/");
+
+ /** swagger閰嶇疆 */
+ registry.addResourceHandler("/swagger-ui/**")
+ .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/")
+ .setCacheControl(CacheControl.maxAge(5, TimeUnit.HOURS).cachePublic());;
+ }
/**
* 璺ㄥ煙閰嶇疆
@@ -80,4 +97,4 @@
return localeResolver;
}
-}
\ No newline at end of file
+}
--
Gitblit v1.8.0