mod: 系统消息

This commit is contained in:
guozhigq
2024-09-28 23:16:00 +08:00
parent 7d5ce08bfc
commit 005c518b82
5 changed files with 78 additions and 14 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;
}