From 7bfff647374964ce84cd734ac6928231a8e06d02 Mon Sep 17 00:00:00 2001
From: zhanghao <774378400@qq.com>
Date: Mon, 17 Aug 2026 15:04:33 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=A0=B9=E6=8D=AE=E6=9C=BA=E6=A2=B0?=
=?UTF-8?q?=E8=87=82=E7=9A=84=E6=95=B0=E9=87=8F=E6=9D=A5=E5=88=A4=E6=96=AD?=
=?UTF-8?q?=E6=9C=BA=E5=99=A8=E4=BA=BA=E7=9A=84=E7=B1=BB=E5=9E=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components.d.ts | 2 -
src/views/Address.vue | 91 +++++++++++++++++++++----------------------
2 files changed, 45 insertions(+), 48 deletions(-)
diff --git a/components.d.ts b/components.d.ts
index c1980dc..e1f9c9a 100644
--- a/components.d.ts
+++ b/components.d.ts
@@ -13,8 +13,6 @@ declare module 'vue' {
export interface GlobalComponents {
ElButton: typeof import('element-plus/es')['ElButton']
ElContainer: typeof import('element-plus/es')['ElContainer']
- ElForm: typeof import('element-plus/es')['ElForm']
- ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElHeader: typeof import('element-plus/es')['ElHeader']
ElIcon: typeof import('element-plus/es')['ElIcon']
ElInput: typeof import('element-plus/es')['ElInput']
diff --git a/src/views/Address.vue b/src/views/Address.vue
index 45757d0..11b1715 100644
--- a/src/views/Address.vue
+++ b/src/views/Address.vue
@@ -27,14 +27,6 @@
-
-
-
-
-
-
-
-
进入上位机控制页面
连接异常排查:检查机器人状态、局域网联通、设备ID调谐是否匹配
@@ -62,23 +54,33 @@ const selectedDevices = computed(() => Object.entries(selectedRobot.value?.devic
([kind, devices]) => devices.map(device => ({ kind, ...device }))
))
let refreshTimer
-const ruleFormRef = ref()
-const ruleForm = ref({
- robotType: 'inspection',
-})
-const rules = ref({
- robotType: [
- { required: true, message: '请选择机器人类型', trigger: 'blur' }
- ],
-})
+/**
+ * 通过机械臂数量判断机器人类型
+ * 1 个机械臂为巡检机器人,2 个机械臂为讲解机器人
+ * @param robot
+ */
+const getRobotType = (robot) => {
+ const armCount = robot?.devices?.arm?.length || 0
+ if (armCount === 1) return 'inspection'
+ if (armCount === 2) return 'explanation'
+ return ''
+}
+/**
+ * 选择机器人并且设置机器人类型
+ */
const selectRobot = () => {
const robot = selectedRobot.value
if (!robot) return
robotStore.setRobotId(robot.robotId)
+ const robotType = getRobotType(robot)
+ if (robotType) robotStore.setRobotType(robotType)
}
+/**
+ * 加载机器人列表
+ */
const loadRobots = async () => {
robotListLoading.value = true
try {
@@ -101,32 +103,34 @@ const testConnect = async () => {
ElMessage.warning('请先选择已连接机器人')
return
}
- const valid = await ruleFormRef.value.validate();
- if (valid) {
- loading.value = true
- robotStore.setRobotId(selectedRobot.value.robotId)
- robotStore.setRobotType(ruleForm.value.robotType)
- selectRobot()
-
- try {
- const result = await getRuntimeState()
- loading.value = false
- if (result.code === 200) {
- robotStore.setPosition(result.data.pose)
- robotStore.setBattery(result.data.battery)
- robotStore.setCurrentMap(result.data.current_map)
- router.push({
- path: '/home'
- })
- } else {
- ElMessage.error(result?.message || result?.error || '连接服务错误')
- }
- }
- catch (error) {
- loading.value = false
- ElMessage.error(error?.message || '连接服务错误')
+ const robotType = getRobotType(selectedRobot.value)
+ if (!robotType) {
+ ElMessage.warning('机器人机械臂数量异常,无法判断机器人类型')
+ return
+ }
+
+ loading.value = true
+ robotStore.setRobotId(selectedRobot.value.robotId)
+ robotStore.setRobotType(robotType)
+
+ try {
+ const result = await getRuntimeState()
+ loading.value = false
+ if (result.code === 200) {
+ robotStore.setPosition(result.data.pose)
+ robotStore.setBattery(result.data.battery)
+ robotStore.setCurrentMap(result.data.current_map)
+ router.push({
+ path: '/home'
+ })
+ } else {
+ ElMessage.error(result?.message || result?.error || '连接服务错误')
}
}
+ catch (error) {
+ loading.value = false
+ ElMessage.error(error?.message || '连接服务错误')
+ }
}
@@ -174,11 +178,6 @@ const testConnect = async () => {
margin-bottom: 12px;
}
- :deep(.el-form-item__label) {
- font-size: 16px;
- line-height: 40px;
- }
-
:deep(.el-input__inner) {
height: 40px;
// 避免 iPad Safari 聚焦小字号输入框时自动缩放页面。