From e7af9b0ab3752f832f7675b336f030e3ff81978f Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Wed, 25 Sep 2024 16:56:53 +0800 Subject: [PATCH] opt: video cover --- lib/common/widgets/list_sheet.dart | 20 +++++++++++-------- lib/http/video.dart | 1 - .../video/detail/introduction/controller.dart | 11 ++++++++-- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/common/widgets/list_sheet.dart b/lib/common/widgets/list_sheet.dart index c49e8a52..f7040717 100644 --- a/lib/common/widgets/list_sheet.dart +++ b/lib/common/widgets/list_sheet.dart @@ -122,14 +122,18 @@ class _ListSheetContentState extends State { } SmartDialog.showToast('切换到:$title'); widget.onClose(); - if (episode is bangumi.EpisodeItem && episode.cover != null) { - widget.changeFucCall( - episode.bvid, episode.cid, episode.aid, episode.cover); - } else if (episode.runtimeType.toString() == "EpisodeItem") { - widget.changeFucCall(episode.bvid, episode.cid, episode.aid, null); - } else { - widget.changeFucCall(widget.bvid!, episode.cid, widget.aid!, null); - } + widget.changeFucCall( + episode.runtimeType.toString() == "EpisodeItem" + ? episode.bvid + : widget.bvid, + episode.cid, + episode.aid, + episode is video.EpisodeItem + ? episode.arc?.pic + : episode is bangumi.EpisodeItem + ? episode.cover + : null, + ); }, dense: false, leading: (episode is video.EpisodeItem && episode.arc?.pic != null) || diff --git a/lib/http/video.dart b/lib/http/video.dart index 9af4ec08..63b9cf0f 100644 --- a/lib/http/video.dart +++ b/lib/http/video.dart @@ -254,7 +254,6 @@ class VideoHttp { return { 'status': true, 'data': result.data!, - 'pic': result.data?.pic ?? '', }; } else { // Map errMap = { diff --git a/lib/pages/video/detail/introduction/controller.dart b/lib/pages/video/detail/introduction/controller.dart index 8065214f..323d788d 100644 --- a/lib/pages/video/detail/introduction/controller.dart +++ b/lib/pages/video/detail/introduction/controller.dart @@ -123,7 +123,14 @@ class VideoIntroController extends GetxController { var result = await VideoHttp.videoIntro(bvid: bvid); if (result['status']) { videoDetail.value = result['data']!; - videoDetailController.videoItem['pic'] = result['pic']!; + if (videoDetailController.videoItem['pic'] == null || + videoDetailController.videoItem['pic'] == '') { + try { + videoDetailController.videoItem['pic'] = result['data'].pic; + } catch (e) { + debugPrint(e.toString()); + } + } if (videoDetail.value.pages != null && videoDetail.value.pages!.isNotEmpty && lastPlayCid.value == 0) { @@ -475,7 +482,7 @@ class VideoIntroController extends GetxController { videoDetailCtr.oid.value = aid ?? IdUtils.bv2av(bvid); videoDetailCtr.cid.value = cid; if (cover is String && cover.isNotEmpty) { - videoItem!['pic'] = cover; + videoDetailCtr.videoItem['pic'] = cover; } videoDetailCtr.danmakuCid.value = cid; videoDetailCtr.queryVideoUrl();