mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: unify trending api & feat: search recommend (#694)
* opt: unify trending api * opt: disable icon * feat: search recommend * mod: recommend api
This commit is contained in:
committed by
GitHub
parent
3638d65008
commit
f0e3b776bb
@@ -1,46 +0,0 @@
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
part 'hot.g.dart';
|
||||
|
||||
@HiveType(typeId: 6)
|
||||
class HotSearchModel {
|
||||
HotSearchModel({
|
||||
this.list,
|
||||
});
|
||||
|
||||
@HiveField(0)
|
||||
List<HotSearchItem>? list;
|
||||
|
||||
HotSearchModel.fromJson(Map<String, dynamic> json) {
|
||||
list = (json['list'] as List?)
|
||||
?.map<HotSearchItem>((e) => HotSearchItem.fromJson(e))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
@HiveType(typeId: 7)
|
||||
class HotSearchItem {
|
||||
HotSearchItem({
|
||||
this.keyword,
|
||||
this.showName,
|
||||
this.wordType,
|
||||
this.icon,
|
||||
});
|
||||
|
||||
@HiveField(0)
|
||||
String? keyword;
|
||||
@HiveField(1)
|
||||
String? showName;
|
||||
// 4/5热 11话题 8普通 7直播
|
||||
@HiveField(2)
|
||||
int? wordType;
|
||||
@HiveField(3)
|
||||
String? icon;
|
||||
|
||||
HotSearchItem.fromJson(Map<String, dynamic> json) {
|
||||
keyword = json['keyword'];
|
||||
showName = json['show_name'];
|
||||
wordType = json['word_type'];
|
||||
icon = json['icon'];
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'hot.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// TypeAdapterGenerator
|
||||
// **************************************************************************
|
||||
|
||||
class HotSearchModelAdapter extends TypeAdapter<HotSearchModel> {
|
||||
@override
|
||||
final int typeId = 6;
|
||||
|
||||
@override
|
||||
HotSearchModel read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return HotSearchModel(
|
||||
list: (fields[0] as List?)?.cast<HotSearchItem>(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, HotSearchModel obj) {
|
||||
writer
|
||||
..writeByte(1)
|
||||
..writeByte(0)
|
||||
..write(obj.list);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is HotSearchModelAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
|
||||
class HotSearchItemAdapter extends TypeAdapter<HotSearchItem> {
|
||||
@override
|
||||
final int typeId = 7;
|
||||
|
||||
@override
|
||||
HotSearchItem read(BinaryReader reader) {
|
||||
final numOfFields = reader.readByte();
|
||||
final fields = <int, dynamic>{
|
||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
||||
};
|
||||
return HotSearchItem(
|
||||
keyword: fields[0] as String?,
|
||||
showName: fields[1] as String?,
|
||||
wordType: fields[2] as int?,
|
||||
icon: fields[3] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, HotSearchItem obj) {
|
||||
writer
|
||||
..writeByte(4)
|
||||
..writeByte(0)
|
||||
..write(obj.keyword)
|
||||
..writeByte(1)
|
||||
..write(obj.showName)
|
||||
..writeByte(2)
|
||||
..write(obj.wordType)
|
||||
..writeByte(3)
|
||||
..write(obj.icon);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => typeId.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is HotSearchItemAdapter &&
|
||||
runtimeType == other.runtimeType &&
|
||||
typeId == other.typeId;
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
import 'trending_data.dart';
|
||||
|
||||
class SearchTrending {
|
||||
int? code;
|
||||
String? message;
|
||||
int? ttl;
|
||||
TrendingData? data;
|
||||
|
||||
SearchTrending({this.code, this.message, this.ttl, this.data});
|
||||
|
||||
factory SearchTrending.fromJson(Map<String, dynamic> json) {
|
||||
return SearchTrending(
|
||||
code: json['code'] as int?,
|
||||
message: json['message'] as String?,
|
||||
ttl: json['ttl'] as int?,
|
||||
data: json['data'] == null
|
||||
? null
|
||||
: TrendingData.fromJson(json['data'] as Map<String, dynamic>),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'code': code,
|
||||
'message': message,
|
||||
'ttl': ttl,
|
||||
'data': data?.toJson(),
|
||||
};
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
import 'stat_datas.dart';
|
||||
|
||||
class TopList {
|
||||
int? hotId;
|
||||
String? keyword;
|
||||
String? showName;
|
||||
int? score;
|
||||
int? wordType;
|
||||
int? gotoType;
|
||||
String? gotoValue;
|
||||
String? icon;
|
||||
List<dynamic>? liveId;
|
||||
int? callReason;
|
||||
String? heatLayer;
|
||||
int? pos;
|
||||
int? id;
|
||||
String? status;
|
||||
String? nameType;
|
||||
int? resourceId;
|
||||
int? setGray;
|
||||
List<dynamic>? cardValues;
|
||||
int? heatScore;
|
||||
StatDatas? statDatas;
|
||||
|
||||
TopList({
|
||||
this.hotId,
|
||||
this.keyword,
|
||||
this.showName,
|
||||
this.score,
|
||||
this.wordType,
|
||||
this.gotoType,
|
||||
this.gotoValue,
|
||||
this.icon,
|
||||
this.liveId,
|
||||
this.callReason,
|
||||
this.heatLayer,
|
||||
this.pos,
|
||||
this.id,
|
||||
this.status,
|
||||
this.nameType,
|
||||
this.resourceId,
|
||||
this.setGray,
|
||||
this.cardValues,
|
||||
this.heatScore,
|
||||
this.statDatas,
|
||||
});
|
||||
|
||||
factory TopList.fromJson(Map<String, dynamic> json) => TopList(
|
||||
hotId: json['hot_id'] as int?,
|
||||
keyword: json['keyword'] as String?,
|
||||
showName: json['show_name'] as String?,
|
||||
score: json['score'] as int?,
|
||||
wordType: json['word_type'] as int?,
|
||||
gotoType: json['goto_type'] as int?,
|
||||
gotoValue: json['goto_value'] as String?,
|
||||
icon: json['icon'] as String?,
|
||||
liveId: json['live_id'] as List<dynamic>?,
|
||||
callReason: json['call_reason'] as int?,
|
||||
heatLayer: json['heat_layer'] as String?,
|
||||
pos: json['pos'] as int?,
|
||||
id: json['id'] as int?,
|
||||
status: json['status'] as String?,
|
||||
nameType: json['name_type'] as String?,
|
||||
resourceId: json['resource_id'] as int?,
|
||||
setGray: json['set_gray'] as int?,
|
||||
cardValues: json['card_values'] as List<dynamic>?,
|
||||
heatScore: json['heat_score'] as int?,
|
||||
statDatas: json['stat_datas'] == null
|
||||
? null
|
||||
: StatDatas.fromJson(json['stat_datas'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'hot_id': hotId,
|
||||
'keyword': keyword,
|
||||
'show_name': showName,
|
||||
'score': score,
|
||||
'word_type': wordType,
|
||||
'goto_type': gotoType,
|
||||
'goto_value': gotoValue,
|
||||
'icon': icon,
|
||||
'live_id': liveId,
|
||||
'call_reason': callReason,
|
||||
'heat_layer': heatLayer,
|
||||
'pos': pos,
|
||||
'id': id,
|
||||
'status': status,
|
||||
'name_type': nameType,
|
||||
'resource_id': resourceId,
|
||||
'set_gray': setGray,
|
||||
'card_values': cardValues,
|
||||
'heat_score': heatScore,
|
||||
'stat_datas': statDatas?.toJson(),
|
||||
};
|
||||
}
|
||||
@@ -1,9 +1,19 @@
|
||||
import 'package:PiliPlus/models/search/search_trending/trending_list.dart';
|
||||
|
||||
class TrendingData {
|
||||
class SearchKeywordData {
|
||||
List<SearchKeywordList>? list;
|
||||
|
||||
SearchKeywordData.fromJson(Map<String, dynamic> json) {
|
||||
list =
|
||||
(json['list'] as List?)?.map((e) => TrendingList.fromJson(e)).toList();
|
||||
}
|
||||
}
|
||||
|
||||
class TrendingData implements SearchKeywordData {
|
||||
String? trackid;
|
||||
List<TrendingList>? list;
|
||||
List<TrendingList>? topList;
|
||||
@override
|
||||
List<SearchKeywordList>? list;
|
||||
List<SearchKeywordList>? topList;
|
||||
String? hotwordEggInfo;
|
||||
|
||||
TrendingData({this.trackid, this.list, this.topList, this.hotwordEggInfo});
|
||||
@@ -18,11 +28,4 @@ class TrendingData {
|
||||
.toList(),
|
||||
hotwordEggInfo: json['hotword_egg_info'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'trackid': trackid,
|
||||
'list': list?.map((e) => e.toJson()).toList(),
|
||||
'top_list': topList?.map((e) => e.toJson()).toList(),
|
||||
'hotword_egg_info': hotwordEggInfo,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,47 +1,28 @@
|
||||
class TrendingList {
|
||||
int? position;
|
||||
class SearchKeywordList {
|
||||
String? keyword;
|
||||
String? showName;
|
||||
int? wordType;
|
||||
String? icon;
|
||||
bool? showLiveIcon;
|
||||
|
||||
SearchKeywordList.fromJson(Map<String, dynamic> json) {
|
||||
keyword = json['keyword'] as String?;
|
||||
}
|
||||
}
|
||||
|
||||
class TrendingList extends SearchKeywordList {
|
||||
String? showName;
|
||||
// 4/5热 11话题 8普通 7直播
|
||||
int? wordType;
|
||||
int? hotId;
|
||||
String? isCommercial;
|
||||
int? resourceId;
|
||||
bool? showLiveIcon;
|
||||
|
||||
TrendingList({
|
||||
this.position,
|
||||
this.keyword,
|
||||
this.showName,
|
||||
this.wordType,
|
||||
this.icon,
|
||||
this.hotId,
|
||||
this.isCommercial,
|
||||
this.resourceId,
|
||||
this.showLiveIcon,
|
||||
});
|
||||
|
||||
factory TrendingList.fromJson(Map<String, dynamic> json) => TrendingList(
|
||||
position: json['position'] as int?,
|
||||
keyword: json['keyword'] as String?,
|
||||
showName: json['show_name'] as String?,
|
||||
wordType: json['word_type'] as int?,
|
||||
icon: json['icon'] as String?,
|
||||
hotId: json['hot_id'] as int?,
|
||||
isCommercial: json['is_commercial'] as String?,
|
||||
resourceId: json['resource_id'] as int?,
|
||||
showLiveIcon: json['show_live_icon'] as bool?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'position': position,
|
||||
'keyword': keyword,
|
||||
'show_name': showName,
|
||||
'word_type': wordType,
|
||||
'icon': icon,
|
||||
'hot_id': hotId,
|
||||
'is_commercial': isCommercial,
|
||||
'resource_id': resourceId,
|
||||
'show_live_icon': showLiveIcon,
|
||||
};
|
||||
TrendingList.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
|
||||
showName = json['show_name'] as String?;
|
||||
wordType = json['word_type'] as int?;
|
||||
icon = json['icon'] as String?;
|
||||
hotId = json['hot_id'] as int?;
|
||||
isCommercial = json['is_commercial'] as String?;
|
||||
resourceId = json['resource_id'] as int?;
|
||||
showLiveIcon = json['show_live_icon'] as bool?;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user