修改首页数据持久化问题

This commit is contained in:
魏少阳 2024-04-17 15:35:06 +08:00
parent 6a9830378d
commit 8d27d592b7
2 changed files with 20 additions and 9 deletions

View File

@ -24,17 +24,18 @@ class LockMainLogic extends BaseGetXController {
loadMainDataLogic(entity.data!); loadMainDataLogic(entity.data!);
Storage.saveMainListData(entity.data!); Storage.saveMainListData(entity.data!);
// return entity.data!; // return entity.data!;
} else {
Get.log("首页锁列表请求失败");
// showToast("数据请求失败");
// state.dataLength.value = 0;
LockListInfoGroupEntity? lockListInfoGroupEntity = await Storage.getLockMainListData();
loadMainDataLogic(lockListInfoGroupEntity!);
} }
// else {
// Get.log("首页锁列表请求失败");
// // showToast("数据请求失败");
// // state.dataLength.value = 0;
// LockListInfoGroupEntity? lockListInfoGroupEntity = await Storage.getLockMainListData();
// loadMainDataLogic(lockListInfoGroupEntity!);
// }
return entity; return entity;
} }
loadMainDataLogic(LockListInfoGroupEntity entity){ Future<void> loadMainDataLogic(LockListInfoGroupEntity entity){
if (entity.groupList!.isEmpty) { if (entity.groupList!.isEmpty) {
state.dataLength.value = 0; state.dataLength.value = 0;
} else if (entity.groupList!.length == 1) { } else if (entity.groupList!.length == 1) {
@ -48,6 +49,7 @@ class LockMainLogic extends BaseGetXController {
state.dataLength.value = 2; state.dataLength.value = 2;
} }
state.lockListInfoGroupEntity.value = entity; state.lockListInfoGroupEntity.value = entity;
return Future.value();
} }
/// ///
@ -106,9 +108,9 @@ class LockMainLogic extends BaseGetXController {
// getLockInfo(); // getLockInfo();
// //
connectListener(); // connectListener();
// //
getConnectType(); // getConnectType();
} }
@override @override

View File

@ -36,6 +36,15 @@ class _StarLockMainPageState extends State<StarLockMainPage> with BaseWidget {
final state = Get.find<LockMainLogic>().state; final state = Get.find<LockMainLogic>().state;
Future<void> getHttpData() async { Future<void> getHttpData() async {
LockListInfoGroupEntity? lockListInfoGroupEntity = await Storage.getLockMainListData();
Get.log("lockListInfoGroupEntity:${lockListInfoGroupEntity!.groupList!.length}");
if (lockListInfoGroupEntity != null) {
logic.loadMainDataLogic(lockListInfoGroupEntity).then((value) {
if (mounted) {
setState(() {});
}
});
}
logic.getStarLockInfo().then((LockListInfoEntity value) { logic.getStarLockInfo().then((LockListInfoEntity value) {
if (mounted) { if (mounted) {
setState(() {}); setState(() {});