更新首页睡眠报告定时刷新
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:EasyDartModule/EasyDartModule.dart';
|
import 'package:EasyDartModule/EasyDartModule.dart';
|
||||||
@@ -48,6 +49,24 @@ class BodyDeviceController extends GetControllerEx<BodyDeviceModel> {
|
|||||||
|
|
||||||
String wifiMac = "";
|
String wifiMac = "";
|
||||||
|
|
||||||
|
Timer? _sleepReportTimer; // 定时器
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onInit() {
|
||||||
|
super.onInit();
|
||||||
|
// 启动定时器,每10分钟请求一次
|
||||||
|
_sleepReportTimer = Timer.periodic(const Duration(minutes: 10), (timer) {
|
||||||
|
getSleepReport();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onClose() {
|
||||||
|
// 页面销毁时取消定时器
|
||||||
|
_sleepReportTimer?.cancel();
|
||||||
|
super.onClose();
|
||||||
|
}
|
||||||
|
|
||||||
Future<ApiResponse> getDeviceNum() async {
|
Future<ApiResponse> getDeviceNum() async {
|
||||||
try {
|
try {
|
||||||
ApiResponse apiResponse = ApiResponse(code: -1, msg: "设备.设备列表请求失败".tr);
|
ApiResponse apiResponse = ApiResponse(code: -1, msg: "设备.设备列表请求失败".tr);
|
||||||
@@ -199,6 +218,7 @@ class BodyDeviceController extends GetControllerEx<BodyDeviceModel> {
|
|||||||
|
|
||||||
Future<ApiResponse> getSleepReport() async {
|
Future<ApiResponse> getSleepReport() async {
|
||||||
try {
|
try {
|
||||||
|
ef.log("刷新睡眠报告");
|
||||||
sleepReportData.value = {};
|
sleepReportData.value = {};
|
||||||
ApiResponse<Map<String, List<dynamic>>> apiResponse = ApiResponse(
|
ApiResponse<Map<String, List<dynamic>>> apiResponse = ApiResponse(
|
||||||
code: -1,
|
code: -1,
|
||||||
|
|||||||
@@ -383,7 +383,6 @@ class _HomePageState extends State<HomePage> {
|
|||||||
.currentColor.sc4,
|
.currentColor.sc4,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
].divide(SizedBox(
|
].divide(SizedBox(
|
||||||
width: 20.rpx,
|
width: 20.rpx,
|
||||||
)),
|
)),
|
||||||
|
|||||||
Reference in New Issue
Block a user