diff --git a/src/http/index.js b/src/http/index.js index 7192a0b..2744f42 100644 --- a/src/http/index.js +++ b/src/http/index.js @@ -6,8 +6,6 @@ function getTleDataFromExternal(path = "") { let uri = `${BASE_URL}/NORAD/elements/gp.php?GROUP=${path}&FORMAT=tle`; return axios.get(uri).then(res => { if (res.status === 200) { - ElMessage.success('获取TLE成功'); - localStorage.setItem(path, res.data); // 缓存TLE数据,减轻数据服务压力 return Promise.resolve(res.data); } else { ElMessage.error('获取TLE失败'); @@ -16,6 +14,4 @@ function getTleDataFromExternal(path = "") { }); } - - export { getTleDataFromExternal }; \ No newline at end of file diff --git a/src/js/SatelliteEntity.js b/src/js/SatelliteEntity.js index 14486ae..49a42a6 100644 --- a/src/js/SatelliteEntity.js +++ b/src/js/SatelliteEntity.js @@ -51,6 +51,7 @@ class SatelliteEntity { createSatelliteEntity() { const start = Cesium.JulianDate.fromIso8601(new Date().toISOString()); const stop = Cesium.JulianDate.addSeconds(start, this.totalSeconds, new Cesium.JulianDate()); + const color = Cesium.Color.fromRandom({ alpha: 1.0 }); let satelliteEntity = { name: this.name, description: this.name, @@ -58,15 +59,15 @@ class SatelliteEntity { position: this._getPositionProperty(), point: { pixelSize: 8, - color: Cesium.Color.fromRandom({ alpha: 1.0 }), + color: color, // scaleByDistance: new Cesium.NearFarScalar(1.5e3, 1, 8.0e8, 0.5), }, path: new Cesium.PathGraphics({ - width: 1, - show: false, + width: 0.5, + show: true, leadTime: this.leadTime, trailTime: this.trailTime, - material: Cesium.Color.LIME, + material: color, }), label: { text: this.name, @@ -79,7 +80,7 @@ class SatelliteEntity { horizontalOrigin: Cesium.VerticalOrigin.LEFT, pixelOffset: new Cesium.Cartesian2(0, 5), fillColor: Cesium.Color.WHITE, - distanceDisplayCondition: new Cesium.DistanceDisplayCondition(10.0, 5000000), + // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(10.0, 50000000), } } return satelliteEntity; diff --git a/src/utils/index.js b/src/utils/index.js new file mode 100644 index 0000000..6d24326 --- /dev/null +++ b/src/utils/index.js @@ -0,0 +1,22 @@ +/** + * 比较两个数组之间的差异 + * + * @param {Array} oldArray - 旧的数组 + * @param {Array} newArray - 新的数组 + * @throws {Error} 如果oldArray或newArray不是数组,则抛出错误 + * @returns {Object} 返回一个对象,包含两个属性:addedItems(新数组中新增的元素)和removedItems(旧数组中被移除的元素) + */ +function compareArrays(oldArray, newArray) { + // 验证参数类型,确保oldArray和newArray都是数组 + if (!Array.isArray(oldArray) || !Array.isArray(newArray)) { + throw new Error('Both oldArray and newArray must be arrays.'); + } + // 使用filter方法找出newArray中oldArray不包含的元素,即新增的元素 + const addedItems = newArray.filter(x => !oldArray.includes(x)); + // 使用filter方法找出oldArray中newArray不包含的元素,即被移除的元素 + const removedItems = oldArray.filter(x => !newArray.includes(x)); + // 返回新增的元素和被移除的元素 + return { addedItems, removedItems }; +} + +export { compareArrays }; \ No newline at end of file diff --git a/src/views/satellite-track/SatelliteTrack.vue b/src/views/satellite-track/SatelliteTrack.vue index 59e06e1..84e2cc3 100644 --- a/src/views/satellite-track/SatelliteTrack.vue +++ b/src/views/satellite-track/SatelliteTrack.vue @@ -4,17 +4,8 @@
- - - - +