fix: 热门页刷新逻辑错误

This commit is contained in:
orz12
2024-03-06 15:59:18 +08:00
parent c9acd4109f
commit d3cd645d9e

View File

@@ -14,6 +14,9 @@ class HotController extends GetxController {
// 获取推荐 // 获取推荐
Future queryHotFeed(type) async { Future queryHotFeed(type) async {
if (type != 'onLoad') {
_currentPage = 1;
}
var res = await VideoHttp.hotVideoList( var res = await VideoHttp.hotVideoList(
pn: _currentPage, pn: _currentPage,
ps: _count, ps: _count,
@@ -22,7 +25,8 @@ class HotController extends GetxController {
if (type == 'init') { if (type == 'init') {
videoList.value = res['data']; videoList.value = res['data'];
} else if (type == 'onRefresh') { } else if (type == 'onRefresh') {
videoList.insertAll(0, res['data']); // videoList.insertAll(0, res['data']);
videoList.value = res['data'];
} else if (type == 'onLoad') { } else if (type == 'onLoad') {
videoList.addAll(res['data']); videoList.addAll(res['data']);
} }
@@ -34,15 +38,15 @@ class HotController extends GetxController {
// 下拉刷新 // 下拉刷新
Future onRefresh() async { Future onRefresh() async {
queryHotFeed('onRefresh'); await queryHotFeed('onRefresh');
} }
// 上拉加载 // 上拉加载
Future onLoad() async { Future onLoad() async {
queryHotFeed('onLoad'); await queryHotFeed('onLoad');
} }
// 返回顶部并刷新 // 返回顶部
void animateToTop() async { void animateToTop() async {
if (scrollController.offset >= if (scrollController.offset >=
MediaQuery.of(Get.context!).size.height * 5) { MediaQuery.of(Get.context!).size.height * 5) {