From 37d65a944df5ad99c57ed8096c60527a0f5572e6 Mon Sep 17 00:00:00 2001 From: sjl <1716605279@qq.com> Date: Tue, 14 Jan 2025 16:24:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/.env.development | 2 +- .../views/home/components/channelsTest.vue | 49 ++++++++++++++++--- frontend/src/views/home/components/table.vue | 10 ++-- 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/frontend/.env.development b/frontend/.env.development index 8f13788..ca3d07d 100644 --- a/frontend/.env.development +++ b/frontend/.env.development @@ -19,6 +19,6 @@ VITE_API_URL=/api # 开发环境跨域代理,支持配置多个 -VITE_PROXY=[["/api","http://192.168.1.124:18092/"]] +VITE_PROXY=[["/api","http://192.168.1.127:18092/"]] #VITE_PROXY=[["/api","http://192.168.1.125:18092/"]] # VITE_PROXY=[["/api","http://192.168.1.138:8080/"]]张文 diff --git a/frontend/src/views/home/components/channelsTest.vue b/frontend/src/views/home/components/channelsTest.vue index 82a9d55..774753b 100644 --- a/frontend/src/views/home/components/channelsTest.vue +++ b/frontend/src/views/home/components/channelsTest.vue @@ -241,21 +241,56 @@ watch(webMsgSend,function (newValue,oldValue){ item.devName === newValue.data.devName); if (firstCoefficientVO) { // 检查 firstCoefficientVO 是否存在 firstCoefficientVO.aVuData = parseFloat(newValue.data.aVuData).toFixed(4); - firstCoefficientVO.aVuXi = parseFloat((newValue.data.aVuXi / 10000).toFixed(4)).toString(); + + if (!isNaN(parseFloat(newValue.data.aVuXi)) && isFinite(newValue.data.aVuXi)) { + firstCoefficientVO.aVuXi = parseFloat((parseFloat(newValue.data.aVuXi) / 10000).toFixed(4)).toString(); + } else { + firstCoefficientVO.aVuXi = newValue.data.aVuXi; + } + firstCoefficientVO.bVuData = parseFloat(newValue.data.bVuData).toFixed(4); - firstCoefficientVO.bVuXi = parseFloat((newValue.data.bVuXi / 10000).toFixed(4)).toString(); + + if (!isNaN(parseFloat(newValue.data.bVuXi)) && isFinite(newValue.data.bVuXi)) { + firstCoefficientVO.bVuXi = parseFloat((parseFloat(newValue.data.bVuXi) / 10000).toFixed(4)).toString(); + } else { + firstCoefficientVO.bVuXi = newValue.data.bVuXi; + } + firstCoefficientVO.cVuData = parseFloat(newValue.data.cVuData).toFixed(4); - firstCoefficientVO.cVuXi = parseFloat((newValue.data.cVuXi / 10000).toFixed(4)).toString(); + + if (!isNaN(parseFloat(newValue.data.cVuXi)) && isFinite(newValue.data.cVuXi)) { + firstCoefficientVO.cVuXi = parseFloat((parseFloat(newValue.data.cVuXi) / 10000).toFixed(4)).toString(); + } else { + firstCoefficientVO.cVuXi = newValue.data.cVuXi; + } + firstCoefficientVO.aIeData = parseFloat(newValue.data.aIeData).toFixed(4); - firstCoefficientVO.aIeXi = parseFloat((newValue.data.aVuXi / 10000).toFixed(4)).toString(); + + if (!isNaN(parseFloat(newValue.data.aIeXi)) && isFinite(newValue.data.aIeXi)) { + firstCoefficientVO.aIeXi = parseFloat((parseFloat(newValue.data.aIeXi) / 10000).toFixed(4)).toString(); + } else { + firstCoefficientVO.aIeXi = newValue.data.aIeXi; + } + firstCoefficientVO.bIeData = parseFloat(newValue.data.bIeData).toFixed(4); - firstCoefficientVO.bIeXi = parseFloat((newValue.data.bVuXi / 10000).toFixed(4)).toString(); + + if (!isNaN(parseFloat(newValue.data.bIeXi)) && isFinite(newValue.data.bIeXi)) { + firstCoefficientVO.bIeXi = parseFloat((parseFloat(newValue.data.bIeXi) / 10000).toFixed(4)).toString(); + } else { + firstCoefficientVO.bIeXi = newValue.data.bIeXi; + } + firstCoefficientVO.cIeData = parseFloat(newValue.data.cIeData).toFixed(4); - firstCoefficientVO.cIeXi = parseFloat((newValue.data.cVuXi / 10000).toFixed(4)).toString(); + + if (!isNaN(parseFloat(newValue.data.cIeXi)) && isFinite(newValue.data.cIeXi)) { + firstCoefficientVO.cIeXi = parseFloat((parseFloat(newValue.data.cIeXi) / 10000).toFixed(4)).toString(); + } else { + firstCoefficientVO.cIeXi = newValue.data.cIeXi; + } //console.log(newValue.data.devName + '对象:', firstCoefficientVO); activeIndex.value++; } else { - console.log('未找到匹配的'+ newValue.data.devName+'对象'); + //console.log('未找到匹配的'+ newValue.data.devName+'对象'); } } else { //console.log(newValue.data.devName + '数组为空'); diff --git a/frontend/src/views/home/components/table.vue b/frontend/src/views/home/components/table.vue index 347b417..14118ac 100644 --- a/frontend/src/views/home/components/table.vue +++ b/frontend/src/views/home/components/table.vue @@ -958,11 +958,11 @@ const handleTest = async (val:string) => { return } - // 检查 socketClient.Instance 是否存在 - if (!socketClient.Instance) { - console.error('WebSocket 客户端实例不存在'); - return; - } + // // 检查 socketClient.Instance 是否存在 + // if (!socketClient.Instance) { + // console.error('WebSocket 客户端实例不存在'); + // return; + // } //开始创建webSocket客户端 const data = reactive({