diff --git a/frontend/mobile-app/lib/features/security/presentation/pages/change_password_page.dart b/frontend/mobile-app/lib/features/security/presentation/pages/change_password_page.dart index 01c15f65..783f3281 100644 --- a/frontend/mobile-app/lib/features/security/presentation/pages/change_password_page.dart +++ b/frontend/mobile-app/lib/features/security/presentation/pages/change_password_page.dart @@ -40,6 +40,9 @@ class _ChangePasswordPageState extends ConsumerState { /// 是否正在加载 bool _isLoading = true; + /// 加载状态是否出错 + bool _isLoadError = false; + @override void initState() { super.initState(); @@ -58,6 +61,7 @@ class _ChangePasswordPageState extends ConsumerState { Future _loadPasswordStatus() async { setState(() { _isLoading = true; + _isLoadError = false; }); try { @@ -73,8 +77,7 @@ class _ChangePasswordPageState extends ConsumerState { } catch (e) { if (mounted) { setState(() { - // 出错时默认已设置密码(注册时必须设置) - _hasPassword = true; + _isLoadError = true; _isLoading = false; }); } @@ -221,7 +224,24 @@ class _ChangePasswordPageState extends ConsumerState { valueColor: AlwaysStoppedAnimation(Color(0xFFD4AF37)), ), ) - : SingleChildScrollView( + : _isLoadError + ? Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon(Icons.error_outline, color: Colors.red, size: 48), + const SizedBox(height: 12), + const Text('加载失败,请重试', style: TextStyle(color: Colors.red)), + const SizedBox(height: 16), + ElevatedButton( + onPressed: _loadPasswordStatus, + style: ElevatedButton.styleFrom(backgroundColor: const Color(0xFFD4AF37)), + child: const Text('重试', style: TextStyle(color: Colors.white)), + ), + ], + ), + ) + : SingleChildScrollView( padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start,