1.优化补足了首页下拉刷新中对获取场站接口的加入,确保能够实时获取数据并渲染。
2.优化修改了tcp重连机制,具体操作:断开重连时候不再建立新链接 而是将旧链接重置,并重新发送数据。 3.大面积的给项目中的各个页面 手动接入了多语言的支持。同时也调整了相应带来的问题英文长度较大影响原有的样式的问题,已解决了对应的样式不和谐问题。保证了外观的统一性。 4.给项目中的主要操作加了几个核心的操作比如远程遥控和路径规划添加了双层的保护,设置里安全模式,即在此期间对服务器推送的重复登录操作后的自动退出登录做一个拦截 保证操作的安全性。
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:maibu_satabot_v2/core/di/injection.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/home/presentation/bloc/home_v2_bloc.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/home/presentation/bloc/home_v2_event.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/home/presentation/bloc/home_v2_state.dart';
|
||||
@@ -53,10 +54,23 @@ class _HomeV2PageState extends State<HomeV2Page> {
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
// 🔥 错误状态不再显示全屏错误页面,而是通过 listener 显示 SnackBar
|
||||
// 🔥 错误状态显示重试按钮
|
||||
if (state is HomeV2Error) {
|
||||
// 返回空容器保持页面
|
||||
return const SizedBox.shrink();
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.error_outline, size: 48, color: Colors.orange),
|
||||
const SizedBox(height: 12),
|
||||
Text(state.message, style: const TextStyle(fontSize: 14, color: Colors.grey)),
|
||||
const SizedBox(height: 16),
|
||||
ElevatedButton(
|
||||
onPressed: () => _bloc.add(const HomeV2LoadData()),
|
||||
child: const Text('重试'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (state is HomeV2Loaded) {
|
||||
@@ -92,7 +106,11 @@ class _HomeV2PageState extends State<HomeV2Page> {
|
||||
sl<SiteCubit>().state;
|
||||
return Text(
|
||||
siteState.selectedSite?.siteName ??
|
||||
'选择电站',
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate(
|
||||
'home_v2.select_site',
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
@@ -149,9 +167,11 @@ class _HomeV2PageState extends State<HomeV2Page> {
|
||||
color: Color(0xFF165DFF),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
const Text(
|
||||
'多云 28°C',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('home_v2.weather'),
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF4E5969),
|
||||
),
|
||||
@@ -180,10 +200,12 @@ class _HomeV2PageState extends State<HomeV2Page> {
|
||||
color: Color(0xFFF53F3F),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
const Expanded(
|
||||
Expanded(
|
||||
child: Text(
|
||||
'紧急告警',
|
||||
style: TextStyle(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('home_v2.emergency_alarm'),
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFFF53F3F),
|
||||
),
|
||||
@@ -229,7 +251,8 @@ class _HomeV2PageState extends State<HomeV2Page> {
|
||||
);
|
||||
}
|
||||
|
||||
return const SizedBox();
|
||||
// 🔥 Initial/Loading 状态显示加载指示器
|
||||
return const Center(child: CircularProgressIndicator(color: Color(0xFF165DFF)));
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -256,9 +279,13 @@ class _HomeV2PageState extends State<HomeV2Page> {
|
||||
final sites = currentState.sites;
|
||||
|
||||
if (sites.isEmpty) {
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(const SnackBar(content: Text('暂无可用电站')));
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
AppLocalizations.of(context).translate('home_v2.no_sites'),
|
||||
),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -282,9 +309,11 @@ class _HomeV2PageState extends State<HomeV2Page> {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Text(
|
||||
'选择电站',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).translate('home_v2.select_site'),
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
@@ -303,7 +332,11 @@ class _HomeV2PageState extends State<HomeV2Page> {
|
||||
title: Text(site.siteName),
|
||||
subtitle:
|
||||
site.siteCode != null && site.siteCode!.isNotEmpty
|
||||
? Text('编号: ${site.siteCode}')
|
||||
? Text(
|
||||
AppLocalizations.of(context)
|
||||
.translate('home_v2.site_code')
|
||||
.replaceAll('%s', site.siteCode!),
|
||||
)
|
||||
: null,
|
||||
trailing: isSelected
|
||||
? const Icon(
|
||||
@@ -347,11 +380,9 @@ class _HomeV2PageState extends State<HomeV2Page> {
|
||||
builder: (BuildContext context) {
|
||||
return MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider.value(value: context.read<DeviceStatusBloc>()),
|
||||
BlocProvider.value(
|
||||
value: context.read<DeviceStatusBloc>(),
|
||||
),
|
||||
BlocProvider.value(
|
||||
value: GetIt.I<RemoteControlCubit>(), // 🔥 注入 RemoteControlCubit
|
||||
value: GetIt.I<RemoteControlCubit>(), // 🔥 注入 RemoteControlCubit
|
||||
),
|
||||
],
|
||||
child: const DeviceStatusModal(),
|
||||
|
||||
Reference in New Issue
Block a user