mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: data parse
related #258 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -8,7 +8,6 @@ class ReplyContent {
|
||||
this.pictures, // {}
|
||||
this.vote,
|
||||
this.richText,
|
||||
this.isText,
|
||||
this.topicsMeta,
|
||||
});
|
||||
|
||||
@@ -20,27 +19,19 @@ class ReplyContent {
|
||||
List? pictures;
|
||||
Map? vote;
|
||||
Map? richText;
|
||||
bool? isText;
|
||||
Map? topicsMeta;
|
||||
|
||||
ReplyContent.fromJson(Map<String, dynamic> json) {
|
||||
message = json['message']
|
||||
.replaceAll('>', '>')
|
||||
.replaceAll('"', '"')
|
||||
.replaceAll(''', "'");
|
||||
message = json['message'];
|
||||
atNameToMid = json['at_name_to_mid'] ?? {};
|
||||
members = json['members'] != null
|
||||
? json['members']
|
||||
.map<MemberItemModel>((e) => MemberItemModel.fromJson(e))
|
||||
.toList()
|
||||
: [];
|
||||
members = (json['members'] as List?)
|
||||
?.map<MemberItemModel>((e) => MemberItemModel.fromJson(e))
|
||||
.toList();
|
||||
emote = json['emote'] ?? {};
|
||||
jumpUrl = json['jump_url'] ?? {};
|
||||
pictures = json['pictures'] ?? [];
|
||||
vote = json['vote'] ?? {};
|
||||
richText = json['rich_text'] ?? {};
|
||||
// 不包含@ 笔记 图片的时候,文字可折叠
|
||||
isText = atNameToMid!.isEmpty && vote!.isEmpty && pictures!.isEmpty;
|
||||
topicsMeta = json['topics_meta'] ?? {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,15 +27,15 @@ class ReplyData {
|
||||
json['cursor'] == null ? null : ReplyCursor.fromJson(json['cursor']);
|
||||
config =
|
||||
json['config'] == null ? null : ReplyConfig.fromJson(json['config']);
|
||||
replies = json['replies'] != null
|
||||
? List<ReplyItemModel>.from(json['replies'].map<ReplyItemModel>(
|
||||
(item) => ReplyItemModel.fromJson(item, json['upper']['mid'])))
|
||||
: <ReplyItemModel>[];
|
||||
topReplies = json['top_replies'] != null
|
||||
? List<ReplyItemModel>.from(json['top_replies'].map<ReplyItemModel>(
|
||||
(item) => ReplyItemModel.fromJson(item, json['upper']['mid'],
|
||||
isTopStatus: true)))
|
||||
: <ReplyItemModel>[];
|
||||
replies = (json['replies'] as List?)
|
||||
?.map<ReplyItemModel>(
|
||||
(item) => ReplyItemModel.fromJson(item, json['upper']['mid']))
|
||||
.toList();
|
||||
topReplies = (json['top_replies'] as List?)
|
||||
?.map<ReplyItemModel>((item) => ReplyItemModel.fromJson(
|
||||
item, json['upper']['mid'],
|
||||
isTopStatus: true))
|
||||
.toList();
|
||||
upper = json['upper'] == null ? null : ReplyUpper.fromJson(json['upper']);
|
||||
}
|
||||
}
|
||||
@@ -60,15 +60,15 @@ class ReplyReplyData {
|
||||
ReplyReplyData.fromJson(Map<String, dynamic> json) {
|
||||
page = ReplyPage.fromJson(json['page']);
|
||||
config = ReplyConfig.fromJson(json['config']);
|
||||
replies = json['replies'] != null
|
||||
? List<ReplyItemModel>.from(json['replies'].map<ReplyItemModel>(
|
||||
(item) => ReplyItemModel.fromJson(item, json['upper']['mid'])))
|
||||
: <ReplyItemModel>[];
|
||||
topReplies = json['top_replies'] != null
|
||||
? List<ReplyItemModel>.from(json['top_replies'].map<ReplyItemModel>(
|
||||
(item) => ReplyItemModel.fromJson(item, json['upper']['mid'],
|
||||
isTopStatus: true)))
|
||||
: <ReplyItemModel>[];
|
||||
replies = (json['replies'] as List?)
|
||||
?.map<ReplyItemModel>(
|
||||
(item) => ReplyItemModel.fromJson(item, json['upper']['mid']))
|
||||
.toList();
|
||||
topReplies = (json['top_replies'] as List?)
|
||||
?.map<ReplyItemModel>((item) => ReplyItemModel.fromJson(
|
||||
item, json['upper']['mid'],
|
||||
isTopStatus: true))
|
||||
.toList();
|
||||
upper = ReplyUpper.fromJson(json['upper']);
|
||||
root = ReplyItemModel.fromJson(json['root'], json['upper']['mid']);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ class EmoteModelData {
|
||||
|
||||
EmoteModelData.fromJson(Map<String, dynamic> json) {
|
||||
setting =
|
||||
json['setting'] != null ? Setting.fromJson(json['setting']) : null;
|
||||
json['setting'] != null ? Setting.fromJson(json['setting']) : null;
|
||||
if (json['packages'] != null) {
|
||||
packages = <Packages>[];
|
||||
json['packages'].forEach((v) {
|
||||
@@ -68,17 +68,17 @@ class Packages {
|
||||
|
||||
Packages(
|
||||
{this.id,
|
||||
this.text,
|
||||
this.url,
|
||||
this.mtime,
|
||||
this.type,
|
||||
this.attr,
|
||||
this.meta,
|
||||
this.emote,
|
||||
this.flags,
|
||||
this.label,
|
||||
this.packageSubTitle,
|
||||
this.refMid});
|
||||
this.text,
|
||||
this.url,
|
||||
this.mtime,
|
||||
this.type,
|
||||
this.attr,
|
||||
this.meta,
|
||||
this.emote,
|
||||
this.flags,
|
||||
this.label,
|
||||
this.packageSubTitle,
|
||||
this.refMid});
|
||||
|
||||
Packages.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
@@ -95,7 +95,7 @@ class Packages {
|
||||
});
|
||||
}
|
||||
flags =
|
||||
json['flags'] != null ? PackagesFlags.fromJson(json['flags']) : null;
|
||||
json['flags'] != null ? PackagesFlags.fromJson(json['flags']) : null;
|
||||
label = json['label'] != null ? Label.fromJson(json['label']) : null;
|
||||
packageSubTitle = json['package_sub_title'];
|
||||
refMid = json['ref_mid'];
|
||||
@@ -189,16 +189,16 @@ class Emote {
|
||||
|
||||
Emote(
|
||||
{this.id,
|
||||
this.packageId,
|
||||
this.text,
|
||||
this.url,
|
||||
this.mtime,
|
||||
this.type,
|
||||
this.attr,
|
||||
this.meta,
|
||||
this.flags,
|
||||
this.activity,
|
||||
this.gifUrl});
|
||||
this.packageId,
|
||||
this.text,
|
||||
this.url,
|
||||
this.mtime,
|
||||
this.type,
|
||||
this.attr,
|
||||
this.meta,
|
||||
this.flags,
|
||||
this.activity,
|
||||
this.gifUrl});
|
||||
|
||||
Emote.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
@@ -245,9 +245,7 @@ class EmoteMeta {
|
||||
|
||||
EmoteMeta.fromJson(Map<String, dynamic> json) {
|
||||
size = json['size'];
|
||||
suggest = json['suggest'] == null
|
||||
? null
|
||||
: List<String>.from(json['suggest'].map((x) => x));
|
||||
suggest = json['suggest'];
|
||||
alias = json['alias'];
|
||||
gifUrl = json['gif_url'];
|
||||
}
|
||||
|
||||
@@ -86,10 +86,9 @@ class ReplyItemModel {
|
||||
action = json['action'];
|
||||
member = ReplyMember.fromJson(json['member']);
|
||||
content = ReplyContent.fromJson(json['content']);
|
||||
replies = json['replies'] != null
|
||||
? List<ReplyItemModel>.from(json['replies']
|
||||
.map((item) => ReplyItemModel.fromJson(item, upperMid)))
|
||||
: <ReplyItemModel>[];
|
||||
replies = (json['replies'] as List?)
|
||||
?.map((item) => ReplyItemModel.fromJson(item, upperMid))
|
||||
.toList();
|
||||
assist = json['assist'];
|
||||
upAction = UpAction.fromJson(json['up_action']);
|
||||
invisible = json['invisible'];
|
||||
@@ -98,9 +97,8 @@ class ReplyItemModel {
|
||||
: ReplyControl.fromJson(json['reply_control']);
|
||||
isUp = upperMid.toString() == json['member']['mid'];
|
||||
isTop = isTopStatus;
|
||||
cardLabel = json['card_label'] != null
|
||||
? json['card_label'].map((e) => e['text_content']).toList()
|
||||
: [];
|
||||
cardLabel =
|
||||
(json['card_label'] as List?)?.map((e) => e['text_content']).toList();
|
||||
rcount = json['rcount'];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user