fix(mobile): always check for updates and add debug logs
- Remove condition that only checked updates when wallet was created - Add debug logging to version checker and self hosted updater - Updates should now prompt on every app launch 🤖 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
2ed1658c16
commit
53320df220
|
|
@ -19,13 +19,16 @@ class SelfHostedUpdater {
|
|||
|
||||
/// 检查并提示更新
|
||||
Future<void> checkAndPromptUpdate(BuildContext context) async {
|
||||
debugPrint('[SelfHostedUpdater] 开始检查更新...');
|
||||
final versionInfo = await versionChecker.checkForUpdate();
|
||||
|
||||
if (versionInfo == null) {
|
||||
debugPrint('Already latest version');
|
||||
debugPrint('[SelfHostedUpdater] 已是最新版本,无需更新');
|
||||
return;
|
||||
}
|
||||
|
||||
debugPrint('[SelfHostedUpdater] 发现新版本: ${versionInfo.version}, versionCode: ${versionInfo.versionCode}');
|
||||
|
||||
if (!context.mounted) return;
|
||||
|
||||
// 检测安装来源
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ class VersionChecker {
|
|||
Future<VersionInfo?> fetchLatestVersion() async {
|
||||
try {
|
||||
final currentInfo = await getCurrentVersion();
|
||||
debugPrint('[VersionChecker] 当前版本: ${currentInfo.version}, buildNumber: ${currentInfo.buildNumber}');
|
||||
debugPrint('[VersionChecker] API URL: $apiBaseUrl/api/app/version/check');
|
||||
|
||||
final response = await _dio.get(
|
||||
'/api/app/version/check',
|
||||
|
|
@ -35,17 +37,22 @@ class VersionChecker {
|
|||
},
|
||||
);
|
||||
|
||||
debugPrint('[VersionChecker] 响应状态: ${response.statusCode}');
|
||||
debugPrint('[VersionChecker] 响应数据: ${response.data}');
|
||||
|
||||
if (response.statusCode == 200 && response.data != null) {
|
||||
// 检查是否需要更新
|
||||
final needUpdate = response.data['needUpdate'] as bool? ?? true;
|
||||
if (!needUpdate) {
|
||||
debugPrint('[VersionChecker] 服务器返回无需更新');
|
||||
return null;
|
||||
}
|
||||
debugPrint('[VersionChecker] 服务器返回需要更新');
|
||||
return VersionInfo.fromJson(response.data);
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
debugPrint('Fetch version failed: $e');
|
||||
debugPrint('[VersionChecker] 获取版本失败: $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,14 +69,8 @@ class _SplashPageState extends ConsumerState<SplashPage> {
|
|||
context.go(RoutePaths.onboarding);
|
||||
}
|
||||
|
||||
// 获取目标路由用于后续检查
|
||||
final targetRoute = authState.isWalletCreated ? RoutePaths.ranking : null;
|
||||
|
||||
// 延迟检查应用更新(跳转后执行,避免阻塞启动)
|
||||
if (targetRoute == RoutePaths.ranking) {
|
||||
// 只在进入主页面时检查更新
|
||||
checkForAppUpdate(context);
|
||||
}
|
||||
// 总是检查应用更新(跳转后执行,避免阻塞启动)
|
||||
checkForAppUpdate(context);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
|||
Loading…
Reference in New Issue