Files
2026-09-15 15:44:13 +07:00

91 lines
3.1 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import '../cartoon_media_info.dart';
import '../video_model.dart';
import 'module_detail_model.dart';
/// 片库筛选面板的全部可选项(分类 / 排序 / 付费 / 标签 / 时间)
class HomeVideoLibrary {
List<TimeType>? canvas;
List<TimeType>? orderBy;
List<TimeType>? paymentType;
List<Tags>? vidTags;
List<Tags>? acgTags;
List<TimeType>? timeType;
HomeVideoLibrary();
HomeVideoLibrary.fromJson(dynamic json) {
canvas = (json['canvas'] as List?)?.map((e) => TimeType.fromJson(e)).toList();
orderBy = (json['orderBy'] as List?)?.map((e) => TimeType.fromJson(e)).toList();
paymentType = (json['paymentType'] as List?)?.map((e) => TimeType.fromJson(e)).toList();
vidTags = (json['vidTags'] as List?)?.map((e) => Tags.fromJson(e)).toList();
acgTags = (json['acgTags'] as List?)?.map((e) => Tags.fromJson(e)).toList();
timeType = (json['timeType'] as List?)?.map((e) => TimeType.fromJson(e)).toList();
}
//一项都没有就别渲染筛选面板了;timeType 不算,它单独有默认值
bool get isNotEmpty =>
canvas?.isNotEmpty == true ||
orderBy?.isNotEmpty == true ||
paymentType?.isNotEmpty == true ||
acgTags?.isNotEmpty == true ||
vidTags?.isNotEmpty == true;
}
/// 筛选面板里的一个选项,key 传给接口、name 给用户看
class TimeType {
String? key;
String? name;
TimeType.fromJson(dynamic json) {
key = json['key'];
name = json['name'];
}
bool get isACG => name?.contains("动漫") == true || name?.contains("漫画") == true;
Map<String, dynamic> toJson() => {'key': key, 'name': name};
}
/// 用户当前选中的筛选组合,整个塞进请求参数
class Keyword {
TimeType? canvas;
TimeType? orderBy;
Tags? tags;
TimeType? paymentType;
TimeType? timeType;
Keyword();
Keyword.fromJson(dynamic json) {
canvas = json['canvas'] != null ? TimeType.fromJson(json['canvas']) : null;
orderBy = json['orderBy'] != null ? TimeType.fromJson(json['orderBy']) : null;
tags = json['tags'] != null ? Tags.fromJson(json['tags']) : null;
paymentType = json['paymentType'] != null ? TimeType.fromJson(json['paymentType']) : null;
timeType = json['timeType'] != null ? TimeType.fromJson(json['timeType']) : null;
}
//拼给调用方比对「筛选条件有没有变」,不作他用
String get modelKey => "${canvas?.name}${orderBy?.name}${tags?.name}${paymentType?.name}${timeType?.name}";
Map<String, dynamic> toJson() => {
'canvas': canvas?.toJson(),
'orderBy': orderBy?.toJson(),
'tags': tags?.toJson(),
'paymentType': paymentType?.toJson(),
'timeType': timeType?.toJson(),
}..removeWhere((key, value) => value == null);
}
/// 片库筛选结果:影视走 listACG 走 allMediaList
class HomeVideoLibraryResult {
bool? hasNext;
List<VideoModel>? list;
List<CartoonMediaInfo>? allMediaList;
HomeVideoLibraryResult.fromJson(dynamic json) {
hasNext = json['hasNext'];
list = (json['list'] as List?)?.map((e) => VideoModel.fromJson(e)).toList();
allMediaList = (json['allMediaList'] as List?)?.map((e) => CartoonMediaInfo.fromJson(e)).toList();
}
}