mod: 首页网络异常请求重试
This commit is contained in:
@ -25,7 +25,6 @@ import 'package:pilipala/utils/recommend_filter.dart';
|
||||
import 'package:catcher_2/catcher_2.dart';
|
||||
import './services/loggeer.dart';
|
||||
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
MediaKit.ensureInitialized();
|
||||
@ -55,14 +54,13 @@ void main() async {
|
||||
[FileHandler(await getLogsPath())],
|
||||
);
|
||||
|
||||
Catcher2(
|
||||
debugConfig: debugConfig,
|
||||
releaseConfig: releaseConfig,
|
||||
runAppFunction: () {
|
||||
runApp(const MyApp());
|
||||
},
|
||||
);
|
||||
|
||||
// Catcher2(
|
||||
// debugConfig: debugConfig,
|
||||
// releaseConfig: releaseConfig,
|
||||
// runAppFunction: () {
|
||||
runApp(const MyApp());
|
||||
// },
|
||||
// );
|
||||
|
||||
// 小白条、导航栏沉浸
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||
|
@ -9,7 +9,6 @@ import 'package:pilipala/common/constants.dart';
|
||||
import 'package:pilipala/common/widgets/http_error.dart';
|
||||
import 'package:pilipala/pages/home/index.dart';
|
||||
import 'package:pilipala/pages/main/index.dart';
|
||||
import 'package:pilipala/pages/rcmd/view.dart';
|
||||
|
||||
import 'controller.dart';
|
||||
import 'widgets/bangumu_card_v.dart';
|
||||
@ -199,7 +198,10 @@ class _BangumiPageState extends State<BangumiPage>
|
||||
} else {
|
||||
return HttpError(
|
||||
errMsg: data['msg'],
|
||||
fn: () => {},
|
||||
fn: () {
|
||||
_futureBuilderFuture =
|
||||
_bangumidController.queryBangumiListFeed();
|
||||
},
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@ -208,7 +210,6 @@ class _BangumiPageState extends State<BangumiPage>
|
||||
},
|
||||
),
|
||||
),
|
||||
const LoadingMore()
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@ -89,8 +89,7 @@ class _HotPageState extends State<HotPage> with AutomaticKeepAliveClientMixin {
|
||||
if (data['status']) {
|
||||
return Obx(
|
||||
() => SliverList(
|
||||
delegate:
|
||||
SliverChildBuilderDelegate((context, index) {
|
||||
delegate: SliverChildBuilderDelegate((context, index) {
|
||||
return VideoCardH(
|
||||
videoItem: _hotController.videoList[index],
|
||||
showPubdate: true,
|
||||
@ -110,7 +109,12 @@ class _HotPageState extends State<HotPage> with AutomaticKeepAliveClientMixin {
|
||||
} else {
|
||||
return HttpError(
|
||||
errMsg: data['msg'],
|
||||
fn: () => setState(() {}),
|
||||
fn: () {
|
||||
setState(() {
|
||||
_futureBuilderFuture =
|
||||
_hotController.queryHotFeed('init');
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
} else {
|
||||
|
@ -10,8 +10,7 @@ class LiveController extends GetxController {
|
||||
int count = 12;
|
||||
int _currentPage = 1;
|
||||
RxInt crossAxisCount = 2.obs;
|
||||
RxList<LiveItemModel> liveList = [LiveItemModel()].obs;
|
||||
bool isLoadingMore = false;
|
||||
RxList<LiveItemModel> liveList = <LiveItemModel>[].obs;
|
||||
bool flag = false;
|
||||
OverlayEntry? popupDialog;
|
||||
Box setting = GStrorage.setting;
|
||||
@ -39,7 +38,6 @@ class LiveController extends GetxController {
|
||||
}
|
||||
_currentPage += 1;
|
||||
}
|
||||
isLoadingMore = false;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,6 @@ import 'package:pilipala/common/widgets/http_error.dart';
|
||||
import 'package:pilipala/common/widgets/overlay_pop.dart';
|
||||
import 'package:pilipala/pages/home/index.dart';
|
||||
import 'package:pilipala/pages/main/index.dart';
|
||||
import 'package:pilipala/pages/rcmd/index.dart';
|
||||
|
||||
import 'controller.dart';
|
||||
import 'widgets/live_item.dart';
|
||||
@ -45,8 +44,8 @@ class _LivePageState extends State<LivePage>
|
||||
() {
|
||||
if (scrollController.position.pixels >=
|
||||
scrollController.position.maxScrollExtent - 200) {
|
||||
EasyThrottle.throttle('liveList', const Duration(seconds: 1), () {
|
||||
_liveController.isLoadingMore = true;
|
||||
EasyThrottle.throttle('liveList', const Duration(milliseconds: 200),
|
||||
() {
|
||||
_liveController.onLoad();
|
||||
});
|
||||
}
|
||||
@ -108,24 +107,20 @@ class _LivePageState extends State<LivePage>
|
||||
} else {
|
||||
return HttpError(
|
||||
errMsg: data['msg'],
|
||||
fn: () => {},
|
||||
fn: () {
|
||||
setState(() {
|
||||
_futureBuilderFuture =
|
||||
_liveController.queryLiveList('init');
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// 缓存数据
|
||||
if (_liveController.liveList.length > 1) {
|
||||
return contentGrid(
|
||||
_liveController, _liveController.liveList);
|
||||
}
|
||||
// 骨架屏
|
||||
else {
|
||||
return contentGrid(_liveController, []);
|
||||
}
|
||||
return contentGrid(_liveController, []);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
LoadingMore(ctr: _liveController)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -44,7 +44,7 @@ class _RcmdPageState extends State<RcmdPage>
|
||||
if (scrollController.position.pixels >=
|
||||
scrollController.position.maxScrollExtent - 200) {
|
||||
EasyThrottle.throttle(
|
||||
'my-throttler', const Duration(milliseconds: 500), () {
|
||||
'my-throttler', const Duration(milliseconds: 200), () {
|
||||
_rcmdController.isLoadingMore = true;
|
||||
_rcmdController.onLoad();
|
||||
});
|
||||
@ -113,6 +113,7 @@ class _RcmdPageState extends State<RcmdPage>
|
||||
errMsg: data['msg'],
|
||||
fn: () {
|
||||
setState(() {
|
||||
_rcmdController.isLoadingMore = true;
|
||||
_futureBuilderFuture =
|
||||
_rcmdController.queryRcmdFeed('init');
|
||||
});
|
||||
@ -125,7 +126,6 @@ class _RcmdPageState extends State<RcmdPage>
|
||||
},
|
||||
),
|
||||
),
|
||||
LoadingMore(ctr: _rcmdController),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -188,33 +188,3 @@ class _RcmdPageState extends State<RcmdPage>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class LoadingMore extends StatelessWidget {
|
||||
final dynamic ctr;
|
||||
const LoadingMore({super.key, this.ctr});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SliverToBoxAdapter(
|
||||
child: Container(
|
||||
height: MediaQuery.of(context).padding.bottom + 80,
|
||||
padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
if (ctr != null) {
|
||||
ctr!.isLoadingMore = true;
|
||||
ctr!.onLoad();
|
||||
}
|
||||
},
|
||||
child: Center(
|
||||
child: Text(
|
||||
'点击加载更多 👇',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline, fontSize: 13),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user