Refactor: 重构 HCesiumManager

This commit is contained in:
严浩
2025-04-03 12:35:18 +08:00
parent b1c8597936
commit 8198fefe91
21 changed files with 905 additions and 683 deletions

View File

@ -4,7 +4,7 @@ meta:
</route>
<script setup lang="ts">
import type { GroundStationState, SatelliteState } from '@/components/h-cesium-viewer/types';
import type { GroundStationState, SatelliteState } from '@/components/h-cesium-viewer/useHCesiumViewerCls.types';
// 地面站和选中状态
const groundStationState = reactive<GroundStationState>({
@ -79,7 +79,8 @@ const addRandomStation = () => {
longitude: randomLon,
name: `随机站 ${randomId.slice(-4)}`,
});
groundStationState.selectedIds.add(randomId); // 同时将新站点 ID 添加到选中项
// 创建新的 Set 以触发响应式更新
groundStationState.selectedIds = new Set([randomId, ...groundStationState.selectedIds]); // ESLint: 调整顺序
consola.info('添加随机站点:', groundStationState.groundStations.at(-1)); // 使用 .at() 访问最后一个元素
};
@ -90,7 +91,10 @@ const removeLastStation = () => {
if (removedStation) {
consola.info('移除站点:', removedStation);
// 同时从选中项中移除
groundStationState.selectedIds.delete(removedStation.id);
// 创建新的 Set 以触发响应式更新
const newSelectedIds = new Set(groundStationState.selectedIds);
newSelectedIds.delete(removedStation.id);
groundStationState.selectedIds = newSelectedIds;
}
}
};
@ -98,7 +102,7 @@ const removeLastStation = () => {
// 清空所有选中项
const clearAllStations = () => {
groundStationState.groundStations = [];
groundStationState.selectedIds.clear(); // 清空选中项
groundStationState.selectedIds = new Set(); // 创建新的空 Set 以触发响应式更新
consola.info('清空所有站点');
};