fix(mobile-app): 修复开机动画卡住问题
问题原因: 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 <noreply@anthropic.com>
This commit is contained in:
parent
ca1bc74b2a
commit
fabfbb73fe
|
|
@ -40,10 +40,11 @@ class TelemetryConfig {
|
|||
Future<void> 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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue