diff --git a/lib/pages/history/widgets/item.dart b/lib/pages/history/widgets/item.dart index 05796f17..63a76c20 100644 --- a/lib/pages/history/widgets/item.dart +++ b/lib/pages/history/widgets/item.dart @@ -5,6 +5,7 @@ import 'package:pilipala/common/widgets/badge.dart'; import 'package:pilipala/common/widgets/network_img_layer.dart'; import 'package:pilipala/http/search.dart'; import 'package:pilipala/models/common/business_type.dart'; +import 'package:pilipala/models/live/item.dart'; import 'package:pilipala/utils/id_utils.dart'; import 'package:pilipala/utils/utils.dart'; @@ -19,11 +20,11 @@ class HistoryItem extends StatelessWidget { String heroTag = Utils.makeHeroTag(aid); return InkWell( onTap: () async { - int cid = videoItem.history.cid ?? - // videoItem.history.oid ?? - await SearchHttp.ab2c(aid: aid, bvid: bvid); await Future.delayed(const Duration(milliseconds: 200)); if (videoItem.history.business.contains('article')) { + int cid = videoItem.history.cid ?? + // videoItem.history.oid ?? + await SearchHttp.ab2c(aid: aid, bvid: bvid); Get.toNamed( '/webview', parameters: { @@ -32,7 +33,24 @@ class HistoryItem extends StatelessWidget { 'pageTitle': videoItem.title }, ); + } else if (videoItem.history.business == 'live' && + videoItem.liveStatus == 1) { + LiveItemModel liveItem = LiveItemModel.fromJson({ + 'face': videoItem.authorFace, + 'roomid': videoItem.history.oid, + 'pic': videoItem.cover, + 'title': videoItem.title, + 'uname': videoItem.authorName, + 'cover': videoItem.cover, + }); + Get.toNamed( + '/liveRoom?roomId=${videoItem.history.oid}', + arguments: {'liveItem': liveItem}, + ); } else { + int cid = videoItem.history.cid ?? + // videoItem.history.oid ?? + await SearchHttp.ab2c(aid: aid, bvid: bvid); Get.toNamed('/video?bvid=$bvid&cid=$cid', arguments: {'heroTag': heroTag, 'pic': videoItem.cover}); } diff --git a/lib/pages/liveRoom/controller.dart b/lib/pages/liveRoom/controller.dart index 93bf1018..1cbdd753 100644 --- a/lib/pages/liveRoom/controller.dart +++ b/lib/pages/liveRoom/controller.dart @@ -21,13 +21,12 @@ class LiveRoomController extends GetxController { @override void onInit() { super.onInit(); + roomId = int.parse(Get.parameters['roomId']!); if (Get.arguments != null) { - var args = Get.arguments['liveItem']; + liveItem = Get.arguments['liveItem']; heroTag = Get.arguments['heroTag'] ?? ''; - liveItem = args; - roomId = liveItem.roomId!; - if (args.pic != null && args.pic != '') { - cover = args.cover; + if (liveItem.pic != null && liveItem.pic != '') { + cover = liveItem.cover; } } queryLiveInfo();