mod: try-catch some requests

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-02-12 22:17:01 +08:00
parent d996e0a7dd
commit 675932aa69
3 changed files with 54 additions and 45 deletions

View File

@@ -604,11 +604,13 @@ class BangumiIntroController extends CommonController {
RxInt followStatus = (-1).obs; RxInt followStatus = (-1).obs;
Future queryIsFollowed() async { Future queryIsFollowed() async {
try {
dynamic result = await Request().get( dynamic result = await Request().get(
'https://www.bilibili.com/bangumi/play/ss$seasonId', 'https://www.bilibili.com/bangumi/play/ss$seasonId',
); );
dom.Document document = html_parser.parse(result.data); dom.Document document = html_parser.parse(result.data);
dom.Element? scriptElement = document.querySelector('script#__NEXT_DATA__'); dom.Element? scriptElement =
document.querySelector('script#__NEXT_DATA__');
if (scriptElement != null) { if (scriptElement != null) {
dynamic scriptContent = jsonDecode(scriptElement.text); dynamic scriptContent = jsonDecode(scriptElement.text);
isFollowed.value = isFollowed.value =
@@ -620,5 +622,6 @@ class BangumiIntroController extends CommonController {
// ['play_view_business_info']['user_status']['watch_progress'] // ['play_view_business_info']['user_status']['watch_progress']
// ['current_watch_progress']; // ['current_watch_progress'];
} }
} catch (_) {}
} }
} }

View File

@@ -105,10 +105,12 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
} }
void querySearchDefault() async { void querySearchDefault() async {
try {
var res = await Request().get(Api.searchDefault); var res = await Request().get(Api.searchDefault);
if (res.data['code'] == 0) { if (res.data['code'] == 0) {
defaultSearch.value = res.data['data']['name']; defaultSearch.value = res.data['data']['name'];
} }
} catch (_) {}
} }
showUserInfoDialog(context) { showUserInfoDialog(context) {

View File

@@ -124,6 +124,7 @@ class MainController extends GetxController {
} }
Future _queryPMUnread() async { Future _queryPMUnread() async {
try {
dynamic res = await Request().get(Api.msgUnread); dynamic res = await Request().get(Api.msgUnread);
if (res.data['code'] == 0) { if (res.data['code'] == 0) {
return { return {
@@ -137,12 +138,14 @@ class MainController extends GetxController {
'msg': res.data['message'], 'msg': res.data['message'],
}; };
} }
} catch (_) {}
} }
Future _queryMsgFeedUnread() async { Future _queryMsgFeedUnread() async {
if (isLogin.value.not) { if (isLogin.value.not) {
return; return;
} }
try {
dynamic res = await Request().get(Api.msgFeedUnread); dynamic res = await Request().get(Api.msgFeedUnread);
if (res.data['code'] == 0) { if (res.data['code'] == 0) {
return { return {
@@ -155,6 +158,7 @@ class MainController extends GetxController {
'msg': res.data['message'], 'msg': res.data['message'],
}; };
} }
} catch (_) {}
} }
void getUnreadDynamic() async { void getUnreadDynamic() async {