80 lines
2.1 KiB
Dart
80 lines
2.1 KiB
Dart
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>? dx;
|
|
final Map<String, dynamic>? sd;
|
|
final Map<String, dynamic>? ut;
|
|
|
|
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.dx,
|
|
this.sd,
|
|
this.ut,
|
|
});
|
|
|
|
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'] ?? '',
|
|
dx: json['dx'],
|
|
sd: json['sd'],
|
|
ut: 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),
|
|
);
|
|
}
|
|
} |