class SongModel { final int id; final String title; final String artist; final Map? utTitle; // 可选,根据不同版本标题可能不同 final List 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? dxLevels; final Map? sdLevels; final Map? 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 json) { return SongModel( id: json['id'] ?? 0, title: json['title'] ?? 'Unknown', artist: json['artist'] ?? 'Unknown', utTitle: json['utTitle'], albums: List.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 toJson() => { 'songSize': songSize, 'version': version, 'lastUpdate': lastUpdate.millisecondsSinceEpoch, }; factory SongCacheInfo.fromJson(Map json) { return SongCacheInfo( songSize: json['songSize'] ?? 0, version: json['version'] ?? '', lastUpdate: DateTime.fromMillisecondsSinceEpoch(json['lastUpdate'] ?? 0), ); } }