From c6e9813265f13c9d3c9cc371e8e14a4ab3c2895b Mon Sep 17 00:00:00 2001
From: wangjuncheng <1>
Date: 星期一, 19 五月 2025 14:58:05 +0800
Subject: [PATCH] change

---
 src/components/menu/Location.vue |   73 +++++++++++++++++++++---------------
 1 files changed, 43 insertions(+), 30 deletions(-)

diff --git a/src/components/menu/Location.vue b/src/components/menu/Location.vue
index 7749e80..e6e9048 100644
--- a/src/components/menu/Location.vue
+++ b/src/components/menu/Location.vue
@@ -1,31 +1,32 @@
-<template>
-  <div class="district">
-    <div class="left-top">
-      <span>鐩戞祴浣嶇疆</span>
-    </div>
-
-    <div class="left-content district-content">
-      <div style="margin-left: 5px">
-        <span style="color: white">閲嶇偣娌燂細</span>
-        <el-select @change="handleChange" v-model="selectValue" placeholder="Select" size="large" style="width: 240px">
-          <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
-        </el-select>
+  <template>
+    <div class="district">
+      <div class="left-top">
+        <span>鐩戞祴浣嶇疆</span>
       </div>
 
-      <!-- 婊氬姩鍖哄煙 -->
-      <div style="overflow-y: auto; height: 95%">
-        <!-- 鍔犺浇閬僵灞� -->
-        <div v-if="loading" class="loading-overlay">
-          <div class="spinner"></div>
+      <div class="left-content district-content">
+        <div style="margin-left: 5px">
+          <span style="color: white">閲嶇偣娌燂細</span>
+          <el-select @change="handleChange" v-model="selectValue" placeholder="Select" size="large"
+            style="width: 240px">
+            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
+          </el-select>
         </div>
-        <div v-else v-for="(item, key) in districtList" :key="key" class="district-item" @click="handleClick(item)">
-          <div class="district-item-icon"></div>
-          <div class="district-item-text">{{ item.hdName }}</div>
+
+        <!-- 婊氬姩鍖哄煙 -->
+        <div style="overflow-y: auto; height: 95%">
+          <!-- 鍔犺浇閬僵灞� -->
+          <div v-if="loading" class="loading-overlay">
+            <div class="spinner"></div>
+          </div>
+          <div v-else v-for="(item, key) in districtList" :key="key" class="district-item" @click="handleClick(item)">
+            <div class="district-item-icon"></div>
+            <div class="district-item-text">{{ item.hdName }}</div>
+          </div>
         </div>
       </div>
     </div>
-  </div>
-</template>
+  </template>
 
 <script setup>
 import { ref, onMounted, watch, onBeforeUnmount } from "vue";
@@ -44,6 +45,8 @@
 
 onBeforeUnmount(() => {
   if (route.path !== '/yhgl') {
+    console.log('zzzzzzzzzzzzzzzzzzzzzzzzzz');
+
     handleCleanup();
   }
 });
@@ -112,11 +115,14 @@
     districtList.value = [];
     return;
   }
-
-  districtList.value = simStore.DangerPoint.filter((item) =>
+  const filteredData = simStore.DangerPoint.filter((item) =>
     item.position?.includes(areaName)
   );
-  await initializeDevicePoints();
+
+  if (JSON.stringify(districtList.value) !== JSON.stringify(filteredData)) { // 妫�鏌ユ槸鍚︾湡鐨勯渶瑕佹洿鏂�
+    districtList.value = filteredData;
+    await initializeDevicePoints();
+  }
 };
 
 // 澶勭悊鍖哄煙鍙樺寲浜嬩欢
@@ -128,11 +134,19 @@
   }
   filterDataByArea(areaName);
 };
-watch(() => simStore.DangerShowSwitch, (newValue, oldValue) => {
+let isInitialized = false;
+
+watch(() => simStore.DangerShowSwitch, async (newValue, oldValue) => {
+  console.log('褰撳墠鐘舵�侊細', newValue);
+
   if (newValue) {
-    initializeDevicePoints();
+    if (!isInitialized) {
+      await initializeDevicePoints();
+      isInitialized = true;
+    }
   } else {
-    handleCleanup()
+    handleCleanup();
+    isInitialized = false; // 鎴栬�呬繚鎸佷负 true锛屽彇鍐充簬浣犵殑闇�姹�
   }
 });
 // 鐩戝惉 simStore.DangerPoint 鍙樺寲
@@ -147,8 +161,7 @@
       districtList.value = [];
       loading.value = true; // 鏁版嵁鏈噯澶囧氨缁�
     }
-  },
-  { immediate: true }
+  }
 );
 
 onMounted(() => {

--
Gitblit v1.9.3