linxuxiang 5 ヶ月 前
コミット
ced9bc559b
1 ファイル変更6 行追加6 行削除
  1. 6 6
      src/utils/trainWs.ts

+ 6 - 6
src/utils/trainWs.ts

@@ -1,10 +1,10 @@
 import io from 'socket.io-client';
 import { ref, onMounted, onUnmounted } from 'vue';
-const address: any = import.meta.env.VITE_APP_BASE_API;
-const token: any = localStorage.getItem('token');
-const myInfo: any = localStorage.getItem('userInfo');
 
 export function useWs() {
+  const address: any = import.meta.env.VITE_APP_BASE_API;
+  const token: any = localStorage.getItem('token');
+  const myInfo: any = localStorage.getItem('userInfo');
   let socket: any = null; //ws实例对象
   let timerManager: any = {}; //计时器管理
   let parameter: any = {}; //参数
@@ -215,7 +215,7 @@ export function useWs() {
    */
   function sendMessage(type: string, data: any, callback?: () => void) {
     if (socket?.connected) {
-      callback = callback || function () {};
+      callback = callback || function () { };
       //版本2就拼接进去
       if (version == 'v2') {
         type = type + '_' + version;
@@ -240,7 +240,7 @@ export function useWs() {
         demo: parameter.demo,
         test_time: testTime
       },
-      () => {}
+      () => { }
     );
   }
 
@@ -259,7 +259,7 @@ export function useWs() {
         demo: parameter.demo,
         test_time: testTime
       },
-      () => {}
+      () => { }
     );
   }