fix(mining-app): 账户锁定弹窗 5 秒后自动关闭
AlertDialog 不会自动消失,加 Timer 5 秒后 maybePop 自动关闭。 SnackBar 已有 duration:5s 会自动消失。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
fbf8b6c2e9
commit
acc5c2be80
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'dart:async';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
@ -57,27 +58,32 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
||||||
|
|
||||||
ScaffoldMessenger.of(context).clearSnackBars();
|
ScaffoldMessenger.of(context).clearSnackBars();
|
||||||
if (message.contains('锁定')) {
|
if (message.contains('锁定')) {
|
||||||
// 账户已锁定 → 弹窗 + 找回密码
|
// 账户已锁定 → 弹窗 + 找回密码(5秒后自动关闭)
|
||||||
showDialog<void>(
|
showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (ctx) => AlertDialog(
|
builder: (ctx) {
|
||||||
title: const Text('账户已锁定'),
|
Timer(const Duration(seconds: 5), () {
|
||||||
content: Text(message),
|
if (ctx.mounted) Navigator.of(ctx, rootNavigator: true).maybePop();
|
||||||
actions: [
|
});
|
||||||
TextButton(
|
return AlertDialog(
|
||||||
onPressed: () => Navigator.pop(ctx),
|
title: const Text('账户已锁定'),
|
||||||
child: Text('知道了', style: TextStyle(color: AppColors.textSecondaryOf(context))),
|
content: Text(message),
|
||||||
),
|
actions: [
|
||||||
ElevatedButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () => Navigator.pop(ctx),
|
||||||
Navigator.pop(ctx);
|
child: Text('知道了', style: TextStyle(color: AppColors.textSecondaryOf(context))),
|
||||||
context.push(Routes.forgotPassword, extra: _phoneController.text.trim());
|
),
|
||||||
},
|
ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(backgroundColor: _orange),
|
onPressed: () {
|
||||||
child: const Text('找回密码', style: TextStyle(color: Colors.white)),
|
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('还剩')) {
|
} else if (message.contains('还剩')) {
|
||||||
// 密码错误但还有机会 → SnackBar 提醒 + 找回密码入口
|
// 密码错误但还有机会 → SnackBar 提醒 + 找回密码入口
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue