riku
2025-04-28 3acec796e54dc2f5e7d93e8ca72db7da9ec46f60
src/views/inspection/WorkStream.vue
@@ -79,7 +79,9 @@
  if (socket) {
    socket.close()
  }
  socket = new WebSocket(`ws://192.168.0.138:8082/workstream`)
  const url = 'ws://' + ws + '/workstream'
  // socket = new WebSocket(`ws://192.168.0.138:8080/workstream`)
  socket = new WebSocket(url)
  // 与服务器建立连接:发送消息到服务器
  socket.onopen = () => {
    console.log('connect: ')
@@ -110,16 +112,16 @@
}
onMounted(() => {
  handleLink()
  // setInterval(() => {
  //   streams.push({
  //     time: dayjs().format('YYYY-MM-DD HH:mm:ss'),
  //     user: users[parseInt(Math.random() * users.length)],
  //     obj: objs[parseInt(Math.random() * objs.length)],
  //     event: events[parseInt(Math.random() * events.length)]
  //   })
  //   scrollToBottom()
  // }, 10000)
  // handleLink()
  setInterval(() => {
    streams.push({
      time: dayjs().format('YYYY-MM-DD HH:mm:ss'),
      userName: users[parseInt(Math.random() * users.length)],
      obj: objs[parseInt(Math.random() * objs.length)],
      event: events[parseInt(Math.random() * events.length)]
    })
    scrollToBottom()
  }, 5000)
})
onUnmounted(() => {
  socket.close()