Merge branch 'main' into fix
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
// 首页推荐类型
|
||||
enum RcmdType { web, app }
|
||||
enum RcmdType { web, app, notLogin }
|
||||
|
||||
extension RcmdTypeExtension on RcmdType {
|
||||
String get values => ['web', 'app'][index];
|
||||
String get labels => ['web端', 'app端'][index];
|
||||
String get values => ['web', 'app', 'notLogin'][index];
|
||||
String get labels => ['web端', 'app端', '游客模式'][index];
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
enum ReplySortType { time, like, reply }
|
||||
enum ReplySortType { time, like }
|
||||
|
||||
extension ReplySortTypeExtension on ReplySortType {
|
||||
String get titles => ['最新评论', '最热评论', '回复最多'][index];
|
||||
String get labels => ['最新', '最热', '最多回复'][index];
|
||||
String get titles => ['最新评论', '最热评论'][index];
|
||||
String get labels => ['最新', '最热'][index];
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class RecVideoItemAppModel {
|
||||
int? cid;
|
||||
String? pic;
|
||||
RcmdStat? stat;
|
||||
String? duration;
|
||||
int? duration;
|
||||
String? title;
|
||||
int? isFollowed;
|
||||
RcmdOwner? owner;
|
||||
@ -54,13 +54,27 @@ class RecVideoItemAppModel {
|
||||
cid = json['player_args'] != null ? json['player_args']['cid'] : -1;
|
||||
pic = json['cover'];
|
||||
stat = RcmdStat.fromJson(json);
|
||||
duration = json['cover_right_text'];
|
||||
// 改用player_args中的duration作为原始数据(秒数)
|
||||
duration = json['player_args'] != null
|
||||
? json['player_args']['duration']
|
||||
: -1;
|
||||
//duration = json['cover_right_text'];
|
||||
title = json['title'];
|
||||
isFollowed = 0;
|
||||
owner = RcmdOwner.fromJson(json);
|
||||
rcmdReason = json['rcmd_reason_style'] != null
|
||||
? RcmdReason.fromJson(json['rcmd_reason_style'])
|
||||
: null;
|
||||
// 由于app端api并不会直接返回与owner的关注状态
|
||||
// 所以借用推荐原因是否为“已关注”、“新关注”等判别关注状态,从而与web端接口等效
|
||||
isFollowed = rcmdReason != null &&
|
||||
rcmdReason!.content != null &&
|
||||
rcmdReason!.content!.contains('关注')
|
||||
? 1
|
||||
: 0;
|
||||
// 如果是,就无需再显示推荐原因,交由view统一处理即可
|
||||
if (isFollowed == 1) {
|
||||
rcmdReason = null;
|
||||
}
|
||||
goto = json['goto'];
|
||||
param = int.parse(json['param']);
|
||||
uri = json['uri'];
|
||||
|
@ -1,5 +1,3 @@
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
|
||||
import './model_owner.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
@ -38,7 +36,7 @@ class RecVideoItemModel {
|
||||
@HiveField(6)
|
||||
String? title = '';
|
||||
@HiveField(7)
|
||||
String? duration = '';
|
||||
int? duration = -1;
|
||||
@HiveField(8)
|
||||
int? pubdate = -1;
|
||||
@HiveField(9)
|
||||
@ -58,7 +56,7 @@ class RecVideoItemModel {
|
||||
uri = json["uri"];
|
||||
pic = json["pic"];
|
||||
title = json["title"];
|
||||
duration = Utils.tampToSeektime(json["duration"]);
|
||||
duration = json["duration"];
|
||||
pubdate = json["pubdate"];
|
||||
owner = Owner.fromJson(json["owner"]);
|
||||
stat = Stat.fromJson(json["stat"]);
|
||||
@ -77,14 +75,15 @@ class Stat {
|
||||
this.danmu,
|
||||
});
|
||||
@HiveField(0)
|
||||
String? view;
|
||||
int? view;
|
||||
@HiveField(1)
|
||||
int? like;
|
||||
@HiveField(2)
|
||||
int? danmu;
|
||||
|
||||
Stat.fromJson(Map<String, dynamic> json) {
|
||||
view = Utils.numFormat(json["view"]);
|
||||
// 无需在model中转换以保留原始数据,在view层处理即可
|
||||
view = json["view"];
|
||||
like = json["like"];
|
||||
danmu = json['danmaku'];
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class RecVideoItemModelAdapter extends TypeAdapter<RecVideoItemModel> {
|
||||
uri: fields[4] as String?,
|
||||
pic: fields[5] as String?,
|
||||
title: fields[6] as String?,
|
||||
duration: fields[7] as String?,
|
||||
duration: fields[7] as int?,
|
||||
pubdate: fields[8] as int?,
|
||||
owner: fields[9] as Owner?,
|
||||
stat: fields[10] as Stat?,
|
||||
@ -87,7 +87,7 @@ class StatAdapter extends TypeAdapter<Stat> {
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return Stat(
|
||||
view: fields[0] as String?,
|
||||
view: fields[0] as int?,
|
||||
like: fields[1] as int?,
|
||||
danmu: fields[2] as int?,
|
||||
);
|
||||
|
Reference in New Issue
Block a user