马宇豪
2023-10-20 3943ca967f32343d35f9d384669fc7db29863d1d
src/views/bigScreen/components/screen.vue
@@ -564,16 +564,34 @@
        const getGasTLSocket = ()=>{
          initWebSocket('/ws/gas/flux/','气体通量',120)
        }
        const getPath=async()=> {
          try {
            var htt = window.location.protocol;// 获取协议
            var host = window.location.host;// 获取地址和端口号
            return htt+"//"+host;
          } catch (error) {
            console.error('Error fetching config:', error);
            return ''; // 返回一个默认值或者空字符串
          }
        }
        const initWebSocket =async (requireUrl: string,type: string,beat: number)=>{
            if (typeof WebSocket === 'undefined') {
              alert('您的浏览器不支持socket');
            } else {
              // 实例化socket
              if(import.meta.env.MODE == 'development'){
              let uid = userInfos.value.uid
              let url = import.meta.env.VITE_API_URL + requireUrl + `${uid}`
              url = url.replace('https', 'ws').replace('http', 'ws')
              state.socket = new WebSocket(url)
              }else{
                const apiUrl = await getPath();
                let uid = userInfos.value.uid
                let url = apiUrl + import.meta.env.VITE_API_URL + requireUrl + `${uid}`
                url = url.replace('https', 'ws').replace('http', 'ws')
                state.socket = new WebSocket(url)
              }
              // 监听socket连接
              state.socket.onopen = () => {
                console.log('socket连接成功')
@@ -1125,7 +1143,6 @@
          letter-spacing: 4px;
          font-size: 16px;
          font-weight: bolder;
          line-height: 38px;
          color: #11feee;
        }
        .long-tit{