From cf7752d995e09d48eca9a1ca5634a9e71ae46553 Mon Sep 17 00:00:00 2001
From: wangjuncheng <1>
Date: 星期二, 22 七月 2025 16:19:06 +0800
Subject: [PATCH] 透明度0 修改模型数据路径

---
 src/components/tools/LayerTree.vue |   85 ++++++++++++++++++++++++++++++++++--------
 1 files changed, 69 insertions(+), 16 deletions(-)

diff --git a/src/components/tools/LayerTree.vue b/src/components/tools/LayerTree.vue
index cbe28aa..c217cd7 100644
--- a/src/components/tools/LayerTree.vue
+++ b/src/components/tools/LayerTree.vue
@@ -191,7 +191,8 @@
 function handleModelLayer(checked) {
   if (checked) {
     addTileset(
-      "http://106.120.22.26:9103/gisserver/c3dserver/sunhugou3d/tileset.json"
+      // "http://106.120.22.26:9103/gisserver/c3dserver/sunhugou3d/tileset.json"
+      "http://192.168.37.61:9004/tile/model/service/Iakp0nhx/tileset.json?labtoken=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiItMSxUaHUgQXByIDE4IDE1OjMwOjU3IENTVCAyMDI0In0.j_YKsCRsIQtpgOWfFvMwAP65Rlx9uXyVte_xkE95Vdo"
     )
       .then((model) => {
         treeMap.set("妯″瀷鏁版嵁", model);
@@ -239,22 +240,61 @@
  * 娓呴櫎鍥惧眰瀹炰綋
  * @param {String} layerName - 鍥惧眰鍚嶇О
  */
-function clearLayerEntities(layerName) {
+// 鏆備笖淇濈暀
+// async function clearLayerEntities(layerName) {
+//   const list = treeMap.get(layerName);
+//   if (list && Array.isArray(list)) {
+//     for (const item of list) {
+//       const entity = await item;
+//       if (layerName == "缁煎悎鐩戞祴璁惧淇℃伅") {
+//         removeEntities(entity.deviceId);
+//       } else if (layerName == "瀛欒儭娌熼殣鎮g偣") {
+//         removeEntities(entity.hdId);
+//       }
+//     }
+//   }
+//   treeMap.delete(layerName);
+// }
+
+/**
+ * 娓呴櫎鍥惧眰瀹炰綋
+ * @param {String} layerName - 鍥惧眰鍚嶇О
+ */
+// 姝ゅ嚱鏁颁紭鍖栦簡鍦ㄦā鎷熶豢鐪熼〉闈紝濡傛灉鐐瑰嚮鐩綍鏍戦�変腑鍙栨秷锛屾偿浣嶈浠嶆樉绀�
+async function clearLayerEntities(layerName) {
+  const isMnfzPage = route.path === "/mnfz"; // 鍒ゆ柇鏄惁涓� /mnfz 椤甸潰
+
   const list = treeMap.get(layerName);
   if (list && Array.isArray(list)) {
-    list.forEach((entity) => {
-      clearAllPoints();
-    });
+    for (const item of list) {
+      const entity = await item;
+
+      let shouldRemove = true; // 榛樿瑕佸垹闄�
+
+      // 濡傛灉鏄� /mnfz 椤甸潰锛屽苟涓旀槸鈥滄偿浣嶈鈥濓紝鍒欎笉鍒犻櫎
+      if (isMnfzPage && entity.type === "娉ヤ綅璁�") {
+        shouldRemove = false;
+      }
+
+      if (shouldRemove) {
+        if (layerName === "缁煎悎鐩戞祴璁惧淇℃伅") {
+          removeEntities(entity.deviceId);
+        } else if (layerName === "瀛欒儭娌熼殣鎮g偣") {
+          removeEntities(entity.hdId);
+        }
+      }
+    }
   }
+
   treeMap.delete(layerName);
 }
 
-// 鐩戞帶璁惧寮�鍏冲彉鍖�
-watchEffect(() => {
+watchEffect(async () => {
   clearLayerEntities("缁煎悎鐩戞祴璁惧淇℃伅");
 
   if (simStore.DeviceShowSwitch) {
-    const deviceList = simStore.devices
+    // 浣跨敤 Promise.all 绛夊緟鎵�鏈夊紓姝ユ搷浣滃畬鎴�
+    const deviceListPromises = simStore.devices
       .filter((item) => item.deviceName?.includes("瀛欒儭娌�"))
       .map(async (item) => {
         const entity = viewer.entities.getById(item.deviceId);
@@ -263,8 +303,12 @@
         item.id = item.deviceId;
         item.className = "device";
         item.showLabel = true;
-        await createPoint(item);
+        await createPoint(item); // 纭繚 createPoint 杩斿洖涓�涓� Promise 鎴栬�呮湰韬氨鏄紓姝ュ嚱鏁�
+        return item; // 杩斿洖澶勭悊鍚庣殑 item
       });
+
+    // 绛夊緟鎵�鏈夊紓姝ユ搷浣滃畬鎴�
+    const deviceList = await Promise.all(deviceListPromises);
 
     if (deviceList.length) {
       treeMap.set("缁煎悎鐩戞祴璁惧淇℃伅", deviceList);
@@ -273,13 +317,15 @@
 });
 
 // 鐩戞帶闅愭偅鐐瑰紑鍏冲彉鍖�
-watchEffect(() => {
+watchEffect(async () => {
   clearLayerEntities("瀛欒儭娌熼殣鎮g偣");
 
   if (simStore.DangerShowSwitch) {
-    const dangerPoints = simStore.DangerPoint.filter((item) =>
+    const filteredPoints = simStore.DangerPoint.filter((item) =>
       item.position?.includes("瀛欒儭娌�")
-    ).map(async (item) => {
+    );
+
+    const dangerPointPromises = filteredPoints.map(async (item) => {
       const entity = viewer.entities.getById(item.hdId);
       item.id = item.hdId;
       item.name = item.hdName;
@@ -288,11 +334,18 @@
       item.showBillboard = true;
       item.type = item.disasterType;
       item.className = "district";
-      await createPoint(item);
+      await createPoint(item); // 纭繚 createPoint 鏄紓姝ュ嚱鏁�
+      return item; // 杩斿洖澶勭悊濂界殑 item
     });
 
-    if (dangerPoints.length) {
-      treeMap.set("瀛欒儭娌熼殣鎮g偣", dangerPoints);
+    try {
+      const resolvedPoints = await Promise.all(dangerPointPromises);
+
+      if (resolvedPoints.length) {
+        treeMap.set("瀛欒儭娌熼殣鎮g偣", resolvedPoints);
+      }
+    } catch (error) {
+      console.error("鍒涘缓闅愭偅鐐规椂鍙戠敓閿欒:", error);
     }
   }
 });
@@ -322,7 +375,7 @@
  * 娣诲姞閬块櫓鍦烘墍鏁版嵁
  */
 function addTetrahedron() {
-  getSafePoint().then((res) => {
+  getSafePoint(110116110218).then((res) => {
     const geoJsonData = convertToGeoJson(res.data); // 杞崲涓� GeoJSON
     // 鍔犺浇 GeoJSON 鏁版嵁鍒板湴鍥�
     loadAreaPolygon(geoJsonData, true).then((entities) => {

--
Gitblit v1.9.3