兰宝车间质量管理系统-前端
疯狂的狮子Li
2025-01-20 5e440a7dc434c43eb828fa62cf9c12b0078b8565
src/utils/websocket.ts
@@ -7,7 +7,7 @@
  if (import.meta.env.VITE_APP_WEBSOCKET === 'false') {
    return;
  }
  url = url + '?Authorization=Bearer ' + getToken() + '&clientid=' + import.meta.env.VITE_APP_CLIENT_ID
  url = url + '?Authorization=Bearer ' + getToken() + '&clientid=' + import.meta.env.VITE_APP_CLIENT_ID;
  useWebSocket(url, {
    autoReconnect: {
      // 重连最大次数
@@ -16,14 +16,14 @@
      delay: 1000,
      onFailed() {
        console.log('websocket重连失败');
      },
      }
    },
    heartbeat: {
      message: JSON.stringify({type: 'ping'}),
      message: JSON.stringify({ type: 'ping' }),
      // 发送心跳的间隔
      interval: 10000,
      // 接收到心跳response的超时时间
      pongTimeout: 2000,
      pongTimeout: 2000
    },
    onConnected() {
      console.log('websocket已经连接');