@@ -351,215 +86,53 @@
@@ -1123,10 +217,10 @@ export default {
z-index: 90;
position: relative;
width: 100%;
- border-radius: 10px;
max-width: 470px;
+ border-radius: 10px;
background-color: rgba(255, 255, 255, 0.8);
- box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.2);
+ box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
top: -50px;
opacity: 0;
transition: top 0.5s ease, opacity 1s ease;
@@ -1147,18 +241,15 @@ export default {
.butIconBox {
flex-wrap: wrap;
- /* 允许换行 */
justify-content: flex-start;
- /* 主轴对齐方式 */
align-content: space-around;
- /* 多行在侧轴上的对齐方式 */
}
.butIcon {
border-radius: 10px;
text-align: center;
border: none;
- margin-left: 0px !important;
+ margin-left: 0 !important;
}
.taButGroup {
@@ -1172,7 +263,7 @@ export default {
@media (max-width: 480px) {
.taButGroup {
- height: calc((100vw - 50px)/4);
+ height: calc((100vw - 50px) / 4);
}
.tabContainer {
@@ -1186,7 +277,7 @@ export default {
border-radius: 10px;
padding: 5px;
text-align: center;
- box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.2);
+ box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
}
.taButBG {
diff --git a/src/router/index.js b/src/router/index.js
index bc1fa7e..5b4c703 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -300,6 +300,16 @@ const routes = [
tapName: 'plane'
},
children: [
+ {
+ path: '/planes/swarm',
+ component: () => import('@/views/layout/components/main/planes/swarm'),
+ meta: {
+ title: '集群控制',
+ icon: 'iconfont icon-a-jiqunkongzhianniu_huaban1',
+ roles: ['admin', 'editor'],
+ tapName: 'plane'
+ }
+ },
{
path: '/planes/index/:id/:name', // 动态加载路由时加ID参数
component: () => import('@/views/layout/components/main/planes/index'),
diff --git a/src/store/modules/app.js b/src/store/modules/app.js
index 64cbde2..e37aedd 100644
--- a/src/store/modules/app.js
+++ b/src/store/modules/app.js
@@ -9,7 +9,8 @@ const state = {
/* 页面参数 */
orderSerch: null, // 订单列表页搜索条件
toMessageIdArr: [], // 用户管理 发布公告页面 id临时传参
- toFlyDataIdArr: [] // 飞机飞行数据 临时传参
+ toFlyDataIdArr: [], // 飞机飞行数据 临时传参
+ swarmIdArr: []// 选中的 集群控制飞机ID组
}
const mutations = {
@@ -64,7 +65,12 @@ const mutations = {
// 飞机飞行数据 传递id数组
setToFlyDataIdArr (state, idArr) {
state.toFlyDataIdArr = idArr
+ },
+ // 设置 '选取的集群飞机'id组
+ setSwarmIdArr (state, idArr) {
+ state.swarmIdArr = idArr
}
+
}
const actions = {
diff --git a/src/styles/myIcon.scss b/src/styles/myIcon.scss
index 6534b34..6e0cd14 100644
--- a/src/styles/myIcon.scss
+++ b/src/styles/myIcon.scss
@@ -1 +1 @@
-@import 'https://at.alicdn.com/t/c/font_3703467_793cqnnxv0f.css'; //iconfont阿里巴巴
\ No newline at end of file
+@import 'https://at.alicdn.com/t/c/font_3703467_cqwk36imkj.css'; //iconfont阿里巴巴
\ No newline at end of file
diff --git a/src/views/layout/components/main/home/index.vue b/src/views/layout/components/main/home/index.vue
index 2e0bbce..05d43b8 100644
--- a/src/views/layout/components/main/home/index.vue
+++ b/src/views/layout/components/main/home/index.vue
@@ -73,7 +73,7 @@ export default {
async handler () {
try {
// 等待地图画布准备好
- await waitForMapCanvasReady(this.map)
+ await waitForMapCanvasReady(this.$refs.mapbox.map)
// 画布准备好后执行你自己的逻辑
this.onMapReady()
} catch (err) {
diff --git a/src/views/layout/components/main/planes/index.vue b/src/views/layout/components/main/planes/index.vue
index fd074ef..c9922ee 100644
--- a/src/views/layout/components/main/planes/index.vue
+++ b/src/views/layout/components/main/planes/index.vue
@@ -23,15 +23,21 @@
-
+
米
@@ -128,6 +134,25 @@ export default {
}
this.guidedAlt = height
},
+ // 单架飞机点飞指令,参数:lon, lat, alt
+ flyToSinglePlane (lon, lat, alt) {
+ const lonNum = Number(lon)
+ const latNum = Number(lat)
+ const altNum = Number(alt)
+
+ if (
+ isNaN(lonNum) || isNaN(latNum) || isNaN(altNum) ||
+ lonNum < -180 || lonNum > 180 ||
+ latNum < -90 || latNum > 90
+ ) {
+ this.$message.warning('请输入有效的经纬度(经度-180~180,纬度-90~90)和高度')
+ return false
+ }
+
+ const cmd = `{guidedMode:{lon:${lonNum.toFixed(7)},lat:${latNum.toFixed(7)},alt:${altNum.toFixed(1)}}}`
+ this.publishFun(cmd)
+ return true
+ },
// 地图组件回调地图加载完成后 执行
onMapReady () {
this.mapReady = true// 标记地图加载完成
@@ -190,7 +215,7 @@ export default {
async handler () {
try {
// 等待地图画布准备好
- await waitForMapCanvasReady(this.map)
+ await waitForMapCanvasReady(this.$refs.mapbox.map)
// 画布准备好后执行你自己的逻辑
this.onMapReady()
} catch (err) {
diff --git a/src/views/layout/components/main/planes/swarm.vue b/src/views/layout/components/main/planes/swarm.vue
index fd074ef..6873783 100644
--- a/src/views/layout/components/main/planes/swarm.vue
+++ b/src/views/layout/components/main/planes/swarm.vue
@@ -1,13 +1,12 @@
-
+
@@ -17,21 +16,20 @@
-
+
-
+
-
+
米
@@ -40,14 +38,12 @@
diff --git a/src/views/layout/components/main/register/index.vue b/src/views/layout/components/main/register/index.vue
index 4924826..9b7f0e4 100644
--- a/src/views/layout/components/main/register/index.vue
+++ b/src/views/layout/components/main/register/index.vue
@@ -2,19 +2,21 @@
- 添加
- 删除
-
- 编辑
- 飞行数据
+ 添加
+ 删除
+
+ 编辑
+ 集群控制
+ 飞行数据
-
+
@@ -117,6 +119,20 @@ export default {
this.$message.error('只能选择一条记录')
}
},
+ /**
+ * @description: 跳转到编辑页面
+ */
+ toSwarmPage () {
+ const selId = this.countSelIdArr(this.$refs.myTable.selection)
+ if (selId.length < 2) {
+ this.$message.error('请选择至少两架飞机')
+ return
+ }
+ // 用缓存传参 swarmIdArr
+ this.$store.commit('app/setSwarmIdArr', selId)
+ // 跳转到集群控制页面
+ this.$router.push('/planes/swarm')
+ },
/**
* @description: 跳转到飞机数据统计页面
*/
@@ -155,6 +171,11 @@ export default {
}
}
+.swarmButton {
+ background-color: #7C4DFF;
+ border-color: #7C4DFF
+}
+
.no-wrap-btn-group {
white-space: nowrap;
/* 禁止换行 */
diff --git a/src/views/layout/components/menubar.vue b/src/views/layout/components/menubar.vue
index 40d392c..9c18d13 100644
--- a/src/views/layout/components/menubar.vue
+++ b/src/views/layout/components/menubar.vue
@@ -111,25 +111,34 @@ export default {
}
},
/**
- * @description: 动态加载路由
- */
+ * @description: 动态加载无人机子路由,并保留静态配置(如集群控制)
+ * @param {Array} planes - 飞机对象数组,每个对象包含 id 和 name
+ */
loadRoute (planes) {
- const arr = new Array(0)
- planes.map((item, index) => {
- arr[index] = {
- path: '/planes/index/' + item.id + '/' + item.name,
- component: () => import('@/views/layout/components/main/planes/index.vue'),
- meta: {
- title: item.name,
- icon: 'iconfont icon-wurenji',
- roles: ['admin', 'editor'],
- tapName: 'plane'
- }
+ // 1. 将每架飞机转换为一个路由配置对象
+ const dynamicPlaneRoutes = planes.map((item) => ({
+ path: '/planes/index/' + item.id + '/' + item.name, // 动态路径,携带飞机ID和名称
+ component: () => import('@/views/layout/components/main/planes/index.vue'), // 对应的组件路径
+ meta: {
+ title: item.name, // 用于左侧菜单或标签页显示
+ icon: 'iconfont icon-wurenji', // 图标(可替换)
+ roles: ['admin', 'editor'], // 权限控制
+ tapName: 'plane' // 自定义标记
+ // activeMenu: '/planes/swarm' // 可选:保持菜单高亮在“集群控制”
}
- })
- this.routes.map((element) => {
- if (element.meta.title === '无人机') {
- element.children = arr
+ }))
+
+ // 2. 遍历顶层路由配置,找到 path 为 "/planes" 的主路由
+ this.routes.forEach((element) => {
+ if (element.path === '/planes') {
+ // 3. 过滤原本 children 中的静态路由(排除旧的动态飞机 index 路由)
+ const staticChildren = element.children?.filter(child => !child.path.startsWith('/planes/index/')) || []
+
+ // 4. 合并:静态子路由(如 /planes/swarm) + 动态生成的飞机子路由
+ element.children = [
+ ...staticChildren,
+ ...dynamicPlaneRoutes
+ ]
}
})
}