feat: 重构地面站管理逻辑,新增 GroundStationState 接口,优化组件间数据传递

This commit is contained in:
严浩
2025-04-01 16:20:22 +08:00
parent c829eaaf71
commit 99b5aeb042
6 changed files with 151 additions and 90 deletions

View File

@ -33,7 +33,7 @@ export class HCesiumViewerCls {
*/
addGroundStation(options: GroundStationOptions): Cesium.Entity | null {
if (!this.viewer) {
console.error('视图未初始化。无法添加地面站。'); // 使用 console.error 替代抛出错误,以便在 index.vue 中处理
console.error('视图未初始化。无法添加地面站。');
return null;
}
@ -101,13 +101,8 @@ export class HCesiumViewerCls {
}
}
// 移除 highlightStation 和 unhighlightStation 方法
clearAllGroundStations() {
// ... (清理逻辑不变)
if (!this.viewer) return;
// 优化:直接遍历 Map 清理,避免重复查找
// 使用 for...of 循环替代 forEach
for (const entity of this.currentStationEntities.values()) {
this.viewer?.entities.remove(entity);
}
@ -115,7 +110,6 @@ export class HCesiumViewerCls {
}
destroy() {
// ... (销毁逻辑不变)
if (this.viewer) {
this.clearAllGroundStations();
this.viewer.destroy();