From 6a853c53e1663dd371164c4863696c89f6e2720b Mon Sep 17 00:00:00 2001 From: menghao <1584479611@qq.com> Date: Tue, 3 Feb 2026 16:39:51 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-druid.yml | 2 +- ruoyi-ui/.env.development | 2 +- ruoyi-ui/src/views/cesiumMap/index.vue | 48 ++++++++++++---------- ruoyi-ui/vue.config.js | 2 +- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index c40f2aa..037db5c 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -8,7 +8,7 @@ spring: master: url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root - password: A20040303ctw! + password: 123456 # 从库数据源 slave: # 从数据源开关/默认关闭 diff --git a/ruoyi-ui/.env.development b/ruoyi-ui/.env.development index 94cd40e..ebae234 100644 --- a/ruoyi-ui/.env.development +++ b/ruoyi-ui/.env.development @@ -8,7 +8,7 @@ ENV = 'development' VUE_APP_BASE_API = '/dev-api' # 访问地址(绕过 /dev-api 代理,用于解决静态资源/图片访问 401 认证问题) -VUE_APP_BACKEND_URL = 'http://192.168.50.30:8080' +VUE_APP_BACKEND_URL = 'http://192.168.50.145:8080' # 路由懒加载 VUE_CLI_BABEL_TRANSPILE_MODULES = true diff --git a/ruoyi-ui/src/views/cesiumMap/index.vue b/ruoyi-ui/src/views/cesiumMap/index.vue index cf4a945..aec8372 100644 --- a/ruoyi-ui/src/views/cesiumMap/index.vue +++ b/ruoyi-ui/src/views/cesiumMap/index.vue @@ -35,7 +35,7 @@ @delete="deleteEntityFromContextMenu" @update-property="updateEntityProperty" /> - + - +
@@ -358,7 +358,7 @@ export default { const backendUrl = process.env.VUE_APP_BACKEND_URL || ''; return backendUrl + cleanPath; }, - //正式航线渲染函数(style 可选:waypoint { pixelSize, color, outlineColor, outlineWidth },line { style, width, color, gapColor, dashLength }) + //正式航线渲染函数 renderRouteWaypoints(waypoints, routeId = 'default', platformId, platform, style) { if (!waypoints || waypoints.length < 1) return; // 清理旧线 @@ -367,6 +367,12 @@ export default { if (existingLine) { this.viewer.entities.remove(existingLine); } + // 清理属于该航线的旧平台图标 + const platformBillboardId = `route-platform-${routeId}`; + const existingPlatform = this.viewer.entities.getById(platformBillboardId); + if (existingPlatform) { + this.viewer.entities.remove(existingPlatform); + } // 清理所有属于该航线的旧点 waypoints.forEach((wp,index) => { const waypointEntityId = `wp_${routeId}_${wp.id}`; @@ -2785,7 +2791,7 @@ export default { handleLocate() { this.locateDialogVisible = true }, - + handleLocateConfirm(location) { const { lng, lat } = location if (this.viewer) { @@ -2801,29 +2807,29 @@ export default { this.$message.success(`已定位到经度 ${lng.toFixed(4)},纬度 ${lat.toFixed(4)}`) } }, - + handleLocateCancel() { this.$message.info('已取消定位') }, updateSelectOptions(refName, dataList, labelField) { const select = document.querySelector(`select[ref="${refName}"]`) if (!select) return - + const currentValue = select.value select.innerHTML = '' - + const defaultOption = document.createElement('option') defaultOption.value = '' defaultOption.textContent = refName === 'routeSelect' ? '请选择航线' : '请选择航点' select.appendChild(defaultOption) - + dataList.forEach(item => { const option = document.createElement('option') option.value = item.id option.textContent = typeof labelField === 'function' ? labelField(item) : item[labelField] select.appendChild(option) }) - + select.value = currentValue }, initScaleBar() { @@ -3071,25 +3077,25 @@ export default { if (!positions || positions.length < 2) { return -1; } - + let closestDistance = Number.MAX_VALUE; let closestSegmentIndex = -1; - + // 遍历每一段线段 for (let i = 0; i < positions.length - 1; i++) { const startPoint = positions[i]; const endPoint = positions[i + 1]; - + // 计算鼠标在屏幕上的点到线段的距离 const distance = this.distanceToSegment(mousePosition, startPoint, endPoint); - + // 如果距离小于当前最小距离,更新最小距离和对应的段索引 if (distance < closestDistance) { closestDistance = distance; closestSegmentIndex = i; } } - + // 如果最小距离小于一个阈值,返回对应的段索引 const threshold = 10; // 像素阈值 return closestDistance < threshold ? closestSegmentIndex : -1; @@ -3099,30 +3105,30 @@ export default { // 将3D点转换为屏幕坐标 const startScreen = this.viewer.scene.cartesianToCanvasCoordinates(startPoint); const endScreen = this.viewer.scene.cartesianToCanvasCoordinates(endPoint); - + if (!startScreen || !endScreen) { return Number.MAX_VALUE; } - + // 计算线段的向量 const lineVec = [endScreen.x - startScreen.x, endScreen.y - startScreen.y]; // 计算从线段起点到鼠标点的向量 const mouseVec = [mousePosition.x - startScreen.x, mousePosition.y - startScreen.y]; - + // 计算线段的长度平方 const lineLengthSquared = lineVec[0] * lineVec[0] + lineVec[1] * lineVec[1]; - + if (lineLengthSquared === 0) { // 线段长度为0,返回鼠标点到线段起点的距离 return Math.sqrt(mouseVec[0] * mouseVec[0] + mouseVec[1] * mouseVec[1]); } - + // 计算鼠标点在直线上的投影参数t const t = Math.max(0, Math.min(1, (mouseVec[0] * lineVec[0] + mouseVec[1] * lineVec[1]) / lineLengthSquared)); - + // 计算投影点 const projection = [startScreen.x + t * lineVec[0], startScreen.y + t * lineVec[1]]; - + // 计算鼠标点到投影点的距离 const distanceVec = [mousePosition.x - projection[0], mousePosition.y - projection[1]]; return Math.sqrt(distanceVec[0] * distanceVec[0] + distanceVec[1] * distanceVec[1]); diff --git a/ruoyi-ui/vue.config.js b/ruoyi-ui/vue.config.js index 984b3f0..afdf886 100644 --- a/ruoyi-ui/vue.config.js +++ b/ruoyi-ui/vue.config.js @@ -15,7 +15,7 @@ const CompressionPlugin = require('compression-webpack-plugin') const CopyWebpackPlugin = require('copy-webpack-plugin') const name = process.env.VUE_APP_TITLE || '若依管理系统' // 网页标题 -const baseUrl = 'http://192.168.50.30:8080' // 后端接口 +const baseUrl = 'http://192.168.50.145:8080' // 后端接口 const port = process.env.port || process.env.npm_config_port || 80 // 端口 // 定义 Cesium 源码路径