规范化操作
This commit is contained in:
@@ -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,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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 };
|
||||
};
|
||||
Reference in New Issue
Block a user