规范化操作

This commit is contained in:
wzy-warehouse
2026-04-18 17:34:46 +08:00
parent da7745b7a9
commit f3fd716352
8 changed files with 107 additions and 62 deletions
@@ -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
)
);
}
}
);
</script>
<style scoped></style>
@@ -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<Point[]>([]);
@@ -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)
);
}
}
);
</script>
<style scoped></style>
@@ -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<Point[]>([]);
@@ -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
)
);
}
}
);
</script>
<style scoped></style>
@@ -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,
},
];
+3 -10
View File
@@ -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,
},
];
+5 -41
View File
@@ -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 };
+24
View File
@@ -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 };
};
+8
View File
@@ -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,
};
});