优化+摄像头+扫码绑定

This commit is contained in:
2026-08-10 10:00:52 +08:00
parent db70665ced
commit 9dc445eeb5
41 changed files with 2618 additions and 438 deletions

View File

@@ -66,6 +66,9 @@ class AuthCubit extends Cubit<AuthState> {
_listenToAuthResponse();
// 🔥 设置重连耗尽回调:连续4次重连失败后弹窗提示用户退出登录
tcp.onReconnectExhausted = _showReconnectFailedDialog;
// 🔥 设置重连提示回调:重连中/重连成功 SnackBar
tcp.onReconnectStarted = _showReconnectingToast;
tcp.onReconnectSuccess = _showReconnectSuccessToast;
}
/// App 启动时检查本地缓存
@@ -379,24 +382,42 @@ class AuthCubit extends Cubit<AuthState> {
],
),
actions: [
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () {
Navigator.of(dialogContext).pop();
logout();
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF165DFF),
foregroundColor: Colors.white,
elevation: 0,
padding: const EdgeInsets.symmetric(vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
Row(
children: [
Expanded(
child: OutlinedButton(
onPressed: () => Navigator.of(dialogContext).pop(),
style: OutlinedButton.styleFrom(
foregroundColor: const Color(0xFF86909C),
side: const BorderSide(color: Color(0xFFE5E6EB)),
padding: const EdgeInsets.symmetric(vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
child: const Text('取消', style: TextStyle(fontSize: 15)),
),
),
child: const Text('退出登录', style: TextStyle(fontSize: 15)),
),
const SizedBox(width: 12),
Expanded(
child: ElevatedButton(
onPressed: () {
Navigator.of(dialogContext).pop();
logout();
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF165DFF),
foregroundColor: Colors.white,
elevation: 0,
padding: const EdgeInsets.symmetric(vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
child: const Text('退出登录', style: TextStyle(fontSize: 15)),
),
),
],
),
],
);
@@ -412,6 +433,39 @@ class AuthCubit extends Cubit<AuthState> {
}
}
/// 🔥 重连中提示 SnackBar
void _showReconnectingToast() {
try {
final context = navigatorKey.currentContext;
if (context != null) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('TCP重连中...'),
backgroundColor: Color(0xFFFF7D00),
duration: Duration(seconds: 4),
),
);
}
} catch (_) {}
}
/// 🔥 重连成功提示 SnackBar
void _showReconnectSuccessToast() {
try {
final context = navigatorKey.currentContext;
if (context != null) {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('连接成功'),
backgroundColor: Color(0xFF00B42A),
duration: Duration(seconds: 2),
),
);
}
} catch (_) {}
}
/// 🔥 新增:清空所有业务状态,防止数据泄露到新账户
void _clearAllBusinessState() {
try {