|
|
|
@ -6,6 +6,7 @@ import com.ruoyi.file.service.LocalSysFileServiceImpl;
|
|
|
|
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
|
|
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|
|
|
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
|
|
|
|
|
@ -48,12 +49,12 @@ public class ResourcesConfig implements WebMvcConfigurer
|
|
|
|
|
*/
|
|
|
|
|
private String path;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void addResourceHandlers(ResourceHandlerRegistry registry)
|
|
|
|
|
{
|
|
|
|
|
/** 本地文件上传路径 */
|
|
|
|
|
registry.addResourceHandler(prefix + "/**")
|
|
|
|
|
.addResourceLocations("file:" + path + File.separator);
|
|
|
|
|
public String getDomain() {
|
|
|
|
|
return domain;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setDomain(String domain) {
|
|
|
|
|
this.domain = domain;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getPrefix() {
|
|
|
|
@ -64,14 +65,6 @@ public class ResourcesConfig implements WebMvcConfigurer
|
|
|
|
|
this.prefix = prefix;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getDomain() {
|
|
|
|
|
return domain;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setDomain(String domain) {
|
|
|
|
|
this.domain = domain;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getPath() {
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
@ -79,4 +72,25 @@ public class ResourcesConfig implements WebMvcConfigurer
|
|
|
|
|
public void setPath(String path) {
|
|
|
|
|
this.path = path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void addResourceHandlers(ResourceHandlerRegistry registry)
|
|
|
|
|
{
|
|
|
|
|
/** 本地文件上传路径 */
|
|
|
|
|
registry.addResourceHandler(prefix + "/**")
|
|
|
|
|
.addResourceLocations("file:" + path + File.separator);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 开启跨域
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void addCorsMappings(CorsRegistry registry) {
|
|
|
|
|
// 设置允许跨域的路由
|
|
|
|
|
registry.addMapping(prefix + "/**")
|
|
|
|
|
// 设置允许跨域请求的域名
|
|
|
|
|
.allowedOrigins("*")
|
|
|
|
|
// 设置允许的方法
|
|
|
|
|
.allowedMethods("GET");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|