feat: 首页刷新逻辑 issues #133

This commit is contained in:
guozhigq
2023-09-20 23:52:04 +08:00
parent d1272efad4
commit 97268c36dc
3 changed files with 15 additions and 1 deletions

View File

@ -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']);
}

View File

@ -79,6 +79,12 @@ class _ExtraSettingState extends State<ExtraSetting> {
setKey: SettingBoxKey.enableWordRe,
defaultVal: false,
),
const SetSwitchItem(
title: '首页推荐刷新',
subTitle: '下拉刷新时保留上次内容',
setKey: SettingBoxKey.enableSaveLastData,
defaultVal: false,
),
ListTile(
dense: false,
title: Text('评论展示', style: titleStyle),

View File

@ -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';