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 'package:catcher_2/catcher_2.dart';
|
||||||
import './services/loggeer.dart';
|
import './services/loggeer.dart';
|
||||||
|
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
MediaKit.ensureInitialized();
|
MediaKit.ensureInitialized();
|
||||||
@ -55,14 +54,13 @@ void main() async {
|
|||||||
[FileHandler(await getLogsPath())],
|
[FileHandler(await getLogsPath())],
|
||||||
);
|
);
|
||||||
|
|
||||||
Catcher2(
|
// Catcher2(
|
||||||
debugConfig: debugConfig,
|
// debugConfig: debugConfig,
|
||||||
releaseConfig: releaseConfig,
|
// releaseConfig: releaseConfig,
|
||||||
runAppFunction: () {
|
// runAppFunction: () {
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
},
|
// },
|
||||||
);
|
// );
|
||||||
|
|
||||||
|
|
||||||
// 小白条、导航栏沉浸
|
// 小白条、导航栏沉浸
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
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/common/widgets/http_error.dart';
|
||||||
import 'package:pilipala/pages/home/index.dart';
|
import 'package:pilipala/pages/home/index.dart';
|
||||||
import 'package:pilipala/pages/main/index.dart';
|
import 'package:pilipala/pages/main/index.dart';
|
||||||
import 'package:pilipala/pages/rcmd/view.dart';
|
|
||||||
|
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
import 'widgets/bangumu_card_v.dart';
|
import 'widgets/bangumu_card_v.dart';
|
||||||
@ -199,7 +198,10 @@ class _BangumiPageState extends State<BangumiPage>
|
|||||||
} else {
|
} else {
|
||||||
return HttpError(
|
return HttpError(
|
||||||
errMsg: data['msg'],
|
errMsg: data['msg'],
|
||||||
fn: () => {},
|
fn: () {
|
||||||
|
_futureBuilderFuture =
|
||||||
|
_bangumidController.queryBangumiListFeed();
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} 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']) {
|
if (data['status']) {
|
||||||
return Obx(
|
return Obx(
|
||||||
() => SliverList(
|
() => SliverList(
|
||||||
delegate:
|
delegate: SliverChildBuilderDelegate((context, index) {
|
||||||
SliverChildBuilderDelegate((context, index) {
|
|
||||||
return VideoCardH(
|
return VideoCardH(
|
||||||
videoItem: _hotController.videoList[index],
|
videoItem: _hotController.videoList[index],
|
||||||
showPubdate: true,
|
showPubdate: true,
|
||||||
@ -110,7 +109,12 @@ class _HotPageState extends State<HotPage> with AutomaticKeepAliveClientMixin {
|
|||||||
} else {
|
} else {
|
||||||
return HttpError(
|
return HttpError(
|
||||||
errMsg: data['msg'],
|
errMsg: data['msg'],
|
||||||
fn: () => setState(() {}),
|
fn: () {
|
||||||
|
setState(() {
|
||||||
|
_futureBuilderFuture =
|
||||||
|
_hotController.queryHotFeed('init');
|
||||||
|
});
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -10,8 +10,7 @@ class LiveController extends GetxController {
|
|||||||
int count = 12;
|
int count = 12;
|
||||||
int _currentPage = 1;
|
int _currentPage = 1;
|
||||||
RxInt crossAxisCount = 2.obs;
|
RxInt crossAxisCount = 2.obs;
|
||||||
RxList<LiveItemModel> liveList = [LiveItemModel()].obs;
|
RxList<LiveItemModel> liveList = <LiveItemModel>[].obs;
|
||||||
bool isLoadingMore = false;
|
|
||||||
bool flag = false;
|
bool flag = false;
|
||||||
OverlayEntry? popupDialog;
|
OverlayEntry? popupDialog;
|
||||||
Box setting = GStrorage.setting;
|
Box setting = GStrorage.setting;
|
||||||
@ -39,7 +38,6 @@ class LiveController extends GetxController {
|
|||||||
}
|
}
|
||||||
_currentPage += 1;
|
_currentPage += 1;
|
||||||
}
|
}
|
||||||
isLoadingMore = false;
|
|
||||||
return res;
|
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/common/widgets/overlay_pop.dart';
|
||||||
import 'package:pilipala/pages/home/index.dart';
|
import 'package:pilipala/pages/home/index.dart';
|
||||||
import 'package:pilipala/pages/main/index.dart';
|
import 'package:pilipala/pages/main/index.dart';
|
||||||
import 'package:pilipala/pages/rcmd/index.dart';
|
|
||||||
|
|
||||||
import 'controller.dart';
|
import 'controller.dart';
|
||||||
import 'widgets/live_item.dart';
|
import 'widgets/live_item.dart';
|
||||||
@ -45,8 +44,8 @@ class _LivePageState extends State<LivePage>
|
|||||||
() {
|
() {
|
||||||
if (scrollController.position.pixels >=
|
if (scrollController.position.pixels >=
|
||||||
scrollController.position.maxScrollExtent - 200) {
|
scrollController.position.maxScrollExtent - 200) {
|
||||||
EasyThrottle.throttle('liveList', const Duration(seconds: 1), () {
|
EasyThrottle.throttle('liveList', const Duration(milliseconds: 200),
|
||||||
_liveController.isLoadingMore = true;
|
() {
|
||||||
_liveController.onLoad();
|
_liveController.onLoad();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -108,24 +107,20 @@ class _LivePageState extends State<LivePage>
|
|||||||
} else {
|
} else {
|
||||||
return HttpError(
|
return HttpError(
|
||||||
errMsg: data['msg'],
|
errMsg: data['msg'],
|
||||||
fn: () => {},
|
fn: () {
|
||||||
|
setState(() {
|
||||||
|
_futureBuilderFuture =
|
||||||
|
_liveController.queryLiveList('init');
|
||||||
|
});
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 缓存数据
|
return contentGrid(_liveController, []);
|
||||||
if (_liveController.liveList.length > 1) {
|
|
||||||
return contentGrid(
|
|
||||||
_liveController, _liveController.liveList);
|
|
||||||
}
|
|
||||||
// 骨架屏
|
|
||||||
else {
|
|
||||||
return contentGrid(_liveController, []);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
LoadingMore(ctr: _liveController)
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -44,7 +44,7 @@ class _RcmdPageState extends State<RcmdPage>
|
|||||||
if (scrollController.position.pixels >=
|
if (scrollController.position.pixels >=
|
||||||
scrollController.position.maxScrollExtent - 200) {
|
scrollController.position.maxScrollExtent - 200) {
|
||||||
EasyThrottle.throttle(
|
EasyThrottle.throttle(
|
||||||
'my-throttler', const Duration(milliseconds: 500), () {
|
'my-throttler', const Duration(milliseconds: 200), () {
|
||||||
_rcmdController.isLoadingMore = true;
|
_rcmdController.isLoadingMore = true;
|
||||||
_rcmdController.onLoad();
|
_rcmdController.onLoad();
|
||||||
});
|
});
|
||||||
@ -113,6 +113,7 @@ class _RcmdPageState extends State<RcmdPage>
|
|||||||
errMsg: data['msg'],
|
errMsg: data['msg'],
|
||||||
fn: () {
|
fn: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
_rcmdController.isLoadingMore = true;
|
||||||
_futureBuilderFuture =
|
_futureBuilderFuture =
|
||||||
_rcmdController.queryRcmdFeed('init');
|
_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