修复版本管理整包更新无法弹出的问题

完成集成新的登录接口的更换使用
完成集成用户的场站列表接口
完成开发设计选择场站项为全局属性
完成我的页面的个人信息的集成和详情页面的开发
完成设备页面的中无人机机场的列表接口对接入和个项页面的布局的优化
完成设备页面的中无人机机场的详情接口的对接和使用和页面的更新布局
This commit is contained in:
2026-05-29 14:13:34 +08:00
parent 938aac2db9
commit 335c468aac
23 changed files with 1294 additions and 705 deletions

View File

@@ -19,6 +19,7 @@ import '../../../devices/presentation/bloc/devices_cubit.dart';
import '../../../devices/presentation/bloc/device_status_bloc.dart';
import '../../../devices/presentation/bloc/device_status_event.dart';
import '../../../devices/presentation/bloc/devices_state.dart';
import '../../../../features/v2/site/presentation/cubit/site_cubit.dart';
import '../../data/datasources/auth_tcp_datasource.dart';
import '../../data/datasources/impl/auth_tcp_datasource_impl.dart';
import 'auth_state.dart';
@@ -45,23 +46,30 @@ class AuthCubit extends Cubit<AuthState> {
/// App 启动时检查本地缓存
Future<void> appStarted() async {
final logger = GetIt.I<ILoggerService>() as SentryLoggerImpl;
// print("App 启动时检查本地缓存");
final user = await storage.getUser();
logger.logWithLevel(
'启动时检查本地缓存',
level: 'INFO',
data: {'user': user, 'data': user}
);
if (user != null) {
await tcp.connect(host: TCPConsts.TCP_IP, port: TCPConsts.TCP_PORT);
// await _authTcpDatasource.sendAuthPacket();//包括发送认证包和获取列表和切换函数
tcp.startHeartbeat(interval: const Duration(seconds: 4));
// 2. 同步全局 App 状态
appCubit.setAuth(user);
// 3. 进入已登录状态
emit(AuthAuthenticated(user));
} else {
// print("App 启动时检查本地缓存user=null) ");
try {
final user = await storage.getUser();
logger.logWithLevel(
'启动时检查本地缓存',
level: 'INFO',
data: {'user': user != null ? '找到用户: ${user.username}' : '未找到用户'}
);
if (user != null) {
// await tcp.connect(host: TCPConsts.TCP_IP, port: TCPConsts.TCP_PORT);
// await _authTcpDatasource.sendAuthPacket();//包括发送认证包和获取列表和切换函数
// tcp.startHeartbeat(interval: const Duration(seconds: 4));
// 2. 同步全局 App 状态
appCubit.setAuth(user);
// 3. 进入已登录状态
emit(AuthAuthenticated(user));
logger.logWithLevel('✅ [AUTH] 应用启动 - 已恢复登录状态', level: 'INFO');
} else {
logger.logWithLevel('⚠️ [AUTH] 应用启动 - 无本地缓存,进入未登录状态', level: 'INFO');
emit(AuthUnauthenticated());
}
} catch (e) {
logger.logWithLevel('❌ [AUTH] 应用启动检查失败: $e', level: 'ERROR');
emit(AuthUnauthenticated());
}
}
@@ -69,9 +77,9 @@ class AuthCubit extends Cubit<AuthState> {
/// 当 HTTP 登录/注册成功后调用
Future<void> loginSuccess(UserEntity user) async {
await storage.saveUser(user);
await tcp.connect(host: TCPConsts.TCP_IP, port: TCPConsts.TCP_PORT);
// await _authTcpDatasource.sendAuthPacket(); //包括发送认证包和获取列表和切换函数
//tcp.startHeartbeat(interval: const Duration(seconds: 4)); //启动心跳
// await tcp.connect(host: TCPConsts.TCP_IP, port: TCPConsts.TCP_PORT);
// await _authTcpDatasource.sendAuthPacket(); //包括发送认证包和获取列表和切换函数
//tcp.startHeartbeat(interval: const Duration(seconds: 4)); //启动心跳
appCubit.setAuth(user);
emit(AuthAuthenticated(user));
}
@@ -94,6 +102,7 @@ class AuthCubit extends Cubit<AuthState> {
try {
final devicesCubit = GetIt.I<DevicesCubit>();
final deviceStatusBloc = GetIt.I<DeviceStatusBloc>();
final siteCubit = GetIt.I<SiteCubit>();
// 1. 清空设备列表和选中设备
devicesCubit.emit(const DevicesState());
@@ -105,6 +114,11 @@ class AuthCubit extends Cubit<AuthState> {
debugPrint('✅ [AUTH] 已重置 DeviceStatusBloc 状态');
_logger.logWithLevel('✅ [AUTH] 已重置 DeviceStatusBloc 状态');
// 3. 清空全局选中的场站
siteCubit.clearSelectedSite();
debugPrint('✅ [AUTH] 已清空 SiteCubit 选中状态');
_logger.logWithLevel('✅ [AUTH] 已清空 SiteCubit 选中状态');
debugPrint('✅ [AUTH] 所有业务状态已清空');
_logger.logWithLevel('✅ [AUTH] 所有业务状态已清空');
} catch (e) {
@@ -113,22 +127,6 @@ class AuthCubit extends Cubit<AuthState> {
}
}
/// TCP 指令监听
// void _listenToAuthResponse() {
// print('>>> [AUTH] begin指令监听: ');
// _kickOutSub?.cancel(); // 防止重复监听
//
// // 假设 0x12 是踢下线或多设备登录提醒
// _kickOutSub = dispatcher.onJsonMessage(0x12).listen((json) {
// // 如果后端发来指令确认需要退出
// print('>>> [AUTH] 收到 0x12: $json');
// // logout();
// final respond = json['respond'] ?? '';
// if (respond == 'have_logged_in') {
// logout(); // ✅ 只有特定消息才退出
// }
// });
// }
/// TCP 指令监听
void _listenToAuthResponse() {
_logger.logWithLevel('[AUTH] 监听 TCP 0x12 指令...', level: 'DEBUG');

View File

@@ -21,11 +21,11 @@ class LoginCubit extends Cubit<LoginState> {
emit(LoginLoading());
try {
final result = await loginUseCase.call(LoginParams(username, password, sourceType));
final user = sl<AppUserCubit>().state.user;
final devicesCubit = sl<DevicesCubit>();
if (user != null) {
devicesCubit.fetchAllDevices(user.username);
}
// final user = sl<AppUserCubit>().state.user;
// final devicesCubit = sl<DevicesCubit>();
// if (user != null) {
// devicesCubit.fetchAllDevices(user.username);
// }
result.fold((failure) => emit(LoginFailure(failure.message)), (user) {
emit(LoginSuccess(user));
authCubit.loginSuccess(user);

View File

@@ -38,8 +38,11 @@ class _LoginPageState extends State<LoginPage> {
appBar: AppBar(backgroundColor: Colors.white, elevation: 0),
body: BlocListener<LoginCubit, LoginState>(
listener: (context, state) {
debugPrint('🔍 [LOGIN] 登录状态变化: $state');
if (state is LoginSuccess) {
debugPrint('✅ [LOGIN] 登录成功,准备跳转到首页');
context.go(RoutePaths.home);
debugPrint('✅ [LOGIN] 已调用 context.go(RoutePaths.home)');
} else if (state is LoginFailure) {
// 可以在这里弹出简洁的黑白提示框
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('登录失败,${state.message}')));
@@ -89,7 +92,7 @@ class _LoginPageState extends State<LoginPage> {
const SizedBox(height: 16),
const Text(
"账号登录v1.1.4",
"账号登录v1.1.5",
style: TextStyle(fontSize: 28, fontWeight: FontWeight.bold, color: Colors.brown),
),
const SizedBox(height: 8),