refactor: related

This commit is contained in:
bggRGjQaUbCoE
2024-09-08 16:58:21 +08:00
parent 15c5755392
commit 2bcddc1097
8 changed files with 94 additions and 130 deletions

View File

@@ -275,7 +275,7 @@ class VideoHttp {
}
// 相关视频
static Future relatedVideoList({required String bvid}) async {
static Future<LoadingState> relatedVideoList({required String bvid}) async {
var res = await Request().get(Api.relatedList, data: {'bvid': bvid});
if (res.data['code'] == 0) {
List<HotVideoItemModel> list = [];
@@ -285,9 +285,13 @@ class VideoHttp {
list.add(videoItem);
}
}
return {'status': true, 'data': list};
if (list.isNotEmpty) {
return LoadingState.success(list);
} else {
return LoadingState.empty();
}
} else {
return {'status': false, 'data': [], 'msg': res.data['message']};
return LoadingState.error(res.data['message']);
}
}