规范化操作
This commit is contained in:
@@ -37,6 +37,7 @@
|
|||||||
import { useHiddenPoint } from '@/hooks/rain-earthquake/useHiddenPoint';
|
import { useHiddenPoint } from '@/hooks/rain-earthquake/useHiddenPoint';
|
||||||
import { useStatusStore } from '@/stores/useStatusStore';
|
import { useStatusStore } from '@/stores/useStatusStore';
|
||||||
import { LoadingResource } from '@/types/common/LoadingResourceType';
|
import { LoadingResource } from '@/types/common/LoadingResourceType';
|
||||||
|
import { useLoadingResourceStore } from '@/stores/useLoadingResourceStore';
|
||||||
|
|
||||||
// 接收父组件传递的参数
|
// 接收父组件传递的参数
|
||||||
const props = defineProps<{
|
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>
|
</script>
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
:base-points="hospitalPoints"
|
:base-points="hospitalPoints"
|
||||||
:get-disaster-icon="getDisasterIcon"
|
:get-disaster-icon="getDisasterIcon"
|
||||||
:prefix="config.prefix.hospitalPointId"
|
:prefix="config.prefix.hospitalPointId"
|
||||||
:is-default="true"
|
:is-default="false"
|
||||||
:loading-resource-field="LoadingResource.HOSPITAL"
|
:loading-resource-field="LoadingResource.HOSPITAL"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -36,6 +36,7 @@
|
|||||||
import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils';
|
import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils';
|
||||||
import { LoadingResource } from '@/types/common/LoadingResourceType';
|
import { LoadingResource } from '@/types/common/LoadingResourceType';
|
||||||
import { useHospitalPoint } from '@/hooks/rain-earthquake/useHospitalPoint';
|
import { useHospitalPoint } from '@/hooks/rain-earthquake/useHospitalPoint';
|
||||||
|
import { useLoadingResourceStore } from '@/stores/useLoadingResourceStore';
|
||||||
|
|
||||||
const hospitalPoints = ref<Point[]>([]);
|
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>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils';
|
import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils';
|
||||||
import { useRiskPoint } from '@/hooks/rain-earthquake/useRiskPoint';
|
import { useRiskPoint } from '@/hooks/rain-earthquake/useRiskPoint';
|
||||||
import { LoadingResource } from '@/types/common/LoadingResourceType';
|
import { LoadingResource } from '@/types/common/LoadingResourceType';
|
||||||
|
import { useLoadingResourceStore } from '@/stores/useLoadingResourceStore';
|
||||||
|
|
||||||
const riskPoints = ref<Point[]>([]);
|
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>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
|||||||
@@ -2,11 +2,10 @@ import { ref } from 'vue';
|
|||||||
import type { XianHiddenDangerSpots } from '@/types/base/XianHiddenDangerSpots';
|
import type { XianHiddenDangerSpots } from '@/types/base/XianHiddenDangerSpots';
|
||||||
import type { PaginationType } from '@/types/common/PaginationType';
|
import type { PaginationType } from '@/types/common/PaginationType';
|
||||||
import { PointType } from '@/types/common/DisasterType';
|
import { PointType } from '@/types/common/DisasterType';
|
||||||
import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils';
|
|
||||||
import config from '@/config/config.json';
|
|
||||||
import { useStatusStore } from '@/stores/useStatusStore';
|
import { useStatusStore } from '@/stores/useStatusStore';
|
||||||
import { useLayerControl } from '../useLayerControl';
|
import { useLayerControl } from '../useLayerControl';
|
||||||
import { debrisFlowIcon, landslideIcon, riskAreaIcon } from '@/assets';
|
import { debrisFlowIcon, landslideIcon, riskAreaIcon } from '@/assets';
|
||||||
|
import { useRightHandle } from '../useRightHandle';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 暴雨灾害链
|
* 暴雨灾害链
|
||||||
@@ -159,18 +158,12 @@ export const useEarthquakeDisasterChain = () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '清除模拟',
|
name: '清除模拟',
|
||||||
callback: () => {
|
callback: () => useRightHandle().resetScene(),
|
||||||
CesiumUtilsSingleton.clearAllResources('custom');
|
|
||||||
},
|
|
||||||
executeOnce: true,
|
executeOnce: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '视角重置',
|
name: '视角重置',
|
||||||
callback: () => {
|
callback: () => useRightHandle().resetView(),
|
||||||
CesiumUtilsSingleton.flyToTarget(
|
|
||||||
config.defaultPosition as [number, number, number]
|
|
||||||
);
|
|
||||||
},
|
|
||||||
executeOnce: true,
|
executeOnce: true,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ import { ref } from 'vue';
|
|||||||
import type { XianHiddenDangerSpots } from '@/types/base/XianHiddenDangerSpots';
|
import type { XianHiddenDangerSpots } from '@/types/base/XianHiddenDangerSpots';
|
||||||
import type { PaginationType } from '@/types/common/PaginationType';
|
import type { PaginationType } from '@/types/common/PaginationType';
|
||||||
import { PointType } from '@/types/common/DisasterType';
|
import { PointType } from '@/types/common/DisasterType';
|
||||||
import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils';
|
|
||||||
import config from '@/config/config.json';
|
|
||||||
import { useStatusStore } from '@/stores/useStatusStore';
|
import { useStatusStore } from '@/stores/useStatusStore';
|
||||||
import {
|
import {
|
||||||
debrisFlowIcon,
|
debrisFlowIcon,
|
||||||
@@ -13,6 +11,7 @@ import {
|
|||||||
waterLoggingIcon,
|
waterLoggingIcon,
|
||||||
} from '@/assets';
|
} from '@/assets';
|
||||||
import { useLayerControl } from '../useLayerControl';
|
import { useLayerControl } from '../useLayerControl';
|
||||||
|
import { useRightHandle } from '../useRightHandle';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 暴雨灾害链
|
* 暴雨灾害链
|
||||||
@@ -192,18 +191,12 @@ export const useRainDisasterChain = () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '场景重置',
|
name: '场景重置',
|
||||||
callback: () => {
|
callback: () => useRightHandle().resetScene(),
|
||||||
CesiumUtilsSingleton.clearAllResources('custom');
|
|
||||||
},
|
|
||||||
executeOnce: true,
|
executeOnce: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '视角重置',
|
name: '视角重置',
|
||||||
callback: () => {
|
callback: () => useRightHandle().resetView(),
|
||||||
CesiumUtilsSingleton.flyToTarget(
|
|
||||||
config.defaultPosition as [number, number, number]
|
|
||||||
);
|
|
||||||
},
|
|
||||||
executeOnce: true,
|
executeOnce: true,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
import { useLoadingResourceStore } from '@/stores/useLoadingResourceStore';
|
|
||||||
import { useStatusStore } from '@/stores/useStatusStore';
|
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 - 显示隐藏状态
|
* @param status - 显示隐藏状态
|
||||||
*/
|
*/
|
||||||
const clickHiddenDangerPoint = (status: unknown) => {
|
const clickHiddenDangerPoint = (status: unknown) => {
|
||||||
if (status as boolean) {
|
// 改变风险点显示状态
|
||||||
// 显示隐患点
|
useStatusStore().mapLayers.riskPointShow.show = 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)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 点击显示医院
|
* 点击显示医院
|
||||||
*/
|
*/
|
||||||
const clickHospital = (status: unknown) => {
|
const clickHospital = () => {
|
||||||
if (status as boolean) {
|
// 加载状态为true
|
||||||
useStatusStore().poiLayers.showHospital.loading = true;
|
useStatusStore().poiLayers.showHospital.loading = true;
|
||||||
// 显示医院
|
|
||||||
CesiumUtilsSingleton.batchShowPrimitives(
|
|
||||||
useLoadingResourceStore().getLoadingResource(LoadingResource.HOSPITAL)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// 隐藏医院
|
|
||||||
CesiumUtilsSingleton.batchHidePrimitives(
|
|
||||||
useLoadingResourceStore().getLoadingResource(LoadingResource.HOSPITAL)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return { clickHiddenDangerPoint, clickHospital };
|
return { clickHiddenDangerPoint, clickHospital };
|
||||||
|
|||||||
@@ -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 };
|
||||||
|
};
|
||||||
@@ -160,6 +160,13 @@ export const useStatusStore = defineStore('status', () => {
|
|||||||
// 应用加载状态重置
|
// 应用加载状态重置
|
||||||
appLoadingCompleted.value = false;
|
appLoadingCompleted.value = false;
|
||||||
|
|
||||||
|
resetScene();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重置场景
|
||||||
|
*/
|
||||||
|
const resetScene = () => {
|
||||||
// UI 组件显示状态重置
|
// UI 组件显示状态重置
|
||||||
uiComponents.legendShow = {
|
uiComponents.legendShow = {
|
||||||
show: true,
|
show: true,
|
||||||
@@ -264,5 +271,6 @@ export const useStatusStore = defineStore('status', () => {
|
|||||||
poiLayers,
|
poiLayers,
|
||||||
infrastructureLayers,
|
infrastructureLayers,
|
||||||
reset,
|
reset,
|
||||||
|
resetScene,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user