This commit is contained in:
sjk
2025-11-17 13:39:05 +08:00
commit d4cfe2b9de
479 changed files with 109324 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
/// 学习进度模型
class LearningProgress {
final String id;
final String title;
final String category;
final int totalWords;
final int learnedWords;
final double progress;
final DateTime? lastStudyDate;
LearningProgress({
required this.id,
required this.title,
required this.category,
required this.totalWords,
required this.learnedWords,
required this.progress,
this.lastStudyDate,
});
factory LearningProgress.fromJson(Map<String, dynamic> json) {
return LearningProgress(
id: json['id'] as String? ?? '',
title: json['title'] as String? ?? '',
category: json['category'] as String? ?? '',
totalWords: json['total_words'] as int? ?? 0,
learnedWords: json['learned_words'] as int? ?? 0,
progress: (json['progress'] as num?)?.toDouble() ?? 0.0,
lastStudyDate: json['last_study_date'] != null
? DateTime.tryParse(json['last_study_date'] as String)
: null,
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'title': title,
'category': category,
'total_words': totalWords,
'learned_words': learnedWords,
'progress': progress,
'last_study_date': lastStudyDate?.toIso8601String(),
};
}
String get progressPercentage => '${(progress * 100).toInt()}%';
}