feat: 蓝牙血压计BLE数据同步 + 设备管理页重构 + 健康记录滑动删除 + 医生端合并设计文档
- BLE: 修复Omron设备Indication模式连接(先订阅后配CCCD + forceIndications) + 直连重连
- BLE: 设备断连实时检测(connectionState流→Provider→UI)
- 修复: 血压数据上报后端枚举不匹配(Device→DeviceSync)导致500
- 新增: DELETE /api/health-records/{id} 后端接口
- 设备管理页: 白色主题重设计 + 直连重连 + 实时状态 + Toast通知
- 设备扫描页: 白色主题 + 扫描动画居中 + 已连接等待页面
- 健康记录: 左滑删除(Dismissible) + 同时清理_allRecords和_filtered
- 导航: 修复自定义路由栈下Navigator.pop黑屏bug
- 文档: 医生端合并App完整设计文档(已确认版)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'auth_provider.dart';
|
||||
import 'data_providers.dart';
|
||||
@@ -45,12 +46,27 @@ class DeviceBindState {
|
||||
}
|
||||
|
||||
class DeviceBindNotifier extends Notifier<DeviceBindState> {
|
||||
StreamSubscription? _connSub;
|
||||
|
||||
@override
|
||||
DeviceBindState build() {
|
||||
_loadBinding();
|
||||
_listenConnection();
|
||||
return const DeviceBindState();
|
||||
}
|
||||
|
||||
void _listenConnection() {
|
||||
_connSub?.cancel();
|
||||
_connSub = ref.read(omronBleServiceProvider).connectionState.listen((connected) {
|
||||
if (state.isConnected != connected) {
|
||||
state = state.copyWith(isConnected: connected);
|
||||
}
|
||||
if (!connected && state.isBound) {
|
||||
// 设备断开,但保持绑定信息(下次可以重连)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _loadBinding() async {
|
||||
final db = ref.read(localDbProvider);
|
||||
final mac = await db.read('bp_device_mac');
|
||||
|
||||
Reference in New Issue
Block a user