initial
This commit is contained in:
80
lib/model/song_model.dart
Normal file
80
lib/model/song_model.dart
Normal file
@@ -0,0 +1,80 @@
|
||||
class SongModel {
|
||||
final int id;
|
||||
final String title;
|
||||
final String artist;
|
||||
final Map<String, dynamic>? utTitle; // 可选,根据不同版本标题可能不同
|
||||
final List<String> albums;
|
||||
final bool hasDx;
|
||||
final bool hasSd;
|
||||
final bool hasUt;
|
||||
final String genre;
|
||||
final int bpm;
|
||||
final String releaseDate;
|
||||
final String from;
|
||||
|
||||
// 难度详情映射 key通常是 "0"(Basic), "1"(Advanced) 等,或者 ut 的特殊id
|
||||
final Map<String, dynamic>? dxLevels;
|
||||
final Map<String, dynamic>? sdLevels;
|
||||
final Map<String, dynamic>? utLevels;
|
||||
|
||||
SongModel({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.artist,
|
||||
this.utTitle,
|
||||
required this.albums,
|
||||
required this.hasDx,
|
||||
required this.hasSd,
|
||||
required this.hasUt,
|
||||
required this.genre,
|
||||
required this.bpm,
|
||||
required this.releaseDate,
|
||||
required this.from,
|
||||
this.dxLevels,
|
||||
this.sdLevels,
|
||||
this.utLevels,
|
||||
});
|
||||
|
||||
factory SongModel.fromJson(Map<String, dynamic> json) {
|
||||
return SongModel(
|
||||
id: json['id'] ?? 0,
|
||||
title: json['title'] ?? 'Unknown',
|
||||
artist: json['artist'] ?? 'Unknown',
|
||||
utTitle: json['utTitle'],
|
||||
albums: List<String>.from(json['albums'] ?? []),
|
||||
hasDx: json['hasDx'] ?? false,
|
||||
hasSd: json['hasSd'] ?? false,
|
||||
hasUt: json['hasUt'] ?? false,
|
||||
genre: json['genre'] ?? '',
|
||||
bpm: json['bpm'] ?? 0,
|
||||
releaseDate: json['releaseDate'] ?? '',
|
||||
from: json['from'] ?? '',
|
||||
dxLevels: json['dx'],
|
||||
sdLevels: json['sd'],
|
||||
utLevels: json['ut'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 用于存储本地缓存的版本信息
|
||||
class SongCacheInfo {
|
||||
final int songSize;
|
||||
final String version;
|
||||
final DateTime lastUpdate;
|
||||
|
||||
SongCacheInfo({required this.songSize, required this.version, required this.lastUpdate});
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'songSize': songSize,
|
||||
'version': version,
|
||||
'lastUpdate': lastUpdate.millisecondsSinceEpoch,
|
||||
};
|
||||
|
||||
factory SongCacheInfo.fromJson(Map<String, dynamic> json) {
|
||||
return SongCacheInfo(
|
||||
songSize: json['songSize'] ?? 0,
|
||||
version: json['version'] ?? '',
|
||||
lastUpdate: DateTime.fromMillisecondsSinceEpoch(json['lastUpdate'] ?? 0),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user