فهرست منبع

fix: 地图处理

刘秀芳 2 روز پیش
والد
کامیت
ed8222a856

+ 22 - 3
src/views/old_mini/task_condition/components/interact.vue

@@ -64,14 +64,14 @@
                         </div>
                         <div class="item-bottom">
                             <div class="bottom-tag">
-                                <div class="tag-card active">
+                                <div class="tag-card" :class="{ active: item.sourceData?.daysUntilNext < 5 }">
                                     <div class="card-content">
                                         <div class="card-main-text">{{ item.sourceData?.currentPhenologyName || '--' }}</div>
                                         <div class="card-sub-text">
                                             当前物候期
-                                            <span class="card-icon" @click="handleSelectCurrentPhenology(item)">
+                                            <!-- <span class="card-icon" @click="handleSelectCurrentPhenology(item)">
                                                 <el-icon><Edit /></el-icon>
-                                            </span>
+                                            </span> -->
                                         </div>
                                     </div>
                                 </div>
@@ -206,6 +206,25 @@ onActivated(() => {
     if (route.query.noReload) {
         return;
     }
+    // 确保地图已初始化,使用 nextTick 等待 DOM 更新
+    nextTick(() => {
+        // 检查地图实例是否已初始化
+        if (!indexMap.kmap) {
+            // 如果地图未初始化,重新初始化
+            if (mapContainer.value) {
+                mapPoint.value = store.state.home.miniUserLocationPoint;
+                indexMap.initMap(mapPoint.value, mapContainer.value, true);
+            }
+        } else {
+            // 如果地图已初始化,更新地图尺寸(解决页面切换后地图不显示的问题)
+            if (mapContainer.value && indexMap.kmap.map) {
+                // 等待容器完全可见后再更新尺寸
+                setTimeout(() => {
+                    indexMap.kmap.map.updateSize();
+                }, 100);
+            }
+        }
+    });
     resetAndLoad();
 });
 

+ 19 - 0
src/views/old_mini/task_condition/components/task.vue

@@ -267,6 +267,25 @@ onMounted(() => {
 });
 
 onActivated(() => {
+    // 确保地图已初始化,使用 nextTick 等待 DOM 更新
+    nextTick(() => {
+        // 检查地图实例是否已初始化
+        if (!indexMap.kmap) {
+            // 如果地图未初始化,重新初始化
+            if (mapContainer.value) {
+                mapPoint.value = store.state.home.miniUserLocationPoint;
+                indexMap.initMap(mapPoint.value, mapContainer.value, true);
+            }
+        } else {
+            // 如果地图已初始化,更新地图尺寸(解决页面切换后地图不显示的问题)
+            if (mapContainer.value && indexMap.kmap.map) {
+                // 等待容器完全可见后再更新尺寸
+                setTimeout(() => {
+                    indexMap.kmap.map.updateSize();
+                }, 100);
+            }
+        }
+    });
     // 初始化时获取所有状态的数量
     initTaskCounts();
     getSimpleList();

+ 11 - 0
src/views/old_mini/user/index.vue

@@ -107,6 +107,17 @@ onMounted(() => {
 });
 
 onActivated(() => {
+    // 确保地图已初始化,使用 nextTick 等待 DOM 更新
+    nextTick(() => {
+        // 检查地图实例是否已初始化
+        if (!indexMap.kmap) {
+            // 如果地图未初始化,重新初始化
+            if (mapContainer.value) {
+                const point = store.state.home.miniUserLocationPoint;
+                indexMap.initMap(point, mapContainer.value, true);
+            }
+        }
+    });
     getUserList();
 });