chore(mining-app): remove WebSocket debug logs

移除前端 WebSocket 相关的调试日志

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-18 21:34:07 -08:00
parent c05bcc9a76
commit 94153058d8
2 changed files with 7 additions and 38 deletions

View File

@ -1,5 +1,4 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:socket_io_client/socket_io_client.dart' as IO;
///
@ -75,8 +74,6 @@ class PriceWebSocketService {
///
/// [baseUrl] API https://api.example.com
void connect(String baseUrl) {
debugPrint('[PriceWS] 🔌 connect() called with baseUrl: $baseUrl');
// WebSocket URL
// https://api.example.com -> wss://api.example.com/ws/price
_wsUrl = baseUrl
@ -84,8 +81,6 @@ class PriceWebSocketService {
.replaceFirst('http://', 'ws://');
_wsUrl = '$_wsUrl/ws/price';
debugPrint('[PriceWS] 🔌 Constructed WebSocket URL: $_wsUrl');
_doConnect();
}
@ -96,7 +91,6 @@ class PriceWebSocketService {
}
_updateStatus(WebSocketStatus.connecting);
debugPrint('[PriceWS] Connecting to $_wsUrl');
_socket = IO.io(
_wsUrl,
@ -111,14 +105,12 @@ class PriceWebSocketService {
);
_socket!.onConnect((_) {
debugPrint('[PriceWS] ✅ Connected successfully to $_wsUrl');
_updateStatus(WebSocketStatus.connected);
_reconnectAttempts = 0;
_cancelReconnectTimer();
});
_socket!.onDisconnect((reason) {
debugPrint('[PriceWS] ❌ Disconnected, reason: $reason');
_socket!.onDisconnect((_) {
_updateStatus(WebSocketStatus.disconnected);
//
if (_status != WebSocketStatus.disconnected) {
@ -126,31 +118,26 @@ class PriceWebSocketService {
}
});
_socket!.onConnectError((error) {
debugPrint('[PriceWS] ❌ Connect error: $error');
debugPrint('[PriceWS] URL was: $_wsUrl');
_socket!.onConnectError((_) {
_updateStatus(WebSocketStatus.disconnected);
_scheduleReconnect();
});
_socket!.onError((error) {
debugPrint('[PriceWS] ⚠️ Socket error: $error');
_socket!.onError((_) {
//
});
//
_socket!.onConnectTimeout((_) {
debugPrint('[PriceWS] ⏰ Connection timeout');
//
});
//
_socket!.on('priceUpdate', (data) {
try {
debugPrint('[PriceWS] 📊 Received price update: $data');
final update = PriceUpdate.fromJson(data as Map<String, dynamic>);
debugPrint('[PriceWS] 📊 Parsed: price=${update.price}, burnMultiplier=${update.burnMultiplier}');
_priceUpdateController.add(update);
} catch (e) {
debugPrint('[PriceWS] ❌ Parse error: $e, data: $data');
} catch (_) {
//
}
});
@ -161,20 +148,16 @@ class PriceWebSocketService {
///
///
void disconnect() {
debugPrint('[PriceWS] 🔌 disconnect() called, current status: $_status');
_cancelReconnectTimer();
_reconnectAttempts = 0;
if (_socket != null) {
debugPrint('[PriceWS] 🔌 Disposing socket...');
_socket!.disconnect();
_socket!.dispose();
_socket = null;
debugPrint('[PriceWS] 🔌 Socket disposed');
}
_updateStatus(WebSocketStatus.disconnected);
debugPrint('[PriceWS] 🔌 Disconnect complete');
}
///
@ -183,7 +166,6 @@ class PriceWebSocketService {
///
void _scheduleReconnect() {
if (_reconnectAttempts >= _maxReconnectAttempts) {
debugPrint('[PriceWS] Max reconnect attempts reached');
return;
}
@ -200,7 +182,6 @@ class PriceWebSocketService {
);
_reconnectAttempts++;
debugPrint('[PriceWS] Reconnect attempt $_reconnectAttempts in ${delay.inSeconds}s');
_reconnectTimer = Timer(delay, () {
if (_status != WebSocketStatus.connected) {

View File

@ -48,15 +48,11 @@ class _AssetPageState extends ConsumerState<AssetPage> {
@override
void initState() {
super.initState();
debugPrint('[AssetPage] 📱 initState - connecting WebSocket');
// WebSocket
_connectWebSocket();
}
@override
void dispose() {
debugPrint('[AssetPage] 📱 dispose - disconnecting WebSocket');
// WebSocket
_disconnectWebSocket();
_refreshTimer?.cancel();
super.dispose();
@ -64,33 +60,25 @@ class _AssetPageState extends ConsumerState<AssetPage> {
/// WebSocket
void _connectWebSocket() {
debugPrint('[AssetPage] 🔌 _connectWebSocket called');
final wsService = PriceWebSocketService.instance;
// 使 AppConstants baseUrl
debugPrint('[AssetPage] 🔌 Using baseUrl: ${AppConstants.baseUrl}');
wsService.connect(AppConstants.baseUrl);
//
_priceSubscription = wsService.priceUpdates.listen((update) {
debugPrint('[AssetPage] 📊 Received price update: price=${update.price}, multiplier=${update.burnMultiplier}');
if (mounted) {
setState(() {
_currentPrice = update.price;
_currentBurnMultiplier = update.burnMultiplier;
});
debugPrint('[AssetPage] 📊 State updated: _currentPrice=$_currentPrice, _currentBurnMultiplier=$_currentBurnMultiplier');
}
});
debugPrint('[AssetPage] 🔌 WebSocket listener attached');
}
/// WebSocket
void _disconnectWebSocket() {
debugPrint('[AssetPage] 🔌 _disconnectWebSocket called');
_priceSubscription?.cancel();
_priceSubscription = null;
PriceWebSocketService.instance.disconnect();
debugPrint('[AssetPage] 🔌 WebSocket disconnected');
}
/// 使