From d681b46b3e0355cabaf3b84d7ebb68b7f5bc96f6 Mon Sep 17 00:00:00 2001 From: lixiaolong <702156524@qq.com> Date: Fri, 12 Sep 2025 09:12:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E5=96=84=E6=9C=BA=E5=99=A8?= =?UTF-8?q?=E4=BA=BA=E7=9B=B8=E5=85=B3=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/device/robot.js | 44 ++ .../register/components/Camera/index.vue | 53 +- .../components/DexHand/LeftBottomHand.vue | 22 +- .../components/DexHand/LeftTopHand.vue | 25 +- .../register/components/DexHand/index.vue | 77 ++- src/views/device/robot/ContextMenu.vue | 89 +++ src/views/device/robot/TechButtonWithLine.vue | 547 ++++++++++++++++++ src/views/device/robot/index.vue | 493 +++++++++++++--- vite.config.js | 2 +- 9 files changed, 1254 insertions(+), 98 deletions(-) create mode 100644 src/api/device/robot.js create mode 100644 src/views/device/robot/ContextMenu.vue create mode 100644 src/views/device/robot/TechButtonWithLine.vue diff --git a/src/api/device/robot.js b/src/api/device/robot.js new file mode 100644 index 0000000..b725429 --- /dev/null +++ b/src/api/device/robot.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 查询机器人配置列表 +export function listRobot(query) { + return request({ + url: '/device/robot/list', + method: 'get', + params: query + }) +} + +// 查询机器人配置详细 +export function getRobot(id) { + return request({ + url: '/device/robot/' + id, + method: 'get' + }) +} + +// 新增机器人配置 +export function addRobot(data) { + return request({ + url: '/device/robot', + method: 'post', + data: data + }) +} + +// 修改机器人配置 +export function updateRobot(data) { + return request({ + url: '/device/robot', + method: 'put', + data: data + }) +} + +// 删除机器人配置 +export function delRobot(id) { + return request({ + url: '/device/robot/' + id, + method: 'delete' + }) +} diff --git a/src/views/device/register/components/Camera/index.vue b/src/views/device/register/components/Camera/index.vue index 7c94eac..466ccb9 100644 --- a/src/views/device/register/components/Camera/index.vue +++ b/src/views/device/register/components/Camera/index.vue @@ -17,14 +17,14 @@
- - + +
- - + +
@@ -52,6 +52,18 @@ import { getRegister } from "@/api/device/register"; import { useRoute } from "vue-router"; import { debounce } from 'lodash'; // 引入 lodash 的防抖函数 +// 1. 定义 props +const props = defineProps({ + initialDeviceId: { // 示例 prop,用于从弹窗接收cameraId + type: String, + default: null, + }, + initialTerminalId: { // 示例 prop,用于从弹窗接收 terminalId + type: String, + default: null, + }, +}); + const socket = inject('ws'); const route = useRoute(); const data = reactive({ @@ -189,11 +201,36 @@ watch(() => data.form.rgbCamera, async (newVal) => { subscribeDebounced(newVal, data.terminalId, 'getRGBImageStream'); }); +// 2. 使用 watchEffect 来响应 props 和路由的变化 +watchEffect(() => { + let deviceId = null; + // 优先使用 props 中的值(如果弹窗传入了) + if (props.initialDeviceId) { + deviceId = props.initialDeviceId; + } + // 如果 props 没有传入,再从路由获取(仅当cameraId和terminalId都还没设置时) + // 注意:这里需要根据你实际从路由获取参数的逻辑来调整 + // 假设 route.path.split("/")[3] 是cameraId + if (!props.initialDeviceId && route.path.split("/")[3]) { + deviceId = route.path.split("/")[3]; + // 调用 getRegister 并设置 cameraId + // 注意:这里的 getRegister 函数需要能够处理从路由获取的参数 + + } + getRegister(deviceId).then(res => { + data.cameraId = res.data.deviceCode; + data.terminalId = res.data.idDeDeviceTerminalConfig; + }).catch(error => { + console.error("Error fetching register from route:", error); + }); + +}); + onMounted(() => { - getRegister(route.path.split("/")[3]).then(res => { - data.cameraId = res.data.deviceCode; - data.terminalId = res.data.idDeDeviceTerminalConfig; - }); + // getRegister(route.path.split("/")[3]).then(res => { + // data.cameraId = res.data.deviceCode; + // data.terminalId = res.data.idDeDeviceTerminalConfig; + // }); }); onUnmounted(() => { diff --git a/src/views/device/register/components/DexHand/LeftBottomHand.vue b/src/views/device/register/components/DexHand/LeftBottomHand.vue index 62cf533..27d3d37 100644 --- a/src/views/device/register/components/DexHand/LeftBottomHand.vue +++ b/src/views/device/register/components/DexHand/LeftBottomHand.vue @@ -17,12 +17,30 @@ import { inject } from 'vue'; const emit = defineEmits(['update:bottomSeriesData']); const socket = inject('ws'); const handCanvas = ref(null); -const terminalId = ref('25449ff3fcc7b27da5f69462c5efcec2'); // 待您修改 -const deviceId = ref('hand1'); // 待您修改 +const terminalId = ref(''); // 待您修改 +const deviceId = ref(''); // 待您修改 const frameData = ref({ count: 0, lastTime: 0 }); const isHandSeries = ref(false); const containerRef = ref(null) +// 1. 定义 props +const props = defineProps({ + initialDeviceId: { // 示例 prop,用于从弹窗接收cameraId + type: String, + default: null, + }, + initialTerminalId: { // 示例 prop,用于从弹窗接收 terminalId + type: String, + default: null, + }, +}); + +// 2. 使用 watchEffect 来响应 props 和路由的变化 +watchEffect(() => { + terminalId.value = props.initialTerminalId; + deviceId.value = props.initialDeviceId; +}); + // 矩形定义 const rectangle = [ { x: 24, y: 305, width: 21, height: 20, xCount: 3, yCount: 3 }, // PINKY.TIP diff --git a/src/views/device/register/components/DexHand/LeftTopHand.vue b/src/views/device/register/components/DexHand/LeftTopHand.vue index afcb7e7..5efda72 100644 --- a/src/views/device/register/components/DexHand/LeftTopHand.vue +++ b/src/views/device/register/components/DexHand/LeftTopHand.vue @@ -35,6 +35,26 @@ const handImage = ref(null); const containerRef = ref(null); // 新增:引用父容器 const defaultHandImageInfo = { width: 891, height: 981 }; const imageAspectRatio = defaultHandImageInfo.width / defaultHandImageInfo.height; +const terminalId = ref(''); +const deviceId = ref(''); +// 1. 定义 props +const props = defineProps({ + initialDeviceId: { // 示例 prop,用于从弹窗接收cameraId + type: String, + default: null, + }, + initialTerminalId: { // 示例 prop,用于从弹窗接收 terminalId + type: String, + default: null, + }, +}); + +// 2. 使用 watchEffect 来响应 props 和路由的变化 +watchEffect(() => { + terminalId.value = props.initialTerminalId; + deviceId.value = props.initialDeviceId; + console.log(deviceId.value, terminalId.value,props) +}); const sliders = ref([ { value: 0, defalutHeight: 466, height: 0, x: 120, y: 140, vertical: true, style: {} }, // 小拇指 @@ -46,8 +66,9 @@ const sliders = ref([ ]); function updateSeriesData(value, i) { + console.log(deviceId.value, terminalId.value) loading.value = true; - setDexHandAngle({ deviceId: 'hand1', terminalId: '25449ff3fcc7b27da5f69462c5efcec2', value: value / 100, id: i }).then(() => { + setDexHandAngle({ deviceId: deviceId.value, terminalId: terminalId.value, value: value / 100, id: i }).then(() => { loading.value = false; updateToSeriesData(); }).catch(() => { @@ -110,7 +131,7 @@ const updateSliderPositions = () => { }; const updateToSeriesData = () => { - status({ deviceId: 'hand1', terminalId: '25449ff3fcc7b27da5f69462c5efcec2' }).then((res) => { + status({ deviceId: deviceId.value, terminalId: terminalId.value }).then((res) => { const newTopSeriesData = res.data.handsList.map(item => item.force); emit('update:topSeriesData', newTopSeriesData); }); diff --git a/src/views/device/register/components/DexHand/index.vue b/src/views/device/register/components/DexHand/index.vue index 7caee59..fd33381 100644 --- a/src/views/device/register/components/DexHand/index.vue +++ b/src/views/device/register/components/DexHand/index.vue @@ -3,10 +3,12 @@
- + +
- + +
@@ -17,12 +19,28 @@ \ No newline at end of file diff --git a/src/views/device/robot/TechButtonWithLine.vue b/src/views/device/robot/TechButtonWithLine.vue new file mode 100644 index 0000000..a2a3526 --- /dev/null +++ b/src/views/device/robot/TechButtonWithLine.vue @@ -0,0 +1,547 @@ + + + + + \ No newline at end of file diff --git a/src/views/device/robot/index.vue b/src/views/device/robot/index.vue index 79f3f7a..058ce86 100644 --- a/src/views/device/robot/index.vue +++ b/src/views/device/robot/index.vue @@ -1,29 +1,43 @@ \ No newline at end of file diff --git a/vite.config.js b/vite.config.js index 9bddf63..5256ed3 100644 --- a/vite.config.js +++ b/vite.config.js @@ -36,7 +36,7 @@ export default defineConfig(({mode, command}) => { //赵 http://10.148.108.58:13080 // dev http://10.148.20.34:13080 // target: command === 'build' ? VITE_API_URL : 'http://10.148.20.34:13080', - target: command === 'build' ? VITE_API_URL : 'http://192.168.0.10:13080', + target: command === 'build' ? VITE_API_URL : 'http://127.0.0.1:13080', changeOrigin: true, rewrite: (p) => p.replace(/^\/dev-api/, '') }