mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
202 lines
4.6 KiB
Dart
202 lines
4.6 KiB
Dart
part of 'comic_source.dart';
|
|
|
|
class Comment {
|
|
final String userName;
|
|
final String? avatar;
|
|
final String content;
|
|
final String? time;
|
|
final int? replyCount;
|
|
final String? id;
|
|
final int? score;
|
|
final bool? isLiked;
|
|
final int? voteStatus; // 1: upvote, -1: downvote, 0: none
|
|
|
|
static String? parseTime(dynamic value) {
|
|
if(value == null) return null;
|
|
if(value is int) {
|
|
if(value < 10000000000) {
|
|
return DateTime.fromMillisecondsSinceEpoch(value * 1000).toString().substring(0, 19);
|
|
} else {
|
|
return DateTime.fromMillisecondsSinceEpoch(value).toString().substring(0, 19);
|
|
}
|
|
}
|
|
return value.toString();
|
|
}
|
|
|
|
Comment.fromJson(Map<String, dynamic> json)
|
|
: userName = json["userName"],
|
|
avatar = json["avatar"],
|
|
content = json["content"],
|
|
time = parseTime(json["time"]),
|
|
replyCount = json["replyCount"],
|
|
id = json["id"].toString(),
|
|
score = json["score"],
|
|
isLiked = json["isLiked"],
|
|
voteStatus = json["voteStatus"];
|
|
}
|
|
|
|
class Comic {
|
|
final String title;
|
|
|
|
final String cover;
|
|
|
|
final String id;
|
|
|
|
final String? subtitle;
|
|
|
|
final List<String>? tags;
|
|
|
|
final String description;
|
|
|
|
final String sourceKey;
|
|
|
|
final int? maxPage;
|
|
|
|
final String? language;
|
|
|
|
const Comic(
|
|
this.title,
|
|
this.cover,
|
|
this.id,
|
|
this.subtitle,
|
|
this.tags,
|
|
this.description,
|
|
this.sourceKey,
|
|
this.maxPage,
|
|
this.language,
|
|
);
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
"title": title,
|
|
"cover": cover,
|
|
"id": id,
|
|
"subTitle": subtitle,
|
|
"tags": tags,
|
|
"description": description,
|
|
"sourceKey": sourceKey,
|
|
"maxPage": maxPage,
|
|
"language": language,
|
|
};
|
|
}
|
|
|
|
Comic.fromJson(Map<String, dynamic> json, this.sourceKey)
|
|
: title = json["title"],
|
|
subtitle = json["subTitle"] ?? "",
|
|
cover = json["cover"],
|
|
id = json["id"],
|
|
tags = List<String>.from(json["tags"] ?? []),
|
|
description = json["description"] ?? "",
|
|
maxPage = json["maxPage"],
|
|
language = json["language"];
|
|
}
|
|
|
|
class ComicDetails with HistoryMixin {
|
|
@override
|
|
final String title;
|
|
|
|
@override
|
|
final String? subTitle;
|
|
|
|
@override
|
|
final String cover;
|
|
|
|
final String? description;
|
|
|
|
final Map<String, List<String>> tags;
|
|
|
|
/// id-name
|
|
final Map<String, String>? chapters;
|
|
|
|
final List<String>? thumbnails;
|
|
|
|
final List<Comic>? recommend;
|
|
|
|
final String sourceKey;
|
|
|
|
final String comicId;
|
|
|
|
final bool? isFavorite;
|
|
|
|
final String? subId;
|
|
|
|
final bool? isLiked;
|
|
|
|
final int? likesCount;
|
|
|
|
final int? commentsCount;
|
|
|
|
final String? uploader;
|
|
|
|
final String? uploadTime;
|
|
|
|
final String? updateTime;
|
|
|
|
final String? url;
|
|
|
|
static Map<String, List<String>> _generateMap(Map<dynamic, dynamic> map) {
|
|
var res = <String, List<String>>{};
|
|
map.forEach((key, value) {
|
|
res[key] = List<String>.from(value);
|
|
});
|
|
return res;
|
|
}
|
|
|
|
ComicDetails.fromJson(Map<String, dynamic> json)
|
|
: title = json["title"],
|
|
subTitle = json["subTitle"],
|
|
cover = json["cover"],
|
|
description = json["description"],
|
|
tags = _generateMap(json["tags"]),
|
|
chapters = json["chapters"] == null
|
|
? null
|
|
: Map<String, String>.from(json["chapters"]),
|
|
sourceKey = json["sourceKey"],
|
|
comicId = json["comicId"],
|
|
thumbnails = ListOrNull.from(json["thumbnails"]),
|
|
recommend = (json["recommend"] as List?)
|
|
?.map((e) => Comic.fromJson(e, json["sourceKey"]))
|
|
.toList(),
|
|
isFavorite = json["isFavorite"],
|
|
subId = json["subId"],
|
|
likesCount = json["likesCount"],
|
|
isLiked = json["isLiked"],
|
|
commentsCount = json["commentsCount"],
|
|
uploader = json["uploader"],
|
|
uploadTime = json["uploadTime"],
|
|
updateTime = json["updateTime"],
|
|
url = json["url"];
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
"title": title,
|
|
"subTitle": subTitle,
|
|
"cover": cover,
|
|
"description": description,
|
|
"tags": tags,
|
|
"chapters": chapters,
|
|
"thumbnails": thumbnails,
|
|
"recommend": null,
|
|
"sourceKey": sourceKey,
|
|
"comicId": comicId,
|
|
"isFavorite": isFavorite,
|
|
"subId": subId,
|
|
"isLiked": isLiked,
|
|
"likesCount": likesCount,
|
|
"commentsCount": commentsCount,
|
|
"uploader": uploader,
|
|
"uploadTime": uploadTime,
|
|
"updateTime": updateTime,
|
|
"url": url,
|
|
};
|
|
}
|
|
|
|
@override
|
|
HistoryType get historyType => HistoryType(sourceKey.hashCode);
|
|
|
|
@override
|
|
String get id => comicId;
|
|
|
|
ComicType get comicType => ComicType(sourceKey.hashCode);
|
|
}
|