From db69828c482ff6ae9caae13a8fda0c351736fbfd Mon Sep 17 00:00:00 2001 From: wzy-warehouse <18135009705@163.com> Date: Wed, 6 May 2026 18:17:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=87=8D=E7=BD=AE=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E9=80=BB=E8=BE=91=E4=BB=A5=E5=8F=8A=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=B0=8Fbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bug:当选中某个导航菜单时,再次点击会一直加载 --- src/component/map/MapComponent.vue | 8 ++----- src/hooks/rain-earthquake/useRightHandle.ts | 7 ++++--- src/hooks/useScene.ts | 23 +++++++++++++++++++++ src/stores/useLeftLegendStore.ts | 9 +++++++- src/views/IndexView.vue | 6 +++++- 5 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 src/hooks/useScene.ts diff --git a/src/component/map/MapComponent.vue b/src/component/map/MapComponent.vue index 08b5029..e787039 100644 --- a/src/component/map/MapComponent.vue +++ b/src/component/map/MapComponent.vue @@ -15,7 +15,6 @@ import AdministrativeDivision from './AdministrativeDivision.vue'; import { useStatusStore } from '@/stores/useStatusStore'; - import { useLoadingInformationStore } from '@/stores/useLoadingInformation'; import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils'; import { xiAn } from '@/assets'; @@ -23,13 +22,10 @@ import type { GeoJsonFileType } from '@/types/cesium/GeoJsonFileType'; import config from '@/config/config.json'; import { useMap } from '@/hooks/map/useMap'; + import { useScene } from '@/hooks/useScene'; onBeforeMount(() => { - // 重置所有状态 - useStatusStore().reset(); - - // 重置状态 - useLoadingInformationStore().resetStatue(); + useScene().resetScene(); }); onMounted(async () => { diff --git a/src/hooks/rain-earthquake/useRightHandle.ts b/src/hooks/rain-earthquake/useRightHandle.ts index 301c84a..40bfe0d 100644 --- a/src/hooks/rain-earthquake/useRightHandle.ts +++ b/src/hooks/rain-earthquake/useRightHandle.ts @@ -1,8 +1,8 @@ import { useStatusStore } from '@/stores/useStatusStore.ts'; import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils.ts'; import config from '@/config/config.json'; -import { useButtonSelectedIdStore } from '@/stores/useButtonSelectedIdStore'; import { useLeftLegendStore } from '@/stores/useLeftLegendStore'; +import { useScene } from '../useScene'; export const useRightHandle = () => { /** @@ -63,8 +63,9 @@ export const useRightHandle = () => { */ const resetScene = () => { CesiumUtilsSingleton.clearAllResources('custom'); - useStatusStore().resetScene(); - useButtonSelectedIdStore().resetId(); + useScene().resetScene(); + // 隐藏加载 + useStatusStore().appLoadingCompleted = true; }; /** diff --git a/src/hooks/useScene.ts b/src/hooks/useScene.ts new file mode 100644 index 0000000..5461fda --- /dev/null +++ b/src/hooks/useScene.ts @@ -0,0 +1,23 @@ +import { useButtonSelectedIdStore } from '@/stores/useButtonSelectedIdStore'; +import { useLeftLegendStore } from '@/stores/useLeftLegendStore'; +import { useLoadingInformationStore } from '@/stores/useLoadingInformation'; +import { useStatusStore } from '@/stores/useStatusStore'; + +export const useScene = () => { + // 重置场景 + const resetScene = () => { + // 重置所有状态 + useStatusStore().reset(); + + // 重置状态 + useLoadingInformationStore().resetStatue(); + + // 重置按钮 + useButtonSelectedIdStore().resetId(); + + // 重置左侧图例 + useLeftLegendStore().resetLegendListInfo(); + }; + + return { resetScene }; +}; diff --git a/src/stores/useLeftLegendStore.ts b/src/stores/useLeftLegendStore.ts index 4833ce8..d387bc9 100644 --- a/src/stores/useLeftLegendStore.ts +++ b/src/stores/useLeftLegendStore.ts @@ -14,5 +14,12 @@ export const useLeftLegendStore = defineStore('leftLegend', () => { } > > = ref({}); - return { legendListInfo }; + + /** + * 重置左侧图例信息 + */ + const resetLegendListInfo = () => { + legendListInfo.value = {}; + }; + return { legendListInfo, resetLegendListInfo }; }); diff --git a/src/views/IndexView.vue b/src/views/IndexView.vue index 3285d4a..dab6d56 100644 --- a/src/views/IndexView.vue +++ b/src/views/IndexView.vue @@ -10,7 +10,11 @@