From 213de676b386af4a195df899c23d057d889095d1 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 22 十月 2024 16:13:25 +0800
Subject: [PATCH] #

---
 zy-acs-flow/src/map/insight/shelf/ShelfThree.js |    8 ++++++--
 zy-acs-flow/src/map/tool.js                     |    6 +++---
 zy-acs-flow/src/map/insight/agv/AgvThree.js     |    8 ++++++--
 zy-acs-flow/src/map/insight/shelf/ShelfMain.jsx |   10 ++++++++--
 4 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/zy-acs-flow/src/map/insight/agv/AgvThree.js b/zy-acs-flow/src/map/insight/agv/AgvThree.js
index 58724ff..e45c5da 100644
--- a/zy-acs-flow/src/map/insight/agv/AgvThree.js
+++ b/zy-acs-flow/src/map/insight/agv/AgvThree.js
@@ -169,8 +169,12 @@
         }
         this.camera = null;
         this.objects = [];
-        while (this.dom?.firstChild) {
-            this.dom.removeChild(this.dom.firstChild);
+        if (this.dom) {
+            while (this.dom.firstChild) {
+                if (this.dom.contains(this.dom.firstChild)) {
+                    this.dom.removeChild(this.dom.firstChild);
+                }
+            }
         }
     }
 
diff --git a/zy-acs-flow/src/map/insight/shelf/ShelfMain.jsx b/zy-acs-flow/src/map/insight/shelf/ShelfMain.jsx
index 636150e..7c93b4c 100644
--- a/zy-acs-flow/src/map/insight/shelf/ShelfMain.jsx
+++ b/zy-acs-flow/src/map/insight/shelf/ShelfMain.jsx
@@ -71,8 +71,14 @@
             }
 
             Promise.all(promises).then(() => {
-                shelfThree.setNewSelectedMesh(curLocNo);
-                shelfThree.rePerspective(singleHeight * info.length, 500);
+                if (shelfThree) {
+                    if (typeof shelfThree.setNewSelectedMesh === 'function') {
+                        shelfThree.setNewSelectedMesh(curLocNo);
+                    }
+                    if (typeof shelfThree.rePerspective === 'function') {
+                        shelfThree.rePerspective(singleHeight * info.length, 500);
+                    }
+                }
             }).catch(error => {
                 console.error(error);
             });
diff --git a/zy-acs-flow/src/map/insight/shelf/ShelfThree.js b/zy-acs-flow/src/map/insight/shelf/ShelfThree.js
index e239382..c42cf00 100644
--- a/zy-acs-flow/src/map/insight/shelf/ShelfThree.js
+++ b/zy-acs-flow/src/map/insight/shelf/ShelfThree.js
@@ -241,8 +241,12 @@
         this.dom?.removeEventListener("click", this.handleClickEvent);
         this.camera = null;
         this.objects = [];
-        while (this.dom?.firstChild) {
-            this.dom.removeChild(this.dom.firstChild);
+        if (this.dom) {
+            while (this.dom.firstChild) {
+                if (this.dom.contains(this.dom.firstChild)) {
+                    this.dom.removeChild(this.dom.firstChild);
+                }
+            }
         }
     }
 
diff --git a/zy-acs-flow/src/map/tool.js b/zy-acs-flow/src/map/tool.js
index c3a15d6..2993d4e 100644
--- a/zy-acs-flow/src/map/tool.js
+++ b/zy-acs-flow/src/map/tool.js
@@ -348,7 +348,7 @@
 
 function onSpriteMouseOver(event) {
     if (tooltip) {
-        app.stage.removeChild(tooltip);
+        app?.stage.removeChild(tooltip);
     }
     tooltip = createSpriteTooltip(this);// this => sprite
     tooltip.x = event.data.global.x + 10;
@@ -365,7 +365,7 @@
 
 function onSpriteMouseOut() {
     if (tooltip && tooltip.parent) {
-        tooltip.parent.removeChild(tooltip);
+        tooltip.parent?.removeChild(tooltip);
         tooltip = null;
     }
 }
@@ -478,7 +478,7 @@
         effectTicker = null;
     }
     if (effectCircle) {
-        mapContainer.removeChild(effectCircle);
+        mapContainer?.removeChild(effectCircle);
         effectCircle = null;
     }
     selectedSprite = null;

--
Gitblit v1.9.1