From 97268c36dc0a71184dc50fce5554d10fe0c00ce0 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 20 Sep 2023 23:52:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A6=96=E9=A1=B5=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E9=80=BB=E8=BE=91=20issues=20#133?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/rcmd/controller.dart | 9 ++++++++- lib/pages/setting/extra_setting.dart | 6 ++++++ lib/utils/storage.dart | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/pages/rcmd/controller.dart b/lib/pages/rcmd/controller.dart index 1f21ab0d..f3acb67d 100644 --- a/lib/pages/rcmd/controller.dart +++ b/lib/pages/rcmd/controller.dart @@ -14,6 +14,7 @@ class RcmdController extends GetxController { Box recVideo = GStrorage.recVideo; Box setting = GStrorage.setting; RxInt crossAxisCount = 2.obs; + late bool enableSaveLastData; @override void onInit() { @@ -28,6 +29,8 @@ class RcmdController extends GetxController { } videoList.value = list; } + enableSaveLastData = + setting.get(SettingBoxKey.enableSaveLastData, defaultValue: false); } // 获取推荐 @@ -49,7 +52,11 @@ class RcmdController extends GetxController { videoList.value = res['data']; } } else if (type == 'onRefresh') { - videoList.value = res['data']; + if (enableSaveLastData) { + videoList.insertAll(0, res['data']); + } else { + videoList.value = res['data']; + } } else if (type == 'onLoad') { videoList.addAll(res['data']); } diff --git a/lib/pages/setting/extra_setting.dart b/lib/pages/setting/extra_setting.dart index f56029e6..4bbb841c 100644 --- a/lib/pages/setting/extra_setting.dart +++ b/lib/pages/setting/extra_setting.dart @@ -79,6 +79,12 @@ class _ExtraSettingState extends State { setKey: SettingBoxKey.enableWordRe, defaultVal: false, ), + const SetSwitchItem( + title: '首页推荐刷新', + subTitle: '下拉刷新时保留上次内容', + setKey: SettingBoxKey.enableSaveLastData, + defaultVal: false, + ), ListTile( dense: false, title: Text('评论展示', style: titleStyle), diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index 6ecd6083..fdf0fb0a 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -121,6 +121,7 @@ class SettingBoxKey { static const String enableWordRe = 'enableWordRe'; static const String enableSearchWord = 'enableSearchWord'; static const String enableRcmdDynamic = 'enableRcmdDynamic'; + static const String enableSaveLastData = 'enableSaveLastData'; /// 外观 static const String themeMode = 'themeMode';