From f3fd71635241bd0a98f57830613a4c5a9c922235 Mon Sep 17 00:00:00 2001 From: wzy-warehouse <18135009705@163.com> Date: Sat, 18 Apr 2026 17:34:46 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=84=E8=8C=83=E5=8C=96=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rain-earthquake/HiddenPointComponent.vue | 23 ++++++++++ .../rain-earthquake/HospitalComponent.vue | 21 ++++++++- .../rain-earthquake/RiskPointComponent.vue | 21 +++++++++ .../earthquake/useEarthquakeDisasterChain.ts | 13 ++---- src/hooks/rainstorm/useRainDisasterChain.ts | 13 ++---- src/hooks/useLayerControl.ts | 46 ++----------------- src/hooks/useRightHandle.ts | 24 ++++++++++ src/stores/useStatusStore.ts | 8 ++++ 8 files changed, 107 insertions(+), 62 deletions(-) create mode 100644 src/hooks/useRightHandle.ts diff --git a/src/component/rain-earthquake/HiddenPointComponent.vue b/src/component/rain-earthquake/HiddenPointComponent.vue index fb7bb3a..982de8b 100644 --- a/src/component/rain-earthquake/HiddenPointComponent.vue +++ b/src/component/rain-earthquake/HiddenPointComponent.vue @@ -37,6 +37,7 @@ import { useHiddenPoint } from '@/hooks/rain-earthquake/useHiddenPoint'; import { useStatusStore } from '@/stores/useStatusStore'; import { LoadingResource } from '@/types/common/LoadingResourceType'; + import { useLoadingResourceStore } from '@/stores/useLoadingResourceStore'; // 接收父组件传递的参数 const props = defineProps<{ @@ -97,5 +98,27 @@ } } ); + + // 监听显示隐藏 + watch( + () => useStatusStore().mapLayers.hiddenDangerPointShow.show, + (newValue: boolean) => { + if (newValue) { + // 显示隐患点 + CesiumUtilsSingleton.batchShowPrimitives( + useLoadingResourceStore().getLoadingResource( + LoadingResource.HIDDEN_DANGER_POINT + ) + ); + } else { + // 隐藏隐患点 + CesiumUtilsSingleton.batchHidePrimitives( + useLoadingResourceStore().getLoadingResource( + LoadingResource.HIDDEN_DANGER_POINT + ) + ); + } + } + ); diff --git a/src/component/rain-earthquake/HospitalComponent.vue b/src/component/rain-earthquake/HospitalComponent.vue index a20843d..d5e9b48 100644 --- a/src/component/rain-earthquake/HospitalComponent.vue +++ b/src/component/rain-earthquake/HospitalComponent.vue @@ -7,7 +7,7 @@ :base-points="hospitalPoints" :get-disaster-icon="getDisasterIcon" :prefix="config.prefix.hospitalPointId" - :is-default="true" + :is-default="false" :loading-resource-field="LoadingResource.HOSPITAL" /> @@ -36,6 +36,7 @@ import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils'; import { LoadingResource } from '@/types/common/LoadingResourceType'; import { useHospitalPoint } from '@/hooks/rain-earthquake/useHospitalPoint'; + import { useLoadingResourceStore } from '@/stores/useLoadingResourceStore'; const hospitalPoints = ref([]); @@ -90,6 +91,24 @@ } } ); + + // 监听显示隐藏 + watch( + () => useStatusStore().poiLayers.showHospital.show, + (newValue: boolean) => { + if (newValue) { + // 显示医院 + CesiumUtilsSingleton.batchShowPrimitives( + useLoadingResourceStore().getLoadingResource(LoadingResource.HOSPITAL) + ); + } else { + // 隐藏医院 + CesiumUtilsSingleton.batchHidePrimitives( + useLoadingResourceStore().getLoadingResource(LoadingResource.HOSPITAL) + ); + } + } + ); diff --git a/src/component/rain-earthquake/RiskPointComponent.vue b/src/component/rain-earthquake/RiskPointComponent.vue index 74a291c..b6d043f 100644 --- a/src/component/rain-earthquake/RiskPointComponent.vue +++ b/src/component/rain-earthquake/RiskPointComponent.vue @@ -36,6 +36,7 @@ import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils'; import { useRiskPoint } from '@/hooks/rain-earthquake/useRiskPoint'; import { LoadingResource } from '@/types/common/LoadingResourceType'; + import { useLoadingResourceStore } from '@/stores/useLoadingResourceStore'; const riskPoints = ref([]); @@ -88,6 +89,26 @@ } } ); + + // 监听显示隐藏风险点 + watch( + () => useStatusStore().mapLayers.riskPointShow.show, + (newValue: boolean) => { + if (newValue) { + CesiumUtilsSingleton.batchShowPrimitives( + useLoadingResourceStore().getLoadingResource( + LoadingResource.RISK_POINT + ) + ); + } else { + CesiumUtilsSingleton.batchHidePrimitives( + useLoadingResourceStore().getLoadingResource( + LoadingResource.RISK_POINT + ) + ); + } + } + ); diff --git a/src/hooks/earthquake/useEarthquakeDisasterChain.ts b/src/hooks/earthquake/useEarthquakeDisasterChain.ts index 4484c88..789f7d4 100644 --- a/src/hooks/earthquake/useEarthquakeDisasterChain.ts +++ b/src/hooks/earthquake/useEarthquakeDisasterChain.ts @@ -2,11 +2,10 @@ import { ref } from 'vue'; import type { XianHiddenDangerSpots } from '@/types/base/XianHiddenDangerSpots'; import type { PaginationType } from '@/types/common/PaginationType'; import { PointType } from '@/types/common/DisasterType'; -import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils'; -import config from '@/config/config.json'; import { useStatusStore } from '@/stores/useStatusStore'; import { useLayerControl } from '../useLayerControl'; import { debrisFlowIcon, landslideIcon, riskAreaIcon } from '@/assets'; +import { useRightHandle } from '../useRightHandle'; /** * 暴雨灾害链 @@ -159,18 +158,12 @@ export const useEarthquakeDisasterChain = () => { }, { name: '清除模拟', - callback: () => { - CesiumUtilsSingleton.clearAllResources('custom'); - }, + callback: () => useRightHandle().resetScene(), executeOnce: true, }, { name: '视角重置', - callback: () => { - CesiumUtilsSingleton.flyToTarget( - config.defaultPosition as [number, number, number] - ); - }, + callback: () => useRightHandle().resetView(), executeOnce: true, }, ]; diff --git a/src/hooks/rainstorm/useRainDisasterChain.ts b/src/hooks/rainstorm/useRainDisasterChain.ts index 7d08fb2..c8b9187 100644 --- a/src/hooks/rainstorm/useRainDisasterChain.ts +++ b/src/hooks/rainstorm/useRainDisasterChain.ts @@ -2,8 +2,6 @@ import { ref } from 'vue'; import type { XianHiddenDangerSpots } from '@/types/base/XianHiddenDangerSpots'; import type { PaginationType } from '@/types/common/PaginationType'; import { PointType } from '@/types/common/DisasterType'; -import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils'; -import config from '@/config/config.json'; import { useStatusStore } from '@/stores/useStatusStore'; import { debrisFlowIcon, @@ -13,6 +11,7 @@ import { waterLoggingIcon, } from '@/assets'; import { useLayerControl } from '../useLayerControl'; +import { useRightHandle } from '../useRightHandle'; /** * 暴雨灾害链 @@ -192,18 +191,12 @@ export const useRainDisasterChain = () => { }, { name: '场景重置', - callback: () => { - CesiumUtilsSingleton.clearAllResources('custom'); - }, + callback: () => useRightHandle().resetScene(), executeOnce: true, }, { name: '视角重置', - callback: () => { - CesiumUtilsSingleton.flyToTarget( - config.defaultPosition as [number, number, number] - ); - }, + callback: () => useRightHandle().resetView(), executeOnce: true, }, ]; diff --git a/src/hooks/useLayerControl.ts b/src/hooks/useLayerControl.ts index 35314d1..e86cd7f 100644 --- a/src/hooks/useLayerControl.ts +++ b/src/hooks/useLayerControl.ts @@ -1,7 +1,4 @@ -import { useLoadingResourceStore } from '@/stores/useLoadingResourceStore'; import { useStatusStore } from '@/stores/useStatusStore'; -import { LoadingResource } from '@/types/common/LoadingResourceType'; -import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils'; /** * 控制面板显示隐藏逻辑 @@ -12,49 +9,16 @@ export const useLayerControl = () => { * @param status - 显示隐藏状态 */ const clickHiddenDangerPoint = (status: unknown) => { - if (status as boolean) { - // 显示隐患点 - CesiumUtilsSingleton.batchShowPrimitives( - useLoadingResourceStore().getLoadingResource( - LoadingResource.HIDDEN_DANGER_POINT - ) - ); - - // 显示风险点 - CesiumUtilsSingleton.batchShowPrimitives( - useLoadingResourceStore().getLoadingResource(LoadingResource.RISK_POINT) - ); - } else { - // 隐藏隐患点 - CesiumUtilsSingleton.batchHidePrimitives( - useLoadingResourceStore().getLoadingResource( - LoadingResource.HIDDEN_DANGER_POINT - ) - ); - - // 隐藏风险点 - CesiumUtilsSingleton.batchHidePrimitives( - useLoadingResourceStore().getLoadingResource(LoadingResource.RISK_POINT) - ); - } + // 改变风险点显示状态 + useStatusStore().mapLayers.riskPointShow.show = status as boolean; }; /** * 点击显示医院 */ - const clickHospital = (status: unknown) => { - if (status as boolean) { - useStatusStore().poiLayers.showHospital.loading = true; - // 显示医院 - CesiumUtilsSingleton.batchShowPrimitives( - useLoadingResourceStore().getLoadingResource(LoadingResource.HOSPITAL) - ); - } else { - // 隐藏医院 - CesiumUtilsSingleton.batchHidePrimitives( - useLoadingResourceStore().getLoadingResource(LoadingResource.HOSPITAL) - ); - } + const clickHospital = () => { + // 加载状态为true + useStatusStore().poiLayers.showHospital.loading = true; }; return { clickHiddenDangerPoint, clickHospital }; diff --git a/src/hooks/useRightHandle.ts b/src/hooks/useRightHandle.ts new file mode 100644 index 0000000..861b2fa --- /dev/null +++ b/src/hooks/useRightHandle.ts @@ -0,0 +1,24 @@ +import { useStatusStore } from '@/stores/useStatusStore'; +import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils'; +import config from '@/config/config.json'; + +export const useRightHandle = () => { + /** + * 重置场景 + */ + const resetScene = () => { + CesiumUtilsSingleton.clearAllResources('custom'); + useStatusStore().resetScene(); + }; + + /** + * 重置视角 + */ + const resetView = () => { + CesiumUtilsSingleton.flyToTarget( + config.defaultPosition as [number, number, number] + ); + }; + + return { resetScene, resetView }; +}; diff --git a/src/stores/useStatusStore.ts b/src/stores/useStatusStore.ts index 3beb9ab..7bd435c 100644 --- a/src/stores/useStatusStore.ts +++ b/src/stores/useStatusStore.ts @@ -160,6 +160,13 @@ export const useStatusStore = defineStore('status', () => { // 应用加载状态重置 appLoadingCompleted.value = false; + resetScene(); + }; + + /** + * 重置场景 + */ + const resetScene = () => { // UI 组件显示状态重置 uiComponents.legendShow = { show: true, @@ -264,5 +271,6 @@ export const useStatusStore = defineStore('status', () => { poiLayers, infrastructureLayers, reset, + resetScene, }; });