119 lines
3.6 KiB
Dart
119 lines
3.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:get_it/get_it.dart';
|
|
|
|
import '../../../../core/app/app_user_cubit.dart';
|
|
import '../../../auth/presentation/bloc/auth_cubit.dart'; // 🔥 导入 AuthCubit
|
|
import '../../../remote_control/presentation/bloc/remote_control_cubit.dart';
|
|
import '../widgets/map/test_amap_page.dart';
|
|
import '../widgets/map/testmap_pages.dart';
|
|
|
|
class RoutePlanPage extends StatefulWidget {
|
|
const RoutePlanPage({super.key});
|
|
|
|
@override
|
|
State<RoutePlanPage> createState() => _RoutePlanPageState();
|
|
}
|
|
|
|
class _RoutePlanPageState extends State<RoutePlanPage> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
// 🔥 进入安全模式:防止异地登录推送导致路径规划中断
|
|
GetIt.I<AuthCubit>().enterSafeMode();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
// 🔥 离开安全模式:启动 90 秒倒计时
|
|
GetIt.I<AuthCubit>().exitSafeMode();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
try {
|
|
// 🔥 修复:使用 RemoteControlCubit 的 targetDevice 作为唯一设备数据源
|
|
final userState = context.watch<AppUserCubit>().state;
|
|
final remoteControlState = context.watch<RemoteControlCubit>().state;
|
|
final targetDevice = remoteControlState.targetDevice;
|
|
|
|
// debugPrint('🔍 [RoutePlanPage] targetDevice: ${targetDevice?.deviceName ?? "null"}');
|
|
|
|
// 检查是否有选中的设备
|
|
if (targetDevice == null) {
|
|
return Scaffold(
|
|
body: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
const Icon(
|
|
Icons.devices_other,
|
|
size: 64,
|
|
color: Color(0xFF86909C),
|
|
),
|
|
const SizedBox(height: 16),
|
|
const Text(
|
|
'请先选择设备',
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w500,
|
|
color: Color(0xFF1D2129),
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
'在设备列表或场站中选择要控制的设备',
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: Color(0xFF86909C),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
return Scaffold(
|
|
backgroundColor: const Color(0xFFF7F7F7),
|
|
body: MapPageEnterprise(),
|
|
);
|
|
} catch (e, stackTrace) {
|
|
debugPrint('❌ [RoutePlanPage] 构建错误: $e');
|
|
debugPrint('堆栈跟踪: $stackTrace');
|
|
return Scaffold(
|
|
body: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
const Icon(
|
|
Icons.error_outline,
|
|
size: 64,
|
|
color: Colors.red,
|
|
),
|
|
const SizedBox(height: 16),
|
|
const Text(
|
|
'页面加载失败',
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w500,
|
|
color: Color(0xFF1D2129),
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
'错误: $e',
|
|
style: const TextStyle(
|
|
fontSize: 12,
|
|
color: Colors.red,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
}
|