mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: app端推荐参数补充,统一部分代码位置
This commit is contained in:
@@ -35,7 +35,7 @@ class RecVideoItemAppModel {
|
||||
String? title;
|
||||
int? isFollowed;
|
||||
RcmdOwner? owner;
|
||||
RcmdReason? rcmdReason;
|
||||
String? rcmdReason;
|
||||
String? goto;
|
||||
int? param;
|
||||
String? uri;
|
||||
@@ -66,14 +66,10 @@ class RecVideoItemAppModel {
|
||||
//duration = json['cover_right_text'];
|
||||
title = json['title'];
|
||||
owner = RcmdOwner.fromJson(json);
|
||||
rcmdReason = json['rcmd_reason_style'] != null
|
||||
? RcmdReason.fromJson(json['rcmd_reason_style'])
|
||||
: null;
|
||||
rcmdReason = json['bottom_rcmd_reason'] ?? json['top_rcmd_reason'];
|
||||
// 由于app端api并不会直接返回与owner的关注状态
|
||||
// 所以借用推荐原因是否为“已关注”、“新关注”判别关注状态,从而与web端接口等效
|
||||
String rcmdReasonContent = rcmdReason?.content ?? '';
|
||||
isFollowed =
|
||||
(rcmdReasonContent == '已关注') || (rcmdReasonContent == '新关注') ? 1 : 0;
|
||||
isFollowed = (rcmdReason == '已关注') || (rcmdReason == '新关注') ? 1 : 0;
|
||||
// 如果是,就无需再显示推荐原因,交由view统一处理即可
|
||||
if (isFollowed == 1) {
|
||||
rcmdReason = null;
|
||||
@@ -86,7 +82,7 @@ class RecVideoItemAppModel {
|
||||
if (json['goto'] == 'bangumi') {
|
||||
bangumiView = json['cover_left_text_1'];
|
||||
bangumiFollow = json['cover_left_text_2'];
|
||||
bangumiBadge = json['badge'];
|
||||
bangumiBadge = json['cover_right_text'];
|
||||
}
|
||||
|
||||
cardType = json['card_type'];
|
||||
@@ -129,18 +125,6 @@ class RcmdOwner {
|
||||
}
|
||||
}
|
||||
|
||||
class RcmdReason {
|
||||
RcmdReason({
|
||||
this.content,
|
||||
});
|
||||
|
||||
String? content;
|
||||
|
||||
RcmdReason.fromJson(Map<String, dynamic> json) {
|
||||
content = json["text"] ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
class ThreePoint {
|
||||
ThreePoint({
|
||||
this.dislikeReasons,
|
||||
|
||||
@@ -46,7 +46,7 @@ class RecVideoItemModel {
|
||||
@HiveField(11)
|
||||
int? isFollowed;
|
||||
@HiveField(12)
|
||||
RcmdReason? rcmdReason;
|
||||
String? rcmdReason;
|
||||
|
||||
RecVideoItemModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json["id"];
|
||||
@@ -61,9 +61,10 @@ class RecVideoItemModel {
|
||||
owner = Owner.fromJson(json["owner"]);
|
||||
stat = Stat.fromJson(json["stat"]);
|
||||
isFollowed = json["is_followed"] ?? 0;
|
||||
rcmdReason = json["rcmd_reason"] != null
|
||||
? RcmdReason.fromJson(json["rcmd_reason"])
|
||||
: RcmdReason(content: '');
|
||||
// rcmdReason = json["rcmd_reason"] != null
|
||||
// ? RcmdReason.fromJson(json["rcmd_reason"])
|
||||
// : RcmdReason(content: '');
|
||||
rcmdReason = json["rcmd_reason"]?['content'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,19 +90,19 @@ class Stat {
|
||||
}
|
||||
}
|
||||
|
||||
@HiveType(typeId: 2)
|
||||
class RcmdReason {
|
||||
RcmdReason({
|
||||
this.reasonType,
|
||||
this.content,
|
||||
});
|
||||
@HiveField(0)
|
||||
int? reasonType;
|
||||
@HiveField(1)
|
||||
String? content = '';
|
||||
|
||||
RcmdReason.fromJson(Map<String, dynamic> json) {
|
||||
reasonType = json["reason_type"];
|
||||
content = json["content"] ?? '';
|
||||
}
|
||||
}
|
||||
// @HiveType(typeId: 2)
|
||||
// class RcmdReason {
|
||||
// RcmdReason({
|
||||
// this.reasonType,
|
||||
// this.content,
|
||||
// });
|
||||
// @HiveField(0)
|
||||
// int? reasonType;
|
||||
// @HiveField(1)
|
||||
// String? content = '';
|
||||
//
|
||||
// RcmdReason.fromJson(Map<String, dynamic> json) {
|
||||
// reasonType = json["reason_type"];
|
||||
// content = json["content"] ?? '';
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -29,7 +29,7 @@ class RecVideoItemModelAdapter extends TypeAdapter<RecVideoItemModel> {
|
||||
owner: fields[9] as Owner?,
|
||||
stat: fields[10] as Stat?,
|
||||
isFollowed: fields[11] as int?,
|
||||
rcmdReason: fields[12] as RcmdReason?,
|
||||
rcmdReason: fields[12] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -115,40 +115,40 @@ class StatAdapter extends TypeAdapter<Stat> {
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
|
||||
class RcmdReasonAdapter extends TypeAdapter<RcmdReason> {
|
||||
@override
|
||||
final int typeId = 2;
|
||||
|
||||
@override
|
||||
RcmdReason read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return RcmdReason(
|
||||
reasonType: fields[0] as int?,
|
||||
content: fields[1] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, RcmdReason obj) {
|
||||
writer
|
||||
..writeByte(2)
|
||||
..writeByte(0)
|
||||
..write(obj.reasonType)
|
||||
..writeByte(1)
|
||||
..write(obj.content);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is RcmdReasonAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
//
|
||||
// class RcmdReasonAdapter extends TypeAdapter<RcmdReason> {
|
||||
// @override
|
||||
// final int typeId = 2;
|
||||
//
|
||||
// @override
|
||||
// RcmdReason read(BinaryReader reader) {
|
||||
// final numOfFields = reader.readByte();
|
||||
// final fields = <int, dynamic>{
|
||||
// for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
// };
|
||||
// return RcmdReason(
|
||||
// reasonType: fields[0] as int?,
|
||||
// content: fields[1] as String?,
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void write(BinaryWriter writer, RcmdReason obj) {
|
||||
// writer
|
||||
// ..writeByte(2)
|
||||
// ..writeByte(0)
|
||||
// ..write(obj.reasonType)
|
||||
// ..writeByte(1)
|
||||
// ..write(obj.content);
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// int get hashCode => typeId.hashCode;
|
||||
//
|
||||
// @override
|
||||
// bool operator ==(Object other) =>
|
||||
// identical(this, other) ||
|
||||
// other is RcmdReasonAdapter &&
|
||||
// runtimeType == other.runtimeType &&
|
||||
// typeId == other.typeId;
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user