diff --git a/frontend/public/earth/js/controls.js b/frontend/public/earth/js/controls.js index 75d1457d..6ef89950 100644 --- a/frontend/public/earth/js/controls.js +++ b/frontend/public/earth/js/controls.js @@ -3,7 +3,7 @@ import { CONFIG, EARTH_CONFIG } from './constants.js'; import { updateZoomDisplay, showStatusMessage } from './ui.js'; import { toggleTerrain } from './earth.js'; -import { reloadData } from './main.js'; +import { reloadData, clearLockedObject } from './main.js'; import { toggleSatellites, toggleTrails, getShowSatellites, getSatelliteCount } from './satellites.js'; import { toggleCables, getShowCables } from './cables.js'; @@ -228,6 +228,9 @@ function setupTerrainControls() { document.getElementById('toggle-satellites').addEventListener('click', function() { const showSats = !getShowSatellites(); + if (!showSats) { + clearLockedObject(); + } toggleSatellites(showSats); this.classList.toggle('active', showSats); this.querySelector('.tooltip').textContent = showSats ? '隐藏卫星' : '显示卫星'; @@ -246,6 +249,9 @@ function setupTerrainControls() { document.getElementById('toggle-cables').addEventListener('click', function() { const showCables = !getShowCables(); + if (!showCables) { + clearLockedObject(); + } toggleCables(showCables); this.classList.toggle('active', showCables); this.querySelector('.tooltip').textContent = showCables ? '隐藏线缆' : '显示线缆'; diff --git a/frontend/public/earth/js/main.js b/frontend/public/earth/js/main.js index 774fbb2a..9025cb79 100644 --- a/frontend/public/earth/js/main.js +++ b/frontend/public/earth/js/main.js @@ -33,7 +33,7 @@ let lockedObjectType = null; let dragStartTime = 0; let isLongDrag = false; -function clearLockedObject() { +export function clearLockedObject() { hoveredCable = null; hoveredSatellite = null; hoveredSatelliteIndex = null;