mod: 系统消息
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user