修改重置场景逻辑以及修复小bug

bug:当选中某个导航菜单时,再次点击会一直加载
This commit is contained in:
wzy-warehouse
2026-05-06 18:17:54 +08:00
parent 1636ad586d
commit db69828c48
5 changed files with 42 additions and 11 deletions
+2 -6
View File
@@ -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 () => {
+4 -3
View File
@@ -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;
};
/**
+23
View File
@@ -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 };
};
+8 -1
View File
@@ -14,5 +14,12 @@ export const useLeftLegendStore = defineStore('leftLegend', () => {
}
>
> = ref({});
return { legendListInfo };
/**
* 重置左侧图例信息
*/
const resetLegendListInfo = () => {
legendListInfo.value = {};
};
return { legendListInfo, resetLegendListInfo };
});
+5 -1
View File
@@ -10,7 +10,11 @@
</div>
<div class="nav-list">
<router-link
@click="useStatusStore().appLoadingCompleted = false"
@click="
isActive(item.query.identification)
? ''
: (useStatusStore().appLoadingCompleted = false)
"
v-for="(item, index) in topNavMap"
:key="index"
:to="{ name: item.name, query: item.query }"