fix parse opus

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-06-04 19:35:09 +08:00
parent 295a587df5
commit 038285cbe6
4 changed files with 38 additions and 25 deletions

View File

@@ -1,6 +1,8 @@
import 'package:PiliPlus/common/style.dart' as common_style;
import 'package:PiliPlus/models/dynamics/result.dart';
import 'package:PiliPlus/models/dynamics/vote_model.dart';
import 'package:PiliPlus/utils/color_utils.dart';
import 'package:PiliPlus/utils/parse_int.dart';
class ArticleContentModel {
int? align;
@@ -124,14 +126,14 @@ class Word {
Word.fromJson(Map<String, dynamic> json) {
words = json['words'];
fontSize = (json['font_size'] as num?)?.toDouble();
if (json['font_size'] case final num rawSize when rawSize != 0) {
fontSize = rawSize.toDouble();
}
style = json['style'] == null ? null : Style.fromJson(json['style']);
color = json['color'] == null
? null
: int.tryParse(
'FF${(json['color'] as String).substring(1)}',
radix: 16,
);
if (json['color'] case final String rawColor
when rawColor.startsWith('#')) {
color = ColourUtils.parse2Int(json['color']);
}
fontLevel = json['font_level'];
}
@@ -275,7 +277,7 @@ class Music {
Music.fromJson(Map<String, dynamic> json) {
cover = json['cover'];
id = json['id'];
id = safeToInt(json['id']);
jumpUrl = json['jump_url'];
label = json['label'];
title = json['title'];
@@ -291,12 +293,12 @@ class Opus {
int? statView;
Opus.fromJson(Map<String, dynamic> json) {
authorMid = json['author']?['mid'];
authorMid = safeToInt(json['author']?['mid']);
authorName = json['author']?['name'];
cover = json['cover'];
jumpUrl = json['jump_url'];
title = json['title'];
statView = json['stat']?['view'];
statView = safeToInt(json['stat']?['view']);
}
}
@@ -317,9 +319,9 @@ class Live {
descSecond = json['desc_second'];
title = json['title'];
jumpUrl = json['jump_url'];
id = json['id'];
liveState = json['live_state'];
reserveType = json['reserve_type'];
id = safeToInt(json['id']);
liveState = safeToInt(json['live_state']);
reserveType = safeToInt(json['reserve_type']);
badgeText = json['badge']?['text'];
}
}