From 8bfd657326eb9d4bd9b63920cfe3bd362cea4445 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Fri, 10 Oct 2025 20:59:07 +0800
Subject: [PATCH] Merge branch 'feature/v6.0/6.0.4' into prod

---
 src/views/resource/components/spotDetails.vue |   44 ++++++++++++++++++++++++++++++++++----------
 1 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/src/views/resource/components/spotDetails.vue b/src/views/resource/components/spotDetails.vue
index 3d09cb3..28eb3a8 100644
--- a/src/views/resource/components/spotDetails.vue
+++ b/src/views/resource/components/spotDetails.vue
@@ -133,6 +133,8 @@
 import * as Cesium from 'cesium';
 import { PublicCesium } from '@/utils/cesium/publicCesium';
 import { ref, watch, onBeforeUnmount, onMounted } from 'vue';
+// 标记地图是否初始化完成
+const isMapReady = ref(false);
 const uploadPatchDialog = defineModel('show');
 const props = defineProps(['title', 'detailid', 'detailList', 'spotTypeOption', 'regionalData']);
 const polygonTableEle = ref(null);
@@ -266,9 +268,8 @@
 
 // 地图
 const initMap = () => {
-  if (!document.getElementById('spotMap')) {
-    return;
-  }
+  if (!document.getElementById('spotMap') || isMapReady.value) return;
+  
   publicCesiumInstance = new PublicCesium({
     dom: 'spotMap',
     flatMode: false,
@@ -276,12 +277,33 @@
     layerMode: 4,
     contour: false,
   });
+  
   homeViewer.value = publicCesiumInstance.getViewer();
   viewer = publicCesiumInstance.getViewer();
-  viewInstance.value = publicCesiumInstance;
+  viewInstance.value = publicCesiumInstance; 
   viewer.scene.globe.depthTestAgainstTerrain = true;
   viewInstance.value.switchContour(true);
+
+  // 确保 readyPromise 存在
+  if (viewer.readyPromise) {
+    viewer.readyPromise.then(() => {
+      isMapReady.value = true; 
+      getTableList();
+    }).catch((error) => {
+      console.error('地图加载失败:', error);
+      ElMessage.error('地图加载失败,请刷新重试');
+    });
+  } else {
+
+    // 如果没有 readyPromise
+    setTimeout(() => {
+      isMapReady.value = true;
+      getTableList();
+    }, 1000);
+  }
 };
+
+
 // 仅弹框初始化时执行的定位逻辑
 const initMapLocation = () => {
   if (tbJwdList.length === 0 || !homeViewer.value) return;
@@ -303,6 +325,7 @@
 };
 // 初始化所有图斑
 const entitiesAddSpot = () => {
+if (!isMapReady.value || !viewer) return;
   viewer?.entities.removeAll();
   tbJwdList = []; // 重置经纬度列表
   
@@ -594,20 +617,21 @@
 
 watch(uploadPatchDialog, newVal => {
   if (newVal) {
-
     isInit.value = true; 
+    isMapReady.value = false; 
     setTimeout(() => {
       initMap();      
-      getTableList();  
-      getspotManagementTableApi();
+      getspotManagementTableApi(); 
     }, 0);
   } else {
- tableData.value = []; 
+ 
+    tableData.value = []; 
     isEditing.value = false;
     handleUpDateDrawState(false);
     destroyMap();
     isInit.value = false; 
     clearSelect();
+    isMapReady.value = false; 
   }
   refreshonload();
 });
@@ -722,8 +746,8 @@
   z-index: 99;
   width: 277px;
   overflow: hidden;
-  background: rgba(0, 0, 0, 0.6);
-  // backdrop-filter: blur(5px);
+  background: rgba(0, 0, 0, 0.8);
+
   border-radius: 8px 8px 8px 8px;
   padding: 6px 10px 0 10px;
   display: flex;

--
Gitblit v1.9.3