feat: live search

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-05-06 20:31:09 +08:00
parent 867efecc54
commit 661e7bfa78
23 changed files with 835 additions and 68 deletions

View File

@@ -0,0 +1 @@
enum LiveSearchType { room, user }

View 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?,
);
}

View 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>),
);
}

View 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?,
);
}

View 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>),
);
}

View 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?,
);
}

View 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?,
);
}

View 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?,
);
}