From f3ce4485cd37eb7c3bcf16fde86a7f149974c4b6 Mon Sep 17 00:00:00 2001
From: lty <876263681@qq.com>
Date: 星期五, 20 三月 2026 09:51:50 +0800
Subject: [PATCH] #检查导出功能:  1.商品档案无异常  2.库存明细管理(异常)已修复  3.库存明细统计无异常  4.工作档查询维护无异常  5.工作档明细查询无异常  6.工作历史档查询无异常  7.工作明细历史档查询无异常  8.入库通知历史档无异常  9.库存移动流水记录(异常)已修复  10.机台工位绑定无异常  11.库存调整记录无异常  12.工作档维护日志(异常)已修复  13.操作日志无异常

---
 src/main/java/com/zy/common/config/WebConfig.java |   60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 59 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/zy/common/config/WebConfig.java b/src/main/java/com/zy/common/config/WebConfig.java
index 11bb6b2..91f0c82 100644
--- a/src/main/java/com/zy/common/config/WebConfig.java
+++ b/src/main/java/com/zy/common/config/WebConfig.java
@@ -1,9 +1,23 @@
 package com.zy.common.config;
 
+import com.zy.common.constant.MesConstant;
+import com.zy.common.utils.Http;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.core.Ordered;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
+import org.springframework.web.servlet.AsyncHandlerInterceptor;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
 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 javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 /**
  * Created by vincent on 2019-06-13
@@ -18,7 +32,51 @@
     public void addInterceptors(InterceptorRegistry registry) {
         registry.addInterceptor(adminInterceptor)
                 .addPathPatterns("/**")
-                ;
+        ;
     }
 
+    @Override
+    public void addCorsMappings(CorsRegistry registry) {
+        registry.addMapping("/**")
+                .allowedOrigins("*") // 浣跨敤 allowedOriginPatterns 鑰屼笉鏄� allowedOrigins
+                .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
+                .allowedHeaders("*")
+                .allowCredentials(true)
+                .maxAge(3600);
+    }
+
+    /**
+     * 鏂瑰紡浜岋細浣跨敤 Filter锛堟洿鍏ㄩ潰锛屼紭鍏堢骇鏇撮珮锛�
+     */
+    @Bean
+    public FilterRegistrationBean<CorsFilter> corsFilter() {
+        CorsConfiguration config = new CorsConfiguration();
+
+        // 鍏佽鎵�鏈夊煙鍚�
+        config.addAllowedOrigin("*");
+
+        // 鍏佽浠讳綍澶�
+        config.addAllowedHeader("*");
+
+        // 鍏佽浠讳綍鏂规硶锛圙ET, POST, PUT, DELETE, OPTIONS绛夛級
+        config.addAllowedMethod("*");
+
+        // 鍏佽鍑瘉锛堝鏋滈渶瑕乧ookie绛夊嚟璇侊紝璁剧疆涓簍rue锛屼絾闇�瑕佹寚瀹氬叿浣撳煙鍚嶏級
+        config.setAllowCredentials(false);
+
+        // 棰勬璇锋眰鐨勬湁鏁堟湡锛屽崟浣嶄负绉�
+        config.setMaxAge(3600L);
+
+        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+        source.registerCorsConfiguration("/**", config);
+
+        FilterRegistrationBean<CorsFilter> bean = new FilterRegistrationBean<>(new CorsFilter(source));
+
+        // 璁剧疆浼樺厛绾ф渶楂�
+        bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
+
+        return bean;
+    }
+
+
 }

--
Gitblit v1.9.1