From acc5c2be8064bff09171f10b8e3224a4910bf006 Mon Sep 17 00:00:00 2001 From: hailin Date: Tue, 10 Mar 2026 21:03:21 -0700 Subject: [PATCH] =?UTF-8?q?fix(mining-app):=20=E8=B4=A6=E6=88=B7=E9=94=81?= =?UTF-8?q?=E5=AE=9A=E5=BC=B9=E7=AA=97=205=20=E7=A7=92=E5=90=8E=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=85=B3=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AlertDialog 不会自动消失,加 Timer 5 秒后 maybePop 自动关闭。 SnackBar 已有 duration:5s 会自动消失。 Co-Authored-By: Claude Sonnet 4.6 --- .../presentation/pages/auth/login_page.dart | 44 +++++++++++-------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/frontend/mining-app/lib/presentation/pages/auth/login_page.dart b/frontend/mining-app/lib/presentation/pages/auth/login_page.dart index 904da732..22131464 100644 --- a/frontend/mining-app/lib/presentation/pages/auth/login_page.dart +++ b/frontend/mining-app/lib/presentation/pages/auth/login_page.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; @@ -57,27 +58,32 @@ class _LoginPageState extends ConsumerState { ScaffoldMessenger.of(context).clearSnackBars(); if (message.contains('锁定')) { - // 账户已锁定 → 弹窗 + 找回密码 + // 账户已锁定 → 弹窗 + 找回密码(5秒后自动关闭) showDialog( context: context, - builder: (ctx) => AlertDialog( - title: const Text('账户已锁定'), - content: Text(message), - actions: [ - TextButton( - onPressed: () => Navigator.pop(ctx), - child: Text('知道了', style: TextStyle(color: AppColors.textSecondaryOf(context))), - ), - ElevatedButton( - onPressed: () { - Navigator.pop(ctx); - context.push(Routes.forgotPassword, extra: _phoneController.text.trim()); - }, - style: ElevatedButton.styleFrom(backgroundColor: _orange), - child: const Text('找回密码', style: TextStyle(color: Colors.white)), - ), - ], - ), + builder: (ctx) { + Timer(const Duration(seconds: 5), () { + if (ctx.mounted) Navigator.of(ctx, rootNavigator: true).maybePop(); + }); + return AlertDialog( + title: const Text('账户已锁定'), + content: Text(message), + actions: [ + TextButton( + onPressed: () => Navigator.pop(ctx), + child: Text('知道了', style: TextStyle(color: AppColors.textSecondaryOf(context))), + ), + ElevatedButton( + onPressed: () { + Navigator.pop(ctx); + context.push(Routes.forgotPassword, extra: _phoneController.text.trim()); + }, + style: ElevatedButton.styleFrom(backgroundColor: _orange), + child: const Text('找回密码', style: TextStyle(color: Colors.white)), + ), + ], + ); + }, ); } else if (message.contains('还剩')) { // 密码错误但还有机会 → SnackBar 提醒 + 找回密码入口