0418 0222

更新2
This commit is contained in:
spasolreisa
2026-04-18 02:11:45 +08:00
parent fed18d264a
commit 00bd43dc7f
7 changed files with 1805 additions and 24 deletions

View File

@@ -1,5 +1,6 @@
import 'dart:convert';
import 'package:dio/dio.dart';
import '../model/song_model.dart';
import '../model/user_model.dart';
import '../tool/encryption_util.dart';
@@ -307,4 +308,33 @@ class UserService {
throw _getErrorMessage(e);
}
}
static Future<List<ChartLogModel>> getChartLog(String token, List<int> musicIds) async {
try {
print("getChartLog");
// 构建查询参数
// 如果 API 期望的是逗号分隔的字符串 "11434,11435"
final String idsParam = musicIds.map((e) => e.toString()).join(',');
final res = await _dio.get(
'$baseUrl/api/union/chartlog',
queryParameters: {
"musicId": idsParam,
},
options: Options(headers: {"Authorization": token}),
);
// 检查返回数据是否为 List
if (res.data is List) {
return (res.data as List)
.map((item) => ChartLogModel.fromJson(item as Map<String, dynamic>))
.toList();
}
// 如果后端在某些错误情况下返回 Map 而不是 List这里返回空列表或抛出异常
return [];
} on DioException catch (e) {
throw _getErrorMessage(e);
}
}
}