为 audioplayers_android 模块单独设置 Java 1.8,其他模块保持 Java 17
This commit is contained in:
@@ -26,13 +26,6 @@ class HttpClient {
|
||||
|
||||
static final Dio _dio = Dio(_options);
|
||||
|
||||
/// 添加调试日志
|
||||
static void _debugLog(String message) {
|
||||
if (kDebugMode) {
|
||||
print('HttpClient: $message');
|
||||
}
|
||||
}
|
||||
|
||||
/// GET请求
|
||||
static Future<HttpResponse> get(
|
||||
String path, {
|
||||
@@ -92,10 +85,6 @@ class HttpClient {
|
||||
}) async {
|
||||
try {
|
||||
final url = '$_baseUrl$path';
|
||||
_debugLog('请求 $method $url');
|
||||
if (queryParameters != null) {
|
||||
_debugLog('查询参数: $queryParameters');
|
||||
}
|
||||
|
||||
final options = Options(
|
||||
method: method,
|
||||
@@ -129,9 +118,6 @@ class HttpClient {
|
||||
throw UnsupportedError('HTTP method $method is not supported');
|
||||
}
|
||||
|
||||
_debugLog('响应状态: ${response.statusCode}');
|
||||
_debugLog('响应数据: ${response.data}');
|
||||
|
||||
return HttpResponse(
|
||||
statusCode: response.statusCode ?? 0,
|
||||
body: response.data is String
|
||||
@@ -140,7 +126,6 @@ class HttpClient {
|
||||
headers: response.headers.map.cast<String, String>(),
|
||||
);
|
||||
} on DioException catch (e) {
|
||||
_debugLog('Dio异常: ${e.type} - ${e.message}');
|
||||
String message;
|
||||
switch (e.type) {
|
||||
case DioExceptionType.connectionTimeout:
|
||||
@@ -159,7 +144,6 @@ class HttpClient {
|
||||
}
|
||||
throw HttpException(message);
|
||||
} catch (e) {
|
||||
_debugLog('未知异常: $e');
|
||||
throw HttpException('请求失败:$e');
|
||||
}
|
||||
}
|
||||
@@ -175,13 +159,6 @@ class HttpClient {
|
||||
}) async {
|
||||
try {
|
||||
final url = '$_baseUrl$path';
|
||||
_debugLog('FormData请求 $method $url');
|
||||
if (queryParameters != null) {
|
||||
_debugLog('查询参数: $queryParameters');
|
||||
}
|
||||
if (data != null) {
|
||||
_debugLog('表单数据: $data');
|
||||
}
|
||||
|
||||
final formData = FormData.fromMap(data ?? {});
|
||||
|
||||
@@ -213,9 +190,6 @@ class HttpClient {
|
||||
throw UnsupportedError('FormData only supports POST method');
|
||||
}
|
||||
|
||||
_debugLog('响应状态: ${response.statusCode}');
|
||||
_debugLog('响应数据: ${response.data}');
|
||||
|
||||
return HttpResponse(
|
||||
statusCode: response.statusCode ?? 0,
|
||||
body: response.data is String
|
||||
@@ -224,7 +198,6 @@ class HttpClient {
|
||||
headers: response.headers.map.cast<String, String>(),
|
||||
);
|
||||
} on DioException catch (e) {
|
||||
_debugLog('Dio异常: ${e.type} - ${e.message}');
|
||||
String message;
|
||||
switch (e.type) {
|
||||
case DioExceptionType.connectionTimeout:
|
||||
@@ -243,7 +216,6 @@ class HttpClient {
|
||||
}
|
||||
throw HttpException(message);
|
||||
} catch (e) {
|
||||
_debugLog('未知异常: $e');
|
||||
throw HttpException('请求失败:$e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,11 +269,6 @@ class PoetryData {
|
||||
});
|
||||
|
||||
factory PoetryData.fromJson(Map<String, dynamic> json) {
|
||||
// 添加调试信息
|
||||
if (kDebugMode) {
|
||||
print('PoetryData.fromJson: 输入JSON = $json');
|
||||
}
|
||||
|
||||
try {
|
||||
final poetryData = PoetryData(
|
||||
id: int.tryParse(json['id'].toString()) ?? 0,
|
||||
@@ -295,16 +290,9 @@ class PoetryData {
|
||||
createTime: json['create_time']?.toString() ?? '',
|
||||
updateTime: json['update_time']?.toString() ?? '',
|
||||
);
|
||||
|
||||
if (kDebugMode) {
|
||||
print('PoetryData.fromJson: 解析成功');
|
||||
}
|
||||
|
||||
|
||||
return poetryData;
|
||||
} catch (e) {
|
||||
if (kDebugMode) {
|
||||
print('PoetryData.fromJson: 解析失败 - $e');
|
||||
}
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,32 +34,19 @@ class VoteApi {
|
||||
static final Dio _dio = Dio(_options)
|
||||
..interceptors.add(CookieManager(_cookieJar));
|
||||
|
||||
static void _debugLog(String message) {
|
||||
if (kDebugMode) {
|
||||
print('VoteApi: $message');
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> _get(
|
||||
String path, {
|
||||
Map<String, dynamic>? queryParameters,
|
||||
}) async {
|
||||
try {
|
||||
final url = '$_baseUrl$path';
|
||||
_debugLog('GET $url');
|
||||
if (queryParameters != null) {
|
||||
_debugLog('查询参数: $queryParameters');
|
||||
}
|
||||
|
||||
final response = await _dio.get(url, queryParameters: queryParameters);
|
||||
|
||||
_debugLog('响应: ${response.data}');
|
||||
return response.data as Map<String, dynamic>;
|
||||
} on DioException catch (e) {
|
||||
_debugLog('Dio异常: ${e.type} - ${e.message}');
|
||||
throw Exception('请求失败: ${e.message}');
|
||||
} catch (e) {
|
||||
_debugLog('未知异常: $e');
|
||||
throw Exception('请求失败: $e');
|
||||
}
|
||||
}
|
||||
@@ -70,20 +57,13 @@ class VoteApi {
|
||||
}) async {
|
||||
try {
|
||||
final url = '$_baseUrl$path';
|
||||
_debugLog('POST $url');
|
||||
if (data != null) {
|
||||
_debugLog('请求数据: $data');
|
||||
}
|
||||
|
||||
final response = await _dio.post(url, data: data);
|
||||
|
||||
_debugLog('响应: ${response.data}');
|
||||
return response.data as Map<String, dynamic>;
|
||||
} on DioException catch (e) {
|
||||
_debugLog('Dio异常: ${e.type} - ${e.message}');
|
||||
throw Exception('请求失败: ${e.message}');
|
||||
} catch (e) {
|
||||
_debugLog('未知异常: $e');
|
||||
throw Exception('请求失败: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user