修改模型详情回显图片

This commit is contained in:
limengnan 2026-01-20 16:56:36 +08:00
parent 5093d978b4
commit f3bc668e65
2 changed files with 30 additions and 2 deletions

View File

@ -14,6 +14,7 @@ import { searchAlgorithmsModelPage} from "@/api/business/algorithmModel";
import Page from '@/components/Pagination/page.vue' import Page from '@/components/Pagination/page.vue'
import { getDictItemById } from '@/api/dict'; import { getDictItemById } from '@/api/dict';
const apiUrl = import.meta.env.VITE_APP_BASE_API; //
const menuData:any = ref([]); const menuData:any = ref([]);
const algorithmData:any = ref([]); const algorithmData:any = ref([]);
// //
@ -341,7 +342,7 @@ function changeShowResult(isShow:boolean){ // 切换显示结果模型
</div> </div>
<el-dialog v-model="dialogVisible" :close-on-click-modal="false" <el-dialog v-model="dialogVisible" :close-on-click-modal="false"
:modal="false" draggable :before-close="handleClose" :title="title" :modal="false" draggable :before-close="handleClose" :title="'模型详情'"
append-to-body width="1145px" height="600px"> append-to-body width="1145px" height="600px">
<div style=" width: calc(100%); height: calc(100vh - 200px);"> <div style=" width: calc(100%); height: calc(100vh - 200px);">
<div style="display: flex; margin-bottom: 20px; border-bottom: 1px solid #e5e5e5;padding-bottom: 5px;"> <div style="display: flex; margin-bottom: 20px; border-bottom: 1px solid #e5e5e5;padding-bottom: 5px;">
@ -379,7 +380,7 @@ function changeShowResult(isShow:boolean){ // 切换显示结果模型
</el-form-item> </el-form-item>
</el-form> </el-form>
<div v-else style="width: 100%; height: calc(100% - 50px);"> <div v-else style="width: 100%; height: calc(100% - 50px);">
<img src="file:///E:/python_coding/keffCenter/models/GPR/CylindricalTank/V1/error.jpg" alt="" style="width: 100%; height: 100%;object-fit:contain;"> <img :src="apiUrl +'/models/'+ info.metricsImagePath" alt="" style="width: 100%; height: 100%;object-fit:contain;">
</div> </div>
</div> </div>

View File

@ -4,11 +4,14 @@ import cn.hutool.cache.Cache;
import cn.hutool.cache.CacheUtil; import cn.hutool.cache.CacheUtil;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter; import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@ -17,8 +20,21 @@ public class WebConfig implements WebMvcConfigurer {
@Resource @Resource
private FileSpaceProperties fileSpaceProperties; private FileSpaceProperties fileSpaceProperties;
@Value("${file-space.model-path:E:/python_coding/keffCenter/models/}")
private String modelPath;
/**
* 跨域配置允许前端访问 /models/** 资源
*/
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/models/**") // 仅放行 /models/** 路径
.allowedOrigins("http://localhost:3000") // 前端地址
.allowedMethods("GET") // 仅允许 GET
.allowCredentials(true); // 如需带 cookie
}
@Bean @Bean
public Cache<String, String> loginuserCache() { public Cache<String, String> loginuserCache() {
return CacheUtil.newLRUCache(200);//用户登录缓存数 缺省200 return CacheUtil.newLRUCache(200);//用户登录缓存数 缺省200
@ -41,6 +57,7 @@ public class WebConfig implements WebMvcConfigurer {
@SneakyThrows @SneakyThrows
@Override @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
System.out.println("[WebConfig] modelPath in addResourceHandlers = " + modelPath);
registry.addResourceHandler("/icon/**") registry.addResourceHandler("/icon/**")
.addResourceLocations("classpath:/static/icon/") .addResourceLocations("classpath:/static/icon/")
.setCachePeriod(0); .setCachePeriod(0);
@ -52,10 +69,20 @@ public class WebConfig implements WebMvcConfigurer {
registry.addResourceHandler("swagger-ui.html").addResourceLocations( registry.addResourceHandler("swagger-ui.html").addResourceLocations(
"classpath:/META-INF/resources/"); "classpath:/META-INF/resources/");
// 把本地 modelPath 映射到 /models/** URL
String path = modelPath.replace("\\", "/");
if (!path.endsWith("/")) {
path += "/";
}
registry.addResourceHandler("/models/**")
.addResourceLocations("file:" + path);
String systemUrl = "file:" + fileSpaceProperties.getSystem().replace("\\", "/")+"user\\"; String systemUrl = "file:" + fileSpaceProperties.getSystem().replace("\\", "/")+"user\\";
registry.addResourceHandler("/avatar/**").addResourceLocations(systemUrl).setCachePeriod(0); registry.addResourceHandler("/avatar/**").addResourceLocations(systemUrl).setCachePeriod(0);
} }
} }