zhuo
2025-02-22 6d2d026a080f38fe5fdd43c5f55913b40a803391
开发文件映射路径
已修改3个文件
30 ■■■■ 文件已修改
ruoyi-admin/src/main/resources/application-druid.yml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/resources/application-druid.yml
@@ -79,6 +79,7 @@
wordUrl: D:\项目文件存储\word
twoCode: D:\项目文件存储\two_code
outPath: D:\项目文件存储\image
#oa:
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java
@@ -1,6 +1,7 @@
package com.ruoyi.framework.config;
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;
@@ -22,44 +23,41 @@
 * @author ruoyi
 */
@Configuration
public class ResourcesConfig implements WebMvcConfigurer
{
public class ResourcesConfig implements WebMvcConfigurer {
    @Autowired
    private RepeatSubmitInterceptor repeatSubmitInterceptor;
    @Value("${file.path}")
    private String filePath;
    @Value("${outPath}")
    private String outPath;
    @Value("${wordUrl}")
    private String wordUrl;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry)
    {
    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());
        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+"/");
        registry.addResourceHandler("/img/**").addResourceLocations("file:" + filePath + "/");
        registry.addResourceHandler("/outPath/**").addResourceLocations("file:" + outPath);
        registry.addResourceHandler("/word/**").addResourceLocations("file:" + wordUrl + "/");
    }
    /**
     * 自定义拦截规则
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry)
    {
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**");
    }
@@ -67,8 +65,7 @@
     * 跨域配置
     */
    @Bean
    public CorsFilter corsFilter()
    {
    public CorsFilter corsFilter() {
        CorsConfiguration config = new CorsConfiguration();
        config.setAllowCredentials(true);
        // 设置访问源地址
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
@@ -113,7 +113,7 @@
                // 对于登录login 注册register 验证码captchaImage 允许匿名访问
                requests.antMatchers("/login", "/register", "/captchaImage").permitAll()
                    // 静态资源,可匿名访问
                    .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
                    .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**", "/img/**", "/outPath/**", "/word/**").permitAll()
                    .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
                    // 除上面外的所有请求全部需要鉴权认证
                    .anyRequest().authenticated();