Quellcode durchsuchen

Merge branch 'master' of https://git.nanodreamtech.com/wkw/wallet_app

wkw vor 4 Tagen
Ursprung
Commit
9f5edf9a79
4 geänderte Dateien mit 13 neuen und 107 gelöschten Zeilen
  1. 7 6
      .env
  2. 0 95
      src/common/WebSocketService.js
  3. 3 3
      src/stores/modules/webSocketStore.js
  4. 3 3
      src/updater/update.json

+ 7 - 6
.env

@@ -8,13 +8,14 @@ VITE_DEV_PATH='https://wallet.angeltokens.io'
 VITE_PRO_PATH='https://wallet.angeltokens.io'
 
 
-VITE_IM_PATH_FIlE ='https://nim.angeltokens.io/api/v1/file/'
-VITE_PRO_IM_PATH='https://nim.angeltokens.io'
-VITE_DEV_IM_PATH='https://nim.angeltokens.io' 
+# VITE_IM_PATH_FIlE ='https://nim.angeltokens.io/api/v1/file/'
+# VITE_PRO_IM_WSS ='wss://nim.angeltokens.io/api/v1/socket.io'
+# VITE_PRO_IM_PATH='https://nim.angeltokens.io' 
 
-# VITE_IM_PATH_FIlE ='http://192.168.0.59:8888/api/v1/file/'
-# VITE_PRO_IM_PATH='http://192.168.0.59:8888'
-# VITE_DEV_IM_PATH='http://192.168.0.59:8888'
+
+VITE_IM_PATH_FIlE ='http://192.168.0.59:8888/api/v1/file/'
+VITE_PRO_IM_WSS ='ws://192.168.0.59:8888/api/v1/socket.io'
+VITE_DEV_IM_PATH='http://192.168.0.59:8888'
 
 
 VITE_PRO_BACKEND_PATH='https://backend.angeltoken.net'

+ 0 - 95
src/common/WebSocketService.js

@@ -1,95 +0,0 @@
-export default  class WebSocketService {
-  constructor(url) {
-    this.socket = null;
-    this.url = url;
-    // 心跳定时器
-    this.heartbeatTimer = null;
-    this.heartbeatInterval = 30000; // 30秒
-    // 重连次数
-    this.reconnectAttempts = 50; // 默认重连次数
-    this.maxReconnectAttempts = 100; // 最大重连次数
-    this.reconnectInterval = 2000; // 2秒
-    // 存储回调函数
-    this.onMessageCallback = null; // 存储回调函数
-  }
-
-  // 重连
-  reconnect() {
-    if (this.reconnectAttempts < this.maxReconnectAttempts) {
-      this.reconnectAttempts++;
-      console.log(`尝试重新连接... (${this.reconnectAttempts}/${this.maxReconnectAttempts})`);
-      setTimeout(() => {
-        this.connect();
-      }, this.reconnectInterval);
-    } else {
-      console.error('达到最大重连次数,连接失败');
-    }
-  }
-
-
-  // 开启心跳
-  startHeartbeat() {
-    this.heartbeatTimer = setInterval(() => {
-      this.send({ type: 'heartbeat' });
-    }, this.heartbeatInterval);
-  }
-  // 关闭心跳
-  stopHeartbeat() {
-    if (this.heartbeatTimer) {
-      clearInterval(this.heartbeatTimer);
-      this.heartbeatTimer = null;
-    }
-  }
-  // 连接
-  async connect() {
-    this.socket = new WebSocket(this.url);
-    this.socket.onopen = await this.onOpen.bind(this);
-    this.socket.onmessage = this.onMessage.bind(this);
-    this.socket.onclose = this.onClose.bind(this);
-    this.socket.onerror = this.onError.bind(this);
-  }
-  // 连接成功
-  onOpen() {
-    console.log('WebSocket连接已建立');
-    this.reconnectAttempts = 0;
-    this.startHeartbeat();
-  }
-  // 
-  onMessage(event) {
-    console.log('收到消息:', event.data);
-    if (this.onMessageCallback) {
-      this.onMessageCallback(event.data); // 调用回调函数
-    }
-  }
-  // 接收到错误消息  
-  onClose() {
-    console.log('WebSocket连接已关闭');
-    this.stopHeartbeat();
-    this.reconnect();
-  }
-  // 接收到错误消息  
-  onError(error) {
-    console.error('WebSocket错误:', error);
-  }
-  // 发送消息
-  send(data) {
-    if (this.socket && this.socket.readyState === WebSocket.OPEN) {
-      this.socket.send(JSON.stringify(data));
-    } else {
-      console.error('WebSocket未连接');
-    }
-  }
-  // 关闭连接
-  close() {
-    if (this.socket) {
-      this.socket.close();
-    }
-  }
-}
-
-// urls: [
-//   'turn:124.71.68.142:3478?transport=udp', // 强制UDP
-//   'turn:124.71.68.142:3478?transport=tcp'  // TCP备用
-// ]
-
-// const ws = new WebSocketService(`ws://192.168.0.59:3001/ws?user_id=${userId}`)

+ 3 - 3
src/stores/modules/webSocketStore.js

@@ -21,8 +21,8 @@ export const useWebSocketStore = defineStore("webSocketStore", {
     peer: null, // peer实例
     lockConnection: false, // 锁定连接
     reconnectAttempts: 0, // 重连次数
-    maxReconnectAttempts: 5, // 最大重连次数
-    reconnectInterval: 3000, // 重连间隔
+    maxReconnectAttempts: 80, // 最大重连次数
+    reconnectInterval: 2000, // 重连间隔
     messages: [], // 消息列表
     toUserInfo: {},
     unreadMessages: [], // 未读消息列表
@@ -142,7 +142,7 @@ export const useWebSocketStore = defineStore("webSocketStore", {
 
       this.peer = new RTCPeerConnection();
       this.socket = new WebSocket(
-        `wss://nim.angeltokens.io/api/v1/socket.io?user=${userUuid}`
+        `${import.meta.env.VITE_PRO_IM_WSS}?user=${userUuid}`
       );
       // 连接成功
       this.socket.onopen = () => {

+ 3 - 3
src/updater/update.json

@@ -1,7 +1,7 @@
 {
-  "version": "1.0.51",
-  "releaseDate": "2025-08-11 09:30:28",
-  "checksum": "f6b852b798c387b1ebeea4f567c2532f1f3e1c2a156cae67fb7017fdc9221329",
+  "version": "1.0.52",
+  "releaseDate": "2025-08-11 10:23:59",
+  "checksum": "a7ed6a37c0515bb284ddb3dd538010f20adf8af6e3cb035c29cdf8b60cc5d633",
   "minBinaryVersion": "1.0.0",
   "mandatory": true,
   "upDataDescription": "✨修正一些錯誤。。。。!!!"