mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: live search
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
1
lib/models/common/live_search_type.dart
Normal file
1
lib/models/common/live_search_type.dart
Normal file
@@ -0,0 +1 @@
|
||||
enum LiveSearchType { room, user }
|
||||
39
lib/models/live/live_search/data.dart
Normal file
39
lib/models/live/live_search/data.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import 'room.dart';
|
||||
import 'user.dart';
|
||||
|
||||
class LiveSearchData {
|
||||
String? type;
|
||||
int? page;
|
||||
int? pagesize;
|
||||
Room? room;
|
||||
User? user;
|
||||
String? trackId;
|
||||
String? abtestId;
|
||||
String? query;
|
||||
|
||||
LiveSearchData({
|
||||
this.type,
|
||||
this.page,
|
||||
this.pagesize,
|
||||
this.room,
|
||||
this.user,
|
||||
this.trackId,
|
||||
this.abtestId,
|
||||
this.query,
|
||||
});
|
||||
|
||||
factory LiveSearchData.fromJson(Map<String, dynamic> json) => LiveSearchData(
|
||||
type: json['type'] as String?,
|
||||
page: json['page'] as int?,
|
||||
pagesize: json['pagesize'] as int?,
|
||||
room: json['room'] == null
|
||||
? null
|
||||
: Room.fromJson(json['room'] as Map<String, dynamic>),
|
||||
user: json['user'] == null
|
||||
? null
|
||||
: User.fromJson(json['user'] as Map<String, dynamic>),
|
||||
trackId: json['track_id'] as String?,
|
||||
abtestId: json['abtest_id'] as String?,
|
||||
query: json['query'] as String?,
|
||||
);
|
||||
}
|
||||
19
lib/models/live/live_search/live_search.dart
Normal file
19
lib/models/live/live_search/live_search.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
import 'data.dart';
|
||||
|
||||
class LiveSearch {
|
||||
int? code;
|
||||
String? message;
|
||||
int? ttl;
|
||||
LiveSearchData? data;
|
||||
|
||||
LiveSearch({this.code, this.message, this.ttl, this.data});
|
||||
|
||||
factory LiveSearch.fromJson(Map<String, dynamic> json) => LiveSearch(
|
||||
code: json['code'] as int?,
|
||||
message: json['message'] as String?,
|
||||
ttl: json['ttl'] as int?,
|
||||
data: json['data'] == null
|
||||
? null
|
||||
: LiveSearchData.fromJson(json['data'] as Map<String, dynamic>),
|
||||
);
|
||||
}
|
||||
18
lib/models/live/live_search/room.dart
Normal file
18
lib/models/live/live_search/room.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
import 'room_item.dart';
|
||||
|
||||
class Room {
|
||||
List<LiveSearchRoomItemModel>? list;
|
||||
int? totalRoom;
|
||||
int? totalPage;
|
||||
|
||||
Room({this.list, this.totalRoom, this.totalPage});
|
||||
|
||||
factory Room.fromJson(Map<String, dynamic> json) => Room(
|
||||
list: (json['list'] as List<dynamic>?)
|
||||
?.map((e) =>
|
||||
LiveSearchRoomItemModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
totalRoom: json['total_room'] as int?,
|
||||
totalPage: json['total_page'] as int?,
|
||||
);
|
||||
}
|
||||
38
lib/models/live/live_search/room_item.dart
Normal file
38
lib/models/live/live_search/room_item.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
import 'watched_show.dart';
|
||||
|
||||
class LiveSearchRoomItemModel {
|
||||
int? roomid;
|
||||
String? cover;
|
||||
String? title;
|
||||
String? name;
|
||||
String? face;
|
||||
int? online;
|
||||
String? link;
|
||||
WatchedShow? watchedShow;
|
||||
|
||||
LiveSearchRoomItemModel({
|
||||
this.roomid,
|
||||
this.cover,
|
||||
this.title,
|
||||
this.name,
|
||||
this.face,
|
||||
this.online,
|
||||
this.link,
|
||||
this.watchedShow,
|
||||
});
|
||||
|
||||
factory LiveSearchRoomItemModel.fromJson(Map<String, dynamic> json) =>
|
||||
LiveSearchRoomItemModel(
|
||||
roomid: json['roomid'] as int?,
|
||||
cover: json['cover'] as String?,
|
||||
title: json['title'] as String?,
|
||||
name: json['name'] as String?,
|
||||
face: json['face'] as String?,
|
||||
online: json['online'] as int?,
|
||||
link: json['link'] as String?,
|
||||
watchedShow: json['watched_show'] == null
|
||||
? null
|
||||
: WatchedShow.fromJson(
|
||||
json['watched_show'] as Map<String, dynamic>),
|
||||
);
|
||||
}
|
||||
17
lib/models/live/live_search/user.dart
Normal file
17
lib/models/live/live_search/user.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
import 'package:PiliPlus/models/live/live_search/user_item.dart';
|
||||
|
||||
class User {
|
||||
List<LiveSearchUserItemModel>? list;
|
||||
int? totalUser;
|
||||
int? totalPage;
|
||||
|
||||
User({this.list, this.totalUser, this.totalPage});
|
||||
|
||||
factory User.fromJson(Map<String, dynamic> json) => User(
|
||||
list: (json['list'] as List<dynamic>?)
|
||||
?.map((e) => LiveSearchUserItemModel.fromJson(e))
|
||||
.toList(),
|
||||
totalUser: json['total_user'] as int?,
|
||||
totalPage: json['total_page'] as int?,
|
||||
);
|
||||
}
|
||||
33
lib/models/live/live_search/user_item.dart
Normal file
33
lib/models/live/live_search/user_item.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
class LiveSearchUserItemModel {
|
||||
String? face;
|
||||
String? name;
|
||||
int? liveStatus;
|
||||
String? areaName;
|
||||
int? fansNum;
|
||||
List? roomTags;
|
||||
int? roomid;
|
||||
String? link;
|
||||
|
||||
LiveSearchUserItemModel({
|
||||
this.face,
|
||||
this.name,
|
||||
this.liveStatus,
|
||||
this.areaName,
|
||||
this.fansNum,
|
||||
this.roomTags,
|
||||
this.roomid,
|
||||
this.link,
|
||||
});
|
||||
|
||||
factory LiveSearchUserItemModel.fromJson(Map<String, dynamic> json) =>
|
||||
LiveSearchUserItemModel(
|
||||
face: json['face'] as String?,
|
||||
name: json['name'] as String?,
|
||||
liveStatus: json['live_status'] as int?,
|
||||
areaName: json['areaName'] as String?,
|
||||
fansNum: json['fansNum'] as int?,
|
||||
roomTags: json['roomTags'],
|
||||
roomid: json['roomid'] as int?,
|
||||
link: json['link'] as String?,
|
||||
);
|
||||
}
|
||||
26
lib/models/live/live_search/watched_show.dart
Normal file
26
lib/models/live/live_search/watched_show.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
class WatchedShow {
|
||||
int? num;
|
||||
String? textSmall;
|
||||
String? textLarge;
|
||||
String? icon;
|
||||
int? iconLocation;
|
||||
String? iconWeb;
|
||||
|
||||
WatchedShow({
|
||||
this.num,
|
||||
this.textSmall,
|
||||
this.textLarge,
|
||||
this.icon,
|
||||
this.iconLocation,
|
||||
this.iconWeb,
|
||||
});
|
||||
|
||||
factory WatchedShow.fromJson(Map<String, dynamic> json) => WatchedShow(
|
||||
num: json['num'] as int?,
|
||||
textSmall: json['text_small'] as String?,
|
||||
textLarge: json['text_large'] as String?,
|
||||
icon: json['icon'] as String?,
|
||||
iconLocation: json['icon_location'] as int?,
|
||||
iconWeb: json['icon_web'] as String?,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user