Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
laki_icu_app
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张宏
laki_icu_app
Commits
e5f6d0a9
Commit
e5f6d0a9
authored
Jun 23, 2026
by
akari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复SN读取跟写入
parent
e5d7ce05
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
90 additions
and
78 deletions
+90
-78
user_model.dart
lib/models/bo/user_model.dart
+1
-1
event_bus.dart
lib/utils/event_bus.dart
+3
-0
storage_service.dart
lib/utils/storage/storage_service.dart
+13
-12
default_view.dart
lib/views/layout/default_view.dart
+12
-4
monitoring_top_status_bar.dart
lib/views/layout/widgets/monitoring_top_status_bar.dart
+25
-31
monitoring_index_cubit.dart
lib/views/monitoring/index/cubit/monitoring_index_cubit.dart
+8
-11
monitoring_index_view.dart
lib/views/monitoring/index/monitoring_index_view.dart
+15
-6
bluetooth_bind_dialog.dart
...views/monitoring/index/widgets/bluetooth_bind_dialog.dart
+13
-13
No files found.
lib/models/bo/user_model.dart
View file @
e5f6d0a9
...
...
@@ -12,7 +12,7 @@ class UserModel extends Equatable {
final
String
?
hospitalName
;
// ignore: non_constant_identifier_names
static
String
?
MAC
;
static
String
?
SN
;
const
UserModel
({
required
this
.
id
,
...
...
lib/utils/event_bus.dart
View file @
e5f6d0a9
...
...
@@ -24,3 +24,6 @@ class TokenExpiredEvent {}
// 退出登录事件
class
LogoutEvent
{}
// 打开蓝牙扫描/绑定页面事件
class
OpenBluetoothScanEvent
{}
lib/utils/storage/storage_service.dart
View file @
e5f6d0a9
...
...
@@ -9,7 +9,7 @@ class StorageService {
static
const
String
_keyRememberSmsCode
=
'remember_sms_code'
;
static
const
String
_keyRememberEnabled
=
'remember_enabled'
;
static
const
String
_keyUserInfo
=
'user_info'
;
static
const
String
_keyUser
Mac
=
'user_mac
'
;
static
const
String
_keyUser
Sn
=
'user_sn
'
;
static
const
String
_keyClientId
=
'client_id'
;
static
const
String
_keyBoundBluetoothDeviceId
=
'bound_bluetooth_device_id'
;
static
const
String
_keyBoundBluetoothDeviceName
=
...
...
@@ -76,11 +76,12 @@ class StorageService {
final
jsonStr
=
'
${userInfo.id}
|
${userInfo.nickname ?? ''}
|
${userInfo.phone ?? ''}
|
${userInfo.avatar ?? ''}
|
${userInfo.type ?? ''}
|
${userInfo.canControlDevice ?? ''}
|
${userInfo.canViewOperation ?? ''}
|
${userInfo.hospitalId ?? ''}
|
${userInfo.hospitalName ?? ''}
'
;
await
_storage
.
write
(
key:
_keyUserInfo
,
value:
jsonStr
);
await
getUserSn
();
}
Future
<
UserModel
?>
getUserInfo
()
async
{
final
value
=
await
_storage
.
read
(
key:
_keyUserInfo
);
UserModel
.
MAC
=
await
getUserMac
();
UserModel
.
SN
=
await
getUserSn
();
if
(
value
==
null
||
value
.
isEmpty
)
return
null
;
final
parts
=
value
.
split
(
'|'
);
if
(
parts
.
length
<
9
)
return
null
;
...
...
@@ -101,20 +102,20 @@ class StorageService {
await
_storage
.
delete
(
key:
_keyUserInfo
);
}
Future
<
void
>
saveUser
Mac
(
String
mac
)
async
{
UserModel
.
MAC
=
mac
;
await
_storage
.
write
(
key:
_keyUser
Mac
,
value:
mac
);
Future
<
void
>
saveUser
Sn
(
String
sn
)
async
{
UserModel
.
SN
=
sn
;
await
_storage
.
write
(
key:
_keyUser
Sn
,
value:
sn
);
}
Future
<
String
?>
getUser
Mac
()
async
{
final
mac
=
await
_storage
.
read
(
key:
_keyUserMac
);
UserModel
.
MAC
=
mac
;
return
mac
;
Future
<
String
?>
getUser
Sn
()
async
{
final
sn
=
await
_storage
.
read
(
key:
_keyUserSn
);
UserModel
.
SN
=
sn
;
return
sn
;
}
Future
<
void
>
deleteUser
Mac
()
async
{
UserModel
.
MAC
=
null
;
await
_storage
.
delete
(
key:
_keyUser
Mac
);
Future
<
void
>
deleteUser
Sn
()
async
{
UserModel
.
SN
=
null
;
await
_storage
.
delete
(
key:
_keyUser
Sn
);
}
// ==================== ClientId 相关 ====================
...
...
lib/views/layout/default_view.dart
View file @
e5f6d0a9
...
...
@@ -4,6 +4,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import
'package:flutter_screenutil/flutter_screenutil.dart'
;
import
'../../routes/app_router.gr.dart'
;
import
'../../utils/event_bus.dart'
;
import
'cubit/default_layout_cubit.dart'
;
import
'cubit/default_layout_state.dart'
;
import
'widgets/monitoring_bottom_menu.dart'
;
...
...
@@ -78,9 +79,7 @@ class _DefaultLayoutContent extends StatelessWidget {
return
PreferredSize
(
preferredSize:
Size
.
fromHeight
(
104
.
h
),
child:
Container
(
decoration:
const
BoxDecoration
(
// border: BoxBorder.all(width: 1.w,color: Colors.red)
),
decoration:
const
BoxDecoration
(),
child:
Stack
(
children:
[
Positioned
(
...
...
@@ -92,7 +91,7 @@ class _DefaultLayoutContent extends StatelessWidget {
height:
162
.
h
,
),
),
Container
(
SizedBox
(
height:
104
.
h
,
child:
const
MonitoringTopStatusBar
(),
),
...
...
@@ -107,6 +106,15 @@ class _DefaultLayoutContent extends StatelessWidget {
menuItems:
state
.
menuItems
,
selectedMenuId:
selectedMenuId
,
onMenuItemTap:
(
menuId
)
{
if
(
menuId
==
'tsaas'
)
{
if
(
tabsRouter
.
activeIndex
!=
0
)
{
tabsRouter
.
setActiveIndex
(
0
);
}
WidgetsBinding
.
instance
.
addPostFrameCallback
((
_
)
{
eventBus
.
emit
(
OpenBluetoothScanEvent
());
});
return
;
}
final
index
=
indexFromMenuId
(
menuId
);
tabsRouter
.
setActiveIndex
(
index
);
},
...
...
lib/views/layout/widgets/monitoring_top_status_bar.dart
View file @
e5f6d0a9
...
...
@@ -13,40 +13,34 @@ class MonitoringTopStatusBar extends StatelessWidget {
fit:
BoxFit
.
fill
,
),
),
padding:
EdgeInsets
.
only
(
left:
32
.
w
,
bottom:
22
.
h
),
padding:
EdgeInsets
.
only
(
left:
32
.
w
,
bottom:
22
.
h
),
child:
Row
(
children:
[
// SizedBox(width: 18.w),
Text
(
'总运行时长:9999h'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
25
.
sp
,
),
),
SizedBox
(
width:
32
.
w
),
Text
(
'环境温度:30.68'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
25
.
sp
,
),
),
SizedBox
(
width:
32
.
w
),
Text
(
'总制氧时长:500h'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
25
.
sp
,
),
),
// const Spacer(),
children:
[
Text
(
'总运行时长:9999h'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
25
.
sp
,
),
),
SizedBox
(
width:
32
.
w
),
Text
(
'环境温度:30.68'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
25
.
sp
,
),
),
SizedBox
(
width:
32
.
w
),
Text
(
'总制氧时长:500h'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
25
.
sp
,
),
),
],
),
);
}
}
lib/views/monitoring/index/cubit/monitoring_index_cubit.dart
View file @
e5f6d0a9
...
...
@@ -83,11 +83,16 @@ class MonitoringIndexCubit extends Cubit<MonitoringIndexState> {
emit
(
state
.
copyWith
(
bluetoothMessage:
message
));
});
_bluetoothDataSub
=
_bluetoothManager
.
dataStream
.
listen
((
packet
)
{
_bluetoothDataSub
=
_bluetoothManager
.
dataStream
.
listen
((
packet
)
async
{
if
(
isClosed
)
return
;
try
{
final
reports
=
_mcuReportDecoder
.
addBytes
(
packet
.
bytes
);
final
latestReport
=
reports
.
isEmpty
?
null
:
reports
.
last
;
final
latestSn
=
latestReport
?.
sn
.
trim
();
if
(
latestSn
!=
null
&&
latestSn
.
isNotEmpty
)
{
await
_storageService
.
saveUserSn
(
latestSn
);
if
(
isClosed
)
return
;
}
emit
(
state
.
copyWith
(
latestBluetoothRawHex:
packet
.
rawHex
,
latestMcuReport:
latestReport
,
...
...
@@ -108,14 +113,7 @@ class MonitoringIndexCubit extends Cubit<MonitoringIndexState> {
final
boundDevice
=
await
_storageService
.
getBoundBluetoothDevice
();
if
(
isClosed
)
return
;
final
deviceId
=
boundDevice
[
'deviceId'
];
if
(
deviceId
!=
null
&&
deviceId
.
isNotEmpty
)
{
final
userMac
=
await
_storageService
.
getUserMac
();
if
(
userMac
==
null
||
userMac
.
isEmpty
)
{
await
_storageService
.
saveUserMac
(
deviceId
);
}
}
else
{
await
_storageService
.
getUserMac
();
}
await
_storageService
.
getUserSn
();
if
(
isClosed
)
return
;
emit
(
state
.
copyWith
(
boundBluetoothDeviceId:
...
...
@@ -312,7 +310,6 @@ class MonitoringIndexCubit extends Cubit<MonitoringIndexState> {
deviceId:
device
.
remoteId
,
deviceName:
device
.
name
,
);
await
_storageService
.
saveUserMac
(
device
.
remoteId
);
if
(
isClosed
)
return
;
emit
(
state
.
copyWith
(
isBluetoothBinding:
false
,
...
...
@@ -334,7 +331,7 @@ class MonitoringIndexCubit extends Cubit<MonitoringIndexState> {
Future
<
void
>
unbindBluetoothDevice
()
async
{
await
_bluetoothManager
.
disconnect
();
await
_storageService
.
deleteBoundBluetoothDevice
();
await
_storageService
.
deleteUser
Mac
();
await
_storageService
.
deleteUser
Sn
();
_mcuReportDecoder
.
clear
();
if
(
isClosed
)
return
;
emit
(
state
.
copyWith
(
...
...
lib/views/monitoring/index/monitoring_index_view.dart
View file @
e5f6d0a9
import
'dart:async'
;
import
'package:auto_route/auto_route.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
import
'package:flutter_screenutil/flutter_screenutil.dart'
;
import
'package:laki_icu_app/enums/video_stream_mode_enum.dart'
;
import
'package:laki_icu_app/models/bo/monitoring_bo.dart'
;
import
'package:laki_icu_app/utils/event_bus.dart'
;
import
'cubit/monitoring_index_cubit.dart'
;
import
'cubit/monitoring_index_state.dart'
;
...
...
@@ -35,11 +38,22 @@ class MonitoringIndexContent extends StatefulWidget {
class
_MonitoringIndexContentState
extends
State
<
MonitoringIndexContent
>
{
late
final
MonitoringIndexCubit
_monitoringIndexCubit
;
StreamSubscription
<
OpenBluetoothScanEvent
>?
_bluetoothScanEventSub
;
@override
void
initState
()
{
super
.
initState
();
_monitoringIndexCubit
=
context
.
read
<
MonitoringIndexCubit
>();
_bluetoothScanEventSub
=
eventBus
.
on
<
OpenBluetoothScanEvent
>().
listen
((
_
)
{
if
(!
mounted
)
return
;
_showBluetoothDialog
();
});
}
@override
void
dispose
()
{
_bluetoothScanEventSub
?.
cancel
();
super
.
dispose
();
}
@override
...
...
@@ -136,12 +150,7 @@ class _MonitoringIndexContentState extends State<MonitoringIndexContent> {
for
(
int
i
=
0
;
i
<
displayMetrics
.
length
;
i
++)
{
children
.
add
(
Expanded
(
child:
Container
(
decoration:
BoxDecoration
(
// border: BoxBorder.all(width: 1.w, color: Colors.red),
),
child:
MonitoringMetricCard
(
metric:
displayMetrics
[
i
]),
),
child:
MonitoringMetricCard
(
metric:
displayMetrics
[
i
]),
),
);
if
(
i
<
displayMetrics
.
length
-
1
)
{
...
...
lib/views/monitoring/index/widgets/bluetooth_bind_dialog.dart
View file @
e5f6d0a9
...
...
@@ -75,7 +75,7 @@ class _BluetoothBindDialogState extends State<BluetoothBindDialog> {
'设备连接'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
4
2
.
sp
,
fontSize:
4
9
.
sp
,
fontWeight:
FontWeight
.
w400
,
),
),
...
...
@@ -84,7 +84,7 @@ class _BluetoothBindDialogState extends State<BluetoothBindDialog> {
'搜索蓝牙设备完成配对连接'
,
style:
TextStyle
(
color:
Colors
.
white
.
withValues
(
alpha:
0.84
),
fontSize:
2
2
.
sp
,
fontSize:
2
9
.
sp
,
),
),
],
...
...
@@ -147,7 +147,7 @@ class _BluetoothBindDialogState extends State<BluetoothBindDialog> {
message
,
style:
TextStyle
(
color:
Colors
.
white
.
withValues
(
alpha:
0.88
),
fontSize:
2
1
.
sp
,
fontSize:
2
8
.
sp
,
fontWeight:
FontWeight
.
w400
,
),
maxLines:
1
,
...
...
@@ -174,7 +174,7 @@ class _BluetoothBindDialogState extends State<BluetoothBindDialog> {
style:
TextButton
.
styleFrom
(
foregroundColor:
Colors
.
white
,
disabledForegroundColor:
Colors
.
white70
,
textStyle:
TextStyle
(
fontSize:
17
.
sp
),
textStyle:
TextStyle
(
fontSize:
24
.
sp
),
),
),
],
...
...
@@ -188,7 +188,7 @@ class _BluetoothBindDialogState extends State<BluetoothBindDialog> {
state
.
isBluetoothScanning
?
'正在扫描附近设备...'
:
'暂无设备'
,
style:
TextStyle
(
color:
Colors
.
white
.
withValues
(
alpha:
0.76
),
fontSize:
24
.
sp
,
fontSize:
31
.
sp
,
),
),
);
...
...
@@ -290,7 +290,7 @@ class _BluetoothBindDialogState extends State<BluetoothBindDialog> {
color:
rawHex
!=
null
&&
rawHex
.
isNotEmpty
?
const
Color
(
0xFF00F6FF
)
:
Colors
.
white
.
withValues
(
alpha:
0.66
),
fontSize:
15
.
sp
,
fontSize:
22
.
sp
,
),
maxLines:
2
,
overflow:
TextOverflow
.
ellipsis
,
...
...
@@ -323,7 +323,7 @@ class _BluetoothReportSummary extends StatelessWidget {
report
.
sn
.
isEmpty
?
'SN --'
:
'SN
${report.sn}
'
,
style:
TextStyle
(
color:
const
Color
(
0xFF00F6FF
),
fontSize:
15
.
sp
,
fontSize:
22
.
sp
,
fontWeight:
FontWeight
.
w600
,
),
maxLines:
1
,
...
...
@@ -380,14 +380,14 @@ class _BluetoothReportMetric extends StatelessWidget {
text:
'
$label
'
,
style:
TextStyle
(
color:
Colors
.
white
.
withValues
(
alpha:
0.58
),
fontSize:
13
.
sp
,
fontSize:
20
.
sp
,
),
),
TextSpan
(
text:
value
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
16
.
sp
,
fontSize:
23
.
sp
,
fontWeight:
FontWeight
.
w600
,
),
),
...
...
@@ -395,7 +395,7 @@ class _BluetoothReportMetric extends StatelessWidget {
text:
unit
,
style:
TextStyle
(
color:
Colors
.
white
.
withValues
(
alpha:
0.72
),
fontSize:
1
2
.
sp
,
fontSize:
1
9
.
sp
,
),
),
],
...
...
@@ -446,7 +446,7 @@ class _BluetoothDeviceRow extends StatelessWidget {
device
.
name
,
style:
TextStyle
(
color:
textColor
,
fontSize:
26
.
sp
,
fontSize:
33
.
sp
,
fontWeight:
isBound
?
FontWeight
.
w600
:
FontWeight
.
w400
,
),
maxLines:
1
,
...
...
@@ -457,7 +457,7 @@ class _BluetoothDeviceRow extends StatelessWidget {
'
${device.remoteId}
RSSI
${device.rssi}
'
,
style:
TextStyle
(
color:
Colors
.
white
.
withValues
(
alpha:
0.42
),
fontSize:
13
.
sp
,
fontSize:
20
.
sp
,
),
maxLines:
1
,
overflow:
TextOverflow
.
ellipsis
,
...
...
@@ -473,7 +473,7 @@ class _BluetoothDeviceRow extends StatelessWidget {
textAlign:
TextAlign
.
left
,
style:
TextStyle
(
color:
textColor
,
fontSize:
25
.
sp
,
fontSize:
32
.
sp
,
fontWeight:
isBound
?
FontWeight
.
w600
:
FontWeight
.
w400
,
),
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment