From e02bcf418cf71f36196e80c4738b375a329fc98d Mon Sep 17 00:00:00 2001 From: hailin Date: Wed, 25 Feb 2026 08:01:52 -0800 Subject: [PATCH] =?UTF-8?q?fix(mobile-app):=20=E5=8D=87=E7=BA=A7=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E7=A6=81=E6=AD=A2=E7=82=B9=E5=87=BB=E5=A4=96=E9=83=A8?= =?UTF-8?q?=E6=88=96=E8=BF=94=E5=9B=9E=E9=94=AE=E5=85=B3=E9=97=AD=EF=BC=8C?= =?UTF-8?q?=E5=BF=85=E9=A1=BB=E9=80=9A=E8=BF=87=E6=8C=89=E9=92=AE=E6=93=8D?= =?UTF-8?q?=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题: 检测到新版本弹出升级对话框时,用户点击弹窗外部区域或按系统返回键 即可直接关闭弹窗,绕过升级提示,导致用户可能永远不会注意到更新。 修复: 对所有 3 个升级弹窗统一加两层防护: - barrierDismissible: false — 禁止点击弹窗外部区域关闭 - PopScope(canPop: false) — 禁止系统返回键关闭 涉及弹窗: 1. self_hosted_updater.dart - _showSelfHostedUpdateDialog(自建APK更新) 2. self_hosted_updater.dart - _showMarketUpdateDialog(应用市场引导更新) 3. update_service.dart - _checkGooglePlayUpdate(Google Play 更新) 用户必须通过弹窗内按钮操作: - 非强制更新:点击「稍后」/「暂时不更新」关闭,或点击「立即更新」开始更新 - 强制更新:只有「立即更新」按钮,无法跳过 Co-Authored-By: Claude Opus 4.6 --- .../updater/channels/self_hosted_updater.dart | 8 +- .../lib/core/updater/update_service.dart | 78 ++++++++++--------- 2 files changed, 45 insertions(+), 41 deletions(-) diff --git a/frontend/mobile-app/lib/core/updater/channels/self_hosted_updater.dart b/frontend/mobile-app/lib/core/updater/channels/self_hosted_updater.dart index fcf77086..dc2ffa24 100644 --- a/frontend/mobile-app/lib/core/updater/channels/self_hosted_updater.dart +++ b/frontend/mobile-app/lib/core/updater/channels/self_hosted_updater.dart @@ -51,9 +51,9 @@ class SelfHostedUpdater { void _showMarketUpdateDialog(BuildContext context, VersionInfo versionInfo) { showDialog( context: context, - barrierDismissible: !versionInfo.forceUpdate, + barrierDismissible: false, builder: (context) => PopScope( - canPop: !versionInfo.forceUpdate, + canPop: false, child: AlertDialog( title: Text( versionInfo.forceUpdate ? '发现重要更新' : '发现新版本', @@ -144,9 +144,9 @@ class SelfHostedUpdater { BuildContext context, VersionInfo versionInfo) { showDialog( context: context, - barrierDismissible: !versionInfo.forceUpdate, + barrierDismissible: false, builder: (context) => PopScope( - canPop: !versionInfo.forceUpdate, + canPop: false, child: AlertDialog( title: Text( versionInfo.forceUpdate ? '发现重要更新' : '发现新版本', diff --git a/frontend/mobile-app/lib/core/updater/update_service.dart b/frontend/mobile-app/lib/core/updater/update_service.dart index 09df23e2..185e8e83 100644 --- a/frontend/mobile-app/lib/core/updater/update_service.dart +++ b/frontend/mobile-app/lib/core/updater/update_service.dart @@ -110,48 +110,52 @@ class UpdateService { await showDialog( context: context, - builder: (context) => AlertDialog( - title: Text( - '发现新版本', - style: TextStyle( - fontSize: 18.sp, - fontWeight: FontWeight.w600, - color: const Color(0xFF292524), + barrierDismissible: false, + builder: (context) => PopScope( + canPop: false, + child: AlertDialog( + title: Text( + '发现新版本', + style: TextStyle( + fontSize: 18.sp, + fontWeight: FontWeight.w600, + color: const Color(0xFF292524), + ), ), - ), - content: Text( - '有新版本可用,是否立即更新?', - style: TextStyle( - fontSize: 14.sp, - color: const Color(0xFF57534E), + content: Text( + '有新版本可用,是否立即更新?', + style: TextStyle( + fontSize: 14.sp, + color: const Color(0xFF57534E), + ), ), - ), - actions: [ - TextButton( - onPressed: () => Navigator.pop(context), - child: Text( - '稍后', - style: TextStyle( - fontSize: 14.sp, - color: const Color(0xFF78716C), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: Text( + '稍后', + style: TextStyle( + fontSize: 14.sp, + color: const Color(0xFF78716C), + ), ), ), - ), - ElevatedButton( - onPressed: () { - Navigator.pop(context); - GooglePlayUpdater.performFlexibleUpdate(); - }, - style: ElevatedButton.styleFrom( - backgroundColor: const Color(0xFFD4A84B), - foregroundColor: Colors.white, + ElevatedButton( + onPressed: () { + Navigator.pop(context); + GooglePlayUpdater.performFlexibleUpdate(); + }, + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFFD4A84B), + foregroundColor: Colors.white, + ), + child: Text( + '更新', + style: TextStyle(fontSize: 14.sp), + ), ), - child: Text( - '更新', - style: TextStyle(fontSize: 14.sp), - ), - ), - ], + ], + ), ), ); }