Browse Source

!58 修复vite环境变量类型原因导致websocket关闭失效问题
Merge pull request !58 from Lau/N/A

疯狂的狮子Li 1 year ago
parent
commit
d84fee9319
2 changed files with 2 additions and 2 deletions
  1. 1 1
      src/types/env.d.ts
  2. 1 1
      src/utils/websocket.ts

+ 1 - 1
src/types/env.d.ts

@@ -69,7 +69,7 @@ interface ImportMetaEnv {
   VITE_APP_ENV: string;
   VITE_APP_RSA_PUBLIC_KEY: string;
   VITE_APP_CLIENT_ID: string;
-  VITE_APP_WEBSOCKET: boolean;
+  VITE_APP_WEBSOCKET: string;
 }
 interface ImportMeta {
   readonly env: ImportMetaEnv;

+ 1 - 1
src/utils/websocket.ts

@@ -33,7 +33,7 @@ let socketError = 0 as number; // 错误次数
 
 // 初始化socket
 export const initWebSocket = (url: any) => {
-  if (!import.meta.env.VITE_APP_WEBSOCKET) {
+  if (import.meta.env.VITE_APP_WEBSOCKET === 'false') {
     return;
   }
   socketUrl = url;