所有一级页面和不分二级页面
This commit is contained in:
104
lib/core/consts/workorder_consts.dart
Normal file
104
lib/core/consts/workorder_consts.dart
Normal file
@@ -0,0 +1,104 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// 工单模块颜色常量
|
||||
class WorkOrderColors {
|
||||
WorkOrderColors._();
|
||||
|
||||
/// 主色调
|
||||
static const Color primary = Color(0xFF165DFF);
|
||||
|
||||
/// 待处理色(橙色)
|
||||
static const Color pending = Color(0xFFFF7D00);
|
||||
|
||||
/// 执行中色(蓝色)
|
||||
static const Color executing = Color(0xFF165DFF);
|
||||
|
||||
/// 已完成色(绿色)
|
||||
static const Color completed = Color(0xFF00B42A);
|
||||
|
||||
/// 背景色
|
||||
static const Color background = Color(0xFFFFFFFF);
|
||||
|
||||
/// 页面背景色
|
||||
static const Color pageBackground = Color(0xFFF7F8FA);
|
||||
|
||||
/// 主要文字色
|
||||
static const Color primaryText = Color(0xFF1D2129);
|
||||
|
||||
/// 次要文字色
|
||||
static const Color secondaryText = Color(0xFF4E5969);
|
||||
|
||||
/// 辅助文字色
|
||||
static const Color auxiliaryText = Color(0xFF86909C);
|
||||
|
||||
/// 分割线颜色
|
||||
static const Color divider = Color(0xFFF0F0F0);
|
||||
|
||||
/// 进度条背景色
|
||||
static const Color progressBackground = Color(0xFFF0F0F0);
|
||||
|
||||
/// 卡片阴影
|
||||
static List<BoxShadow> get cardShadow => [
|
||||
const BoxShadow(
|
||||
color: Color(0x0D000000),
|
||||
blurRadius: 4,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
/// 工单模块尺寸常量
|
||||
class WorkOrderDimensions {
|
||||
WorkOrderDimensions._();
|
||||
|
||||
/// 通用圆角
|
||||
static const double borderRadius = 16.0;
|
||||
|
||||
/// 水平边距
|
||||
static const double horizontalPadding = 16.0;
|
||||
|
||||
/// 模块间距
|
||||
static const double moduleSpacing = 20.0;
|
||||
|
||||
/// 导航栏高度
|
||||
static const double navigationBarHeight = 44.0;
|
||||
|
||||
/// 标签栏高度
|
||||
static const double tabBarHeight = 44.0;
|
||||
}
|
||||
|
||||
/// 全局应用常量 (供 UI 组件使用)
|
||||
class AppConstants {
|
||||
AppConstants._();
|
||||
|
||||
static const Color primaryColor = WorkOrderColors.primary;
|
||||
static const Color backgroundColor = WorkOrderColors.background;
|
||||
static const Color primaryTextColor = WorkOrderColors.primaryText;
|
||||
static const Color secondaryTextColor = WorkOrderColors.secondaryText;
|
||||
static const Color auxiliaryTextColor = WorkOrderColors.auxiliaryText;
|
||||
static const Color pendingColor = WorkOrderColors.pending;
|
||||
static const Color executingColor = WorkOrderColors.executing;
|
||||
static const Color completedColor = WorkOrderColors.completed;
|
||||
|
||||
static const double borderRadius = WorkOrderDimensions.borderRadius;
|
||||
static const double horizontalPadding = WorkOrderDimensions.horizontalPadding;
|
||||
static const double moduleSpacing = WorkOrderDimensions.moduleSpacing;
|
||||
static const double navigationBarHeight = WorkOrderDimensions.navigationBarHeight;
|
||||
|
||||
static List<BoxShadow> get cardShadow => WorkOrderColors.cardShadow;
|
||||
}
|
||||
|
||||
/// 工单状态枚举
|
||||
enum WorkOrderStatus {
|
||||
pending, // 待处理
|
||||
executing, // 执行中
|
||||
completed, // 已完成
|
||||
all, // 全部
|
||||
}
|
||||
|
||||
/// 工单优先级枚举
|
||||
enum WorkOrderPriority {
|
||||
high, // 高
|
||||
medium, // 中
|
||||
low, // 低
|
||||
}
|
||||
@@ -61,6 +61,18 @@ import '../../features/v2/home/data/repositories/home_repository_impl.dart';
|
||||
import '../../features/v2/home/domain/repositories/home_repository.dart';
|
||||
import '../../features/v2/home/domain/usecases/get_home_data_usecase.dart';
|
||||
import '../../features/v2/home/presentation/bloc/home_v2_bloc.dart';
|
||||
import '../../features/v2/device_list/data/datasources/device_remote_datasource.dart' as device_v2;
|
||||
import '../../features/v2/device_list/data/repositories/device_repository_impl.dart' as device_v2_repo;
|
||||
import '../../features/v2/device_list/domain/repositories/device_repository.dart' as device_v2_domain;
|
||||
import '../../features/v2/device_list/domain/usecases/get_device_status_data_usecase.dart' as device_v2_usecase;
|
||||
import '../../features/v2/device_list/presentation/bloc/device_status_bloc.dart' as device_v2_bloc;
|
||||
import '../../features/v2/waring_center/data/datasources/alarm_remote_datasource.dart';
|
||||
import '../../features/v2/waring_center/data/datasources/impl/alarm_remote_datasource_impl.dart';
|
||||
import '../../features/v2/waring_center/data/repositories/alarm_repository_impl.dart';
|
||||
import '../../features/v2/waring_center/domain/repositories/alarm_repository.dart';
|
||||
import '../../features/v2/waring_center/domain/usecases/get_alarm_count_usecase.dart';
|
||||
import '../../features/v2/waring_center/domain/usecases/get_alarm_list_usecase.dart';
|
||||
import '../../features/v2/waring_center/presentation/bloc/alarm_cubit.dart';
|
||||
import '../app/app_user_cubit.dart';
|
||||
import '../localization/locale_cubit.dart';
|
||||
import '../../features/home/presentation/bloc/permission_request_bloc.dart';
|
||||
@@ -194,6 +206,22 @@ Future<void> init() async {
|
||||
sl.registerLazySingleton<GetHomeDataUseCase>(() => GetHomeDataUseCase(sl()));
|
||||
sl.registerFactory<HomeV2Bloc>(() => HomeV2Bloc(sl()));
|
||||
|
||||
/// Device Status V2
|
||||
sl.registerLazySingleton<device_v2.DeviceRemoteDataSource>(() => device_v2.DeviceRemoteDataSourceImpl());
|
||||
sl.registerLazySingleton<device_v2_domain.DeviceRepository>(() => device_v2_repo.DeviceRepositoryImpl(remoteDataSource: sl()));
|
||||
sl.registerLazySingleton<device_v2_usecase.GetDeviceStatusDataUseCase>(() => device_v2_usecase.GetDeviceStatusDataUseCase(repository: sl()));
|
||||
sl.registerFactory<device_v2_bloc.DeviceStatusBloc>(() => device_v2_bloc.DeviceStatusBloc(sl()));
|
||||
|
||||
/// Alarm Center V2
|
||||
sl.registerLazySingleton<AlarmRemoteDataSource>(() => AlarmRemoteDataSourceImpl());
|
||||
sl.registerLazySingleton<AlarmRepository>(() => AlarmRepositoryImpl(sl()));
|
||||
sl.registerLazySingleton<GetAlarmListUseCase>(() => GetAlarmListUseCase(sl()));
|
||||
sl.registerLazySingleton<GetAlarmCountUseCase>(() => GetAlarmCountUseCase(sl()));
|
||||
sl.registerFactory<AlarmCubit>(() => AlarmCubit(
|
||||
getAlarmListUseCase: sl(),
|
||||
getAlarmCountUseCase: sl(),
|
||||
));
|
||||
|
||||
|
||||
/// 5. 状态管理 (Cubit/Bloc)
|
||||
sl.registerLazySingleton(() => AppUserCubit()); // AuthCubit 依赖它,必须先注册
|
||||
|
||||
@@ -6,3 +6,7 @@ class Failure {
|
||||
class NetworkFailure extends Failure {
|
||||
NetworkFailure(super.message);
|
||||
}
|
||||
|
||||
class ServerFailure extends Failure {
|
||||
ServerFailure(super.message);
|
||||
}
|
||||
|
||||
10
lib/core/error/workorder_failure.dart
Normal file
10
lib/core/error/workorder_failure.dart
Normal file
@@ -0,0 +1,10 @@
|
||||
import 'package:maibu_satabot_v2/core/error/failure.dart';
|
||||
|
||||
/// 工单模块特定的失败类型
|
||||
class WorkOrderFailure extends Failure {
|
||||
WorkOrderFailure(super.message);
|
||||
}
|
||||
|
||||
class UnknownFailure extends WorkOrderFailure {
|
||||
UnknownFailure({required String message}) : super(message);
|
||||
}
|
||||
@@ -97,7 +97,7 @@ class TcpClient {
|
||||
try {
|
||||
var packets = _decoder.decode(data);
|
||||
//debugPrint('📦 [TCP] 解码成功,包数量:${packets.length}');
|
||||
_logger.logWithLevel('✅ [TCP] 解码成功,包数量:${packets.length}',shouldLog: true);
|
||||
_logger.logWithLevel('✅ [TCP] 解码成功,包数量:${packets.length}',shouldLog: false);
|
||||
for (var packet in packets) {
|
||||
// 🔥 最根部日志:收到任何推送都打印
|
||||
// debugPrint('📥 [TCP-ROOT] 收到推送 CMD: 0x${packet.command.toRadixString(16).toUpperCase()}, Payload长度: ${packet.payload.length}');
|
||||
@@ -106,23 +106,23 @@ class TcpClient {
|
||||
if (!_controller.isClosed) {
|
||||
_controller.add(packet);
|
||||
//debugPrint('➡️ [TCP] 已分发 CMD: 0x${packet.command.toRadixString(16)}');
|
||||
_logger.logWithLevel('✅ [TCP] 已分发 CMD: 0x${packet.command.toRadixString(16)}' ,shouldLog: true);
|
||||
_logger.logWithLevel('✅ [TCP] 已分发 CMD: 0x${packet.command.toRadixString(16)}' ,shouldLog: false);
|
||||
}
|
||||
if (packet.command == 0xFF) {
|
||||
//debugPrint('收到服务端心跳,自动回复...');
|
||||
_logger.logWithLevel('✅ [TCP] 收到服务端心跳,自动回复...',shouldLog: true);
|
||||
_logger.logWithLevel('✅ [TCP] 收到服务端心跳,自动回复...',shouldLog: false);
|
||||
sendHeartbeat(); // 回复 AB AA FF AA AB
|
||||
}
|
||||
if (packet.command == 0x03) {
|
||||
// debugPrint('⚠️ 收到认证响应:${packet.payload}');
|
||||
_logger.logWithLevel('⚠️ 收到认证响应:${packet.payload}',shouldLog: true);
|
||||
_logger.logWithLevel('⚠️ 收到认证响应:${packet.payload}',shouldLog: false);
|
||||
// 解析 payload 看是否有错误信息
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e, stackTrace) {
|
||||
// debugPrint('❌ [TCP] 解码数据时发生异常:$e\n$stackTrace'); // 🔥 捕获解码异常
|
||||
_logger.logWithLevel('❌ [TCP] 解码数据时发生异常:$e\n$stackTrace', shouldLog: true);
|
||||
_logger.logWithLevel('❌ [TCP] 解码数据时发生异常:$e\n$stackTrace', shouldLog: false);
|
||||
}
|
||||
},
|
||||
onDone: (){
|
||||
@@ -130,7 +130,7 @@ class TcpClient {
|
||||
// debugPrint('来到断线重连!');
|
||||
if (!_isSwitching) {
|
||||
//debugPrint('onDone❌ [TCP] 连接已断开!');
|
||||
_logger.logWithLevel('❌ [TCP] 连接已断开!', shouldLog: true);
|
||||
_logger.logWithLevel('❌ [TCP] 连接已断开!', shouldLog: false);
|
||||
_handleDisconnect();
|
||||
}
|
||||
_isSwitching = false; // 重置标志,以免影响下次
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:maibu_satabot_v2/features/devices/domain/entities/device_entity.
|
||||
import 'package:maibu_satabot_v2/features/home/presentation/routes/home_routes.dart';
|
||||
import 'package:maibu_satabot_v2/features/main_container/presentation/pages/tab_settings_page.dart';
|
||||
import 'package:maibu_satabot_v2/features/my/presentation/routes/my_routes.dart';
|
||||
import 'package:maibu_satabot_v2/features/waring_center/presentation/routes/warning_center_routes.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/waring_center/presentation/routes/alarm_center_routes.dart';
|
||||
|
||||
import '../../features/auth/presentation/bloc/auth_cubit.dart';
|
||||
import '../../features/auth/presentation/bloc/auth_state.dart';
|
||||
@@ -22,11 +22,14 @@ GoRouter createRouter(AuthCubit authCubit) {
|
||||
redirect: (context, state) {
|
||||
final loggedIn = authCubit.state is AuthAuthenticated;
|
||||
final loggingIn = state.matchedLocation == RoutePaths.login;
|
||||
final registering = state.matchedLocation == RoutePaths.register;
|
||||
|
||||
if (!loggedIn && !loggingIn) {
|
||||
// 如果未登录,只允许访问 login 和 register 页面
|
||||
if (!loggedIn && !loggingIn && !registering) {
|
||||
return RoutePaths.login;
|
||||
}
|
||||
if (loggedIn && loggingIn) {
|
||||
// 如果已登录,尝试访问 login 或 register,则跳转到首页
|
||||
if (loggedIn && (loggingIn || registering)) {
|
||||
return RoutePaths.home;
|
||||
}
|
||||
return null;
|
||||
@@ -60,7 +63,7 @@ GoRouter createRouter(AuthCubit authCubit) {
|
||||
...HomeRoutes.routes,
|
||||
...AiRoutes.routes,
|
||||
...MyRoutes.routes,
|
||||
...WarningCenterRoutes.routes,
|
||||
...AlarmCenterRoutes.routes,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user