diff --git a/ruoyi-ui/src/views/board/index.vue b/ruoyi-ui/src/views/board/index.vue index 0036170..cdc3dc0 100644 --- a/ruoyi-ui/src/views/board/index.vue +++ b/ruoyi-ui/src/views/board/index.vue @@ -10,20 +10,20 @@
运行速度:
升降状态:
实时位置:
-
停止
-
0m/s
-
停止
-
位置1#
+
{{ AlarmInfo.deviceStatus }}
+
{{ AlarmInfo.runSpeed }}m/s
+
{{ AlarmInfo.liftStatus }}
+
位置{{ AlarmInfo.realAddr }}#
平均温度
最高温度
最低温度
温差
-
19
-
39
-
19
-
0
+
{{ TemParam.tempAvg }}
+
{{ TemParam.tempMax }}
+
{{ TemParam.tempMin }}
+
{{ TemParam.tempDiff }}
当前状态:巡检中
@@ -303,7 +303,10 @@ export default { top: 58.4, left: 89.7 }, - ] + ], + AlarmInfo:{}, + DeviceInfo:{}, + TemParam:{} } }, components: { @@ -311,6 +314,7 @@ export default { Chart }, mounted() { + this.getData() this.$refs.chart1.setData({ "color": [ "#00ffff", @@ -567,7 +571,37 @@ export default { ] }) }, - methods: {} + methods: { + getData(){ + // 创建一个新的WebSocket实例 + const socket = new WebSocket('ws://192.168.2.165:7181/ws'); + +// 当WebSocket打开时触发 + socket.onopen = function(event) { + console.log('WebSocket 连接已打开'); + }; + +// 当服务器发送消息时触发 + socket.onmessage = function(event) { + console.log('收到消息:', event.data); + if(event.data.AlarmInfo){ + this.AlarmInfo = event.data.AlarmInfo + } + if(event.data.DeviceInfo){ + this.DeviceInfo = event.data.DeviceInfo + } + if(event.data.TemParam){ + this.TemParam = event.data.TemParam + } + }; + +// 当WebSocket关闭时触发 + socket.onclose = function(event) { + console.log('WebSocket 连接已关闭'); + }; + + } + } }