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 @@