diff --git a/lib/pages/bangumi/introduction/controller.dart b/lib/pages/bangumi/introduction/controller.dart index 5b075c0e..710561c8 100644 --- a/lib/pages/bangumi/introduction/controller.dart +++ b/lib/pages/bangumi/introduction/controller.dart @@ -604,21 +604,24 @@ class BangumiIntroController extends CommonController { RxInt followStatus = (-1).obs; Future queryIsFollowed() async { - dynamic result = await Request().get( - 'https://www.bilibili.com/bangumi/play/ss$seasonId', - ); - dom.Document document = html_parser.parse(result.data); - dom.Element? scriptElement = document.querySelector('script#__NEXT_DATA__'); - if (scriptElement != null) { - dynamic scriptContent = jsonDecode(scriptElement.text); - isFollowed.value = - scriptContent['props']['pageProps']['followState']['isFollowed']; - followStatus.value = - scriptContent['props']['pageProps']['followState']['followStatus']; - // int progress = scriptContent['props']['pageProps']['dehydratedState'] - // ['queries'][0]['state']['data']['result'] - // ['play_view_business_info']['user_status']['watch_progress'] - // ['current_watch_progress']; - } + try { + dynamic result = await Request().get( + 'https://www.bilibili.com/bangumi/play/ss$seasonId', + ); + dom.Document document = html_parser.parse(result.data); + dom.Element? scriptElement = + document.querySelector('script#__NEXT_DATA__'); + if (scriptElement != null) { + dynamic scriptContent = jsonDecode(scriptElement.text); + isFollowed.value = + scriptContent['props']['pageProps']['followState']['isFollowed']; + followStatus.value = + scriptContent['props']['pageProps']['followState']['followStatus']; + // int progress = scriptContent['props']['pageProps']['dehydratedState'] + // ['queries'][0]['state']['data']['result'] + // ['play_view_business_info']['user_status']['watch_progress'] + // ['current_watch_progress']; + } + } catch (_) {} } } diff --git a/lib/pages/home/controller.dart b/lib/pages/home/controller.dart index 76c294a2..60c2cfc0 100644 --- a/lib/pages/home/controller.dart +++ b/lib/pages/home/controller.dart @@ -105,10 +105,12 @@ class HomeController extends GetxController with GetTickerProviderStateMixin { } void querySearchDefault() async { - var res = await Request().get(Api.searchDefault); - if (res.data['code'] == 0) { - defaultSearch.value = res.data['data']['name']; - } + try { + var res = await Request().get(Api.searchDefault); + if (res.data['code'] == 0) { + defaultSearch.value = res.data['data']['name']; + } + } catch (_) {} } showUserInfoDialog(context) { diff --git a/lib/pages/main/controller.dart b/lib/pages/main/controller.dart index a02228d8..40822eee 100644 --- a/lib/pages/main/controller.dart +++ b/lib/pages/main/controller.dart @@ -124,37 +124,41 @@ class MainController extends GetxController { } Future _queryPMUnread() async { - dynamic res = await Request().get(Api.msgUnread); - if (res.data['code'] == 0) { - return { - 'status': true, - 'data': ((res.data['data']?['unfollow_unread'] as int?) ?? 0) + - ((res.data['data']?['follow_unread'] as int?) ?? 0), - }; - } else { - return { - 'status': false, - 'msg': res.data['message'], - }; - } + try { + dynamic res = await Request().get(Api.msgUnread); + if (res.data['code'] == 0) { + return { + 'status': true, + 'data': ((res.data['data']?['unfollow_unread'] as int?) ?? 0) + + ((res.data['data']?['follow_unread'] as int?) ?? 0), + }; + } else { + return { + 'status': false, + 'msg': res.data['message'], + }; + } + } catch (_) {} } Future _queryMsgFeedUnread() async { if (isLogin.value.not) { return; } - dynamic res = await Request().get(Api.msgFeedUnread); - if (res.data['code'] == 0) { - return { - 'status': true, - 'data': res.data['data'], - }; - } else { - return { - 'status': false, - 'msg': res.data['message'], - }; - } + try { + dynamic res = await Request().get(Api.msgFeedUnread); + if (res.data['code'] == 0) { + return { + 'status': true, + 'data': res.data['data'], + }; + } else { + return { + 'status': false, + 'msg': res.data['message'], + }; + } + } catch (_) {} } void getUnreadDynamic() async {