zhuo
2025-02-22 85997724c09d3ebba590b793aa4ec65496f999ff
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java
@@ -2,6 +2,7 @@
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.CacheControl;
@@ -17,7 +18,7 @@
/**
 * 通用配置
 *
 *
 * @author ruoyi
 */
@Configuration
@@ -26,17 +27,31 @@
    @Autowired
    private RepeatSubmitInterceptor repeatSubmitInterceptor;
    @Value("${file.path}")
    private String filePath;
    @Value("${wordUrl}")
    private String wordUrl;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry)
    {
        /** 本地文件上传路径 */
        registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**")
                .addResourceLocations("file:" + RuoYiConfig.getProfile() + "/");
//
//        /** swagger配置 */
//        registry.addResourceHandler("/swagger-ui/**")
//                .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/")
//                .setCacheControl(CacheControl.maxAge(5, TimeUnit.HOURS).cachePublic());
        /** swagger配置 */
        registry.addResourceHandler("/swagger-ui/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/")
                .setCacheControl(CacheControl.maxAge(5, TimeUnit.HOURS).cachePublic());
        registry.addResourceHandler("/doc.html").addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/favicon.ico").addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
        //设置文件虚拟路径映射
        registry.addResourceHandler("/img/**").addResourceLocations("file:"+filePath+"/");
        registry.addResourceHandler("/word/**").addResourceLocations("file:"+wordUrl+"/");
    }
    /**
@@ -70,4 +85,4 @@
        // 返回新的CorsFilter
        return new CorsFilter(source);
    }
}
}