Browse Source

解决打包后SHP数据上传加载问题

WQQ 10 hours ago
parent
commit
ac8e9fbc88

+ 14 - 0
RuoYi-Vue3/src/supermap-cesium-module/js/common/layerManagement.js

@@ -518,6 +518,13 @@ function addGeoJsonLayer(url, name, callback) {
             return;
         }
 
+        // 如果是/profile/路径,添加API基础路径以路由到后端
+        if (url.startsWith('/profile/') || url.startsWith('profile/')) {
+            const baseURL = window.globalRequestConfig?.baseURL || import.meta.env.VITE_APP_BASE_API || '';
+            url = baseURL + (url.startsWith('/') ? url : '/' + url);
+            console.log('/profile/路径添加API前缀后:', url);
+        }
+
         // 外部URL直接加载
         console.log('外部URL直接加载:', url);
         const loadPromise = Cesium.GeoJsonDataSource.load(url, {
@@ -576,6 +583,13 @@ function addGeoJsonLayerWithStyle(url, name, style, callback) {
             return;
         }
 
+        // 如果是/profile/路径,添加API基础路径以路由到后端
+        if (url.startsWith('/profile/') || url.startsWith('profile/')) {
+            const baseURL = window.globalRequestConfig?.baseURL || import.meta.env.VITE_APP_BASE_API || '';
+            url = baseURL + (url.startsWith('/') ? url : '/' + url);
+            console.log('/profile/路径添加API前缀后:', url);
+        }
+
         // 外部URL直接加载
         console.log('外部URL直接加载:', url);
         const fillColor = Cesium.Color.fromCssColorString(style.fillColor || '#00FF00').withAlpha(style.fillOpacity || 0.4);

+ 9 - 0
nginx-production.conf

@@ -32,6 +32,15 @@ server {
         autoindex on;
     }
 
+    # profile文件访问(自定义服务GeoJSON等)
+    location /profile/ {
+        proxy_pass http://localhost:8080/prod-api/;  # 代理到后端(带context-path)
+        proxy_set_header Host $host;
+        proxy_set_header X-Real-IP $remote_addr;
+        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+        proxy_set_header X-Forwarded-Proto $scheme;
+    }
+
     # 错误页面
     error_page 404 /index.html;
     error_page 500 502 503 504 /50x.html;