From fabfbb73fe09eec32d6477399c79ef0ce7d87d94 Mon Sep 17 00:00:00 2001 From: hailin Date: Fri, 9 Jan 2026 08:08:21 -0800 Subject: [PATCH] =?UTF-8?q?fix(mobile-app):=20=E4=BF=AE=E5=A4=8D=E5=BC=80?= =?UTF-8?q?=E6=9C=BA=E5=8A=A8=E7=94=BB=E5=8D=A1=E4=BD=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题原因: 1. TelemetryConfig.syncFromRemote() URL拼接错误,导致请求无效路径 2. 遥测配置同步使用await阻塞,即使失败也要等待超时 修复内容: 1. 修正URL拼接:apiBaseUrl已包含/api/v1,不再重复添加 2. 将超时时间从10秒缩短为5秒 3. 将遥测配置同步改为非阻塞,不再await等待 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../lib/core/telemetry/models/telemetry_config.dart | 7 ++++--- .../mobile-app/lib/core/telemetry/telemetry_service.dart | 7 +++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/frontend/mobile-app/lib/core/telemetry/models/telemetry_config.dart b/frontend/mobile-app/lib/core/telemetry/models/telemetry_config.dart index 719c4ded..06cd6de1 100644 --- a/frontend/mobile-app/lib/core/telemetry/models/telemetry_config.dart +++ b/frontend/mobile-app/lib/core/telemetry/models/telemetry_config.dart @@ -40,10 +40,11 @@ class TelemetryConfig { Future syncFromRemote(String apiBaseUrl) async { try { final dio = Dio(BaseOptions( - connectTimeout: const Duration(seconds: 10), - receiveTimeout: const Duration(seconds: 10), + connectTimeout: const Duration(seconds: 5), + receiveTimeout: const Duration(seconds: 5), )); - final response = await dio.get('$apiBaseUrl/api/telemetry/config'); + // apiBaseUrl 已经包含 /api/v1,所以这里只需要添加相对路径 + final response = await dio.get('$apiBaseUrl/telemetry/config'); final data = response.data; globalEnabled = data['global_enabled'] ?? true; diff --git a/frontend/mobile-app/lib/core/telemetry/telemetry_service.dart b/frontend/mobile-app/lib/core/telemetry/telemetry_service.dart index a4626c26..419c0a39 100644 --- a/frontend/mobile-app/lib/core/telemetry/telemetry_service.dart +++ b/frontend/mobile-app/lib/core/telemetry/telemetry_service.dart @@ -71,8 +71,11 @@ class TelemetryService { // 3. 加载用户选择 await TelemetryConfig().loadUserOptIn(); - // 4. 同步远程配置(首次) - await TelemetryConfig().syncFromRemote(apiBaseUrl); + // 4. 同步远程配置(非阻塞,后台执行) + // 不阻塞启动流程,使用本地缓存的配置先启动 + TelemetryConfig().syncFromRemote(apiBaseUrl).catchError((e) { + debugPrint('📊 [Telemetry] Remote config sync failed (non-blocking): $e'); + }); // 5. 收集设备信息 _deviceContext = await DeviceInfoCollector().collect(context);