Files
xian_vue_new/src/hooks/rain-earthquake/useRightHandle.ts
T

57 lines
1.6 KiB
TypeScript
Raw Normal View History

import { useStatusStore } from '@/stores/useStatusStore.ts';
import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils.ts';
2026-04-18 17:34:46 +08:00
import config from '@/config/config.json';
2026-05-06 17:44:30 +08:00
import { useLeftLegendStore } from '@/stores/useLeftLegendStore';
2026-05-06 18:17:54 +08:00
import { useScene } from '../useScene';
2026-05-07 10:39:34 +08:00
import { useRainstormDeduction } from '../rainstorm/useRainstormDeduction';
2026-04-18 17:34:46 +08:00
export const useRightHandle = () => {
2026-05-05 17:09:32 +08:00
/**
* 暴雨模拟
* @param status - 状态
*/
const rainstormSimulation = (status: unknown) => {
if (status as boolean) {
2026-05-07 10:39:34 +08:00
// 显示步骤
useRainstormDeduction().showStep();
// 开启暴雨模拟:显示降雨栅格图层
useStatusStore().weatherLayers.showRainfallGrid.loading = true;
useStatusStore().weatherLayers.showRainfallGrid.show = true;
2026-05-06 17:44:30 +08:00
2026-05-06 18:02:56 +08:00
// 添加图例
2026-05-07 10:39:34 +08:00
useRainstormDeduction().addLegend();
} else {
// 关闭暴雨模拟:隐藏降雨栅格图层
useStatusStore().weatherLayers.showRainfallGrid.show = false;
2026-05-06 17:44:30 +08:00
2026-05-06 18:02:56 +08:00
// 删除图例
delete useLeftLegendStore().legendListInfo.precipitation;
2026-05-07 10:39:34 +08:00
// 隐藏步骤条
useStatusStore().uiComponents.stepBar.show = false;
2026-05-05 17:09:32 +08:00
}
};
2026-04-18 17:34:46 +08:00
/**
* 重置场景
*/
const resetScene = () => {
CesiumUtilsSingleton.clearAllResources('custom');
2026-05-06 18:17:54 +08:00
useScene().resetScene();
// 隐藏加载
useStatusStore().appLoadingCompleted = true;
2026-04-18 17:34:46 +08:00
};
/**
* 重置视角
*/
const resetView = () => {
CesiumUtilsSingleton.flyToTarget(
config.defaultPosition as [number, number, number]
);
};
2026-05-05 17:09:32 +08:00
return { rainstormSimulation, resetScene, resetView };
2026-04-18 17:34:46 +08:00
};