From f496d63b038c4f6ac9476ae8ff0d0ec679ce5473 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期五, 15 三月 2024 22:09:00 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/pages/map/utils.js |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/zy-asrs-flow/src/pages/map/utils.js b/zy-asrs-flow/src/pages/map/utils.js
index 321d73c..61be79d 100644
--- a/zy-asrs-flow/src/pages/map/utils.js
+++ b/zy-asrs-flow/src/pages/map/utils.js
@@ -316,7 +316,8 @@
     return options;
 }
 
-export const fetchMapData = async () => {
+export const fetchMapData = async (intl) => {
+    clearMapData();
     await Http.doPostPromise('api/map/list', {}, (res) => {
         const mapItemList = res.data.itemList;
         mapItemList.forEach(item => {
@@ -344,7 +345,7 @@
                 mapContainer.addChild(sprite);
             }
         })
-
+        
     }).catch((error) => {
         console.error(error);
     })
@@ -382,4 +383,26 @@
         closeLoading();
         console.error(error);
     })
+}
+
+export const clearMapData = (intl) => {
+    if (!mapContainer) {
+        return;
+    }
+    let childList = [];
+    mapContainer.children.forEach(child => {
+        if (child.data?.uuid) {
+            childList.push(child);
+        }
+    })
+    if (childList.length > 0) {
+        childList.forEach(child => {
+            mapContainer.removeChild(child);
+            child.destroy({ children: true, texture: false, baseTexture: false });
+        })
+        childList.forEach((child, index) => {
+            childList[index] = null;
+        });
+        childList = [];
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1