diff --git a/lib/common/widgets/video_card_v.dart b/lib/common/widgets/video_card_v.dart index 146a0013..d7f82679 100644 --- a/lib/common/widgets/video_card_v.dart +++ b/lib/common/widgets/video_card_v.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; +import '../../models/home/rcmd/result.dart'; import '../../models/model_rec_video_item.dart'; import 'stat/danmu.dart'; import 'stat/view.dart'; @@ -332,6 +333,27 @@ class VideoStat extends StatelessWidget { Utils.formatTimestampToRelativeTime(videoItem.pubdate)), )), const SizedBox(width: 2), + ], + if (videoItem is RecVideoItemAppModel && + videoItem.desc != null && + videoItem.desc.contains(' · ')) ...[ + const Spacer(), + Expanded( + flex: 0, + child: RichText( + maxLines: 1, + text: TextSpan( + style: TextStyle( + fontSize: + Theme.of(context).textTheme.labelSmall!.fontSize, + color: Theme.of(context) + .colorScheme + .outline + .withOpacity(0.8), + ), + text: Utils.shortenChineseDateString(videoItem.desc.split(' · ').last)), + )), + const SizedBox(width: 2), ] ], ); diff --git a/lib/models/home/rcmd/result.dart b/lib/models/home/rcmd/result.dart index 2a4acf03..95e7b710 100644 --- a/lib/models/home/rcmd/result.dart +++ b/lib/models/home/rcmd/result.dart @@ -23,6 +23,7 @@ class RecVideoItemAppModel { this.cardType, this.adInfo, this.threePoint, + this.desc, }); int? id; @@ -48,6 +49,7 @@ class RecVideoItemAppModel { String? cardType; Map? adInfo; ThreePoint? threePoint; + String? desc; RecVideoItemAppModel.fromJson(Map json) { id = json['player_args'] != null @@ -90,6 +92,7 @@ class RecVideoItemAppModel { threePoint = json['three_point'] != null ? ThreePoint.fromJson(json['three_point']) : null; + desc = json['desc']; } } diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 7c2a2c6b..5e3651a4 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -167,6 +167,11 @@ class Utils { return '${hour > 0 ? "${paddingStr(hour)}:" : ""}${paddingStr(minute)}:${paddingStr(second)}'; } + static String shortenChineseDateString(String date) { + if (date.contains("年")) return '${date.split("年").first}年'; + return date; + } + // 完全相对时间显示 static String formatTimestampToRelativeTime(timeStamp) { var difference = DateTime.now()