Merge branch 'main' into feature-minePage

This commit is contained in:
guozhigq
2024-10-01 11:47:47 +08:00
22 changed files with 233 additions and 75 deletions

View File

@ -5,7 +5,7 @@ class MessageSystemModel {
int? cursor;
int? type;
String? title;
Map? content;
dynamic content;
Source? source;
String? timeAt;
int? cardType;
@ -45,7 +45,9 @@ class MessageSystemModel {
cursor: jsons["cursor"],
type: jsons["type"],
title: jsons["title"],
content: json.decode(jsons["content"]),
content: isValidJson(jsons["content"])
? json.decode(jsons["content"])
: jsons["content"],
source: Source.fromJson(jsons["source"]),
timeAt: jsons["time_at"],
cardType: jsons["card_type"],
@ -75,3 +77,12 @@ class Source {
logo: json["logo"],
);
}
bool isValidJson(String str) {
try {
json.decode(str);
} catch (e) {
return false;
}
return true;
}

View File

@ -39,11 +39,11 @@ class ModelResult {
ModelResult.fromJson(Map<String, dynamic> json) {
resultType = json['result_type'];
summary = json['summary'];
outline = json['result_type'] == 2
? json['outline']
outline = json['result_type'] == 0
? <OutlineItem>[]
: json['outline']
.map<OutlineItem>((e) => OutlineItem.fromJson(e))
.toList()
: <OutlineItem>[];
.toList();
}
}