为 audioplayers_android 模块单独设置 Java 1.8,其他模块保持 Java 17
This commit is contained in:
@@ -58,7 +58,6 @@ class _DistinguishPageState extends State<DistinguishPage> {
|
||||
try {
|
||||
return jsonDecode(record) as Map<String, dynamic>;
|
||||
} catch (e) {
|
||||
print('解析记录失败: $e');
|
||||
return <String, dynamic>{};
|
||||
}
|
||||
})
|
||||
@@ -75,7 +74,7 @@ class _DistinguishPageState extends State<DistinguishPage> {
|
||||
// 加载统计数据
|
||||
await _loadStatistics();
|
||||
} catch (e) {
|
||||
print('加载答题记录失败: $e');
|
||||
// 加载失败
|
||||
} finally {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
@@ -121,7 +120,7 @@ class _DistinguishPageState extends State<DistinguishPage> {
|
||||
// 计算诗词水平
|
||||
_calculatePoetryLevel();
|
||||
} catch (e) {
|
||||
print('加载统计数据失败: $e');
|
||||
// 加载失败
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,7 +461,7 @@ $_poetryLevel
|
||||
context,
|
||||
).showSnackBar(const SnackBar(content: Text('答题记录已清空')));
|
||||
} catch (e) {
|
||||
print('清空记录失败: $e');
|
||||
// 清空失败
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class PoetryLevelManager with NetworkListenerMixin {
|
||||
_offlineQuestions.add(map);
|
||||
}
|
||||
} catch (e) {
|
||||
print('解析离线数据失败: $e');
|
||||
// 解析失败,跳过
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ class PoetryLevelManager with NetworkListenerMixin {
|
||||
_currentIndex = 0;
|
||||
}
|
||||
} catch (e) {
|
||||
print('加载离线缓存失败: $e');
|
||||
// 加载失败
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,17 +103,13 @@ class PoetryLevelManager with NetworkListenerMixin {
|
||||
Map<String, dynamic> _parseStringToMap(String str) {
|
||||
final result = <String, dynamic>{};
|
||||
|
||||
print('开始解析字符串: $str');
|
||||
|
||||
try {
|
||||
// 尝试JSON解析
|
||||
final jsonMap = jsonDecode(str);
|
||||
if (jsonMap is Map<String, dynamic>) {
|
||||
print('JSON解析成功: $jsonMap');
|
||||
return jsonMap;
|
||||
}
|
||||
} catch (e) {
|
||||
print('JSON解析失败: $e');
|
||||
// 不是JSON格式,尝试其他解析方式
|
||||
}
|
||||
|
||||
@@ -144,7 +140,6 @@ class PoetryLevelManager with NetworkListenerMixin {
|
||||
}
|
||||
}
|
||||
|
||||
print('解析结果: $result');
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -226,8 +221,6 @@ class PoetryLevelManager with NetworkListenerMixin {
|
||||
isOffline: false,
|
||||
);
|
||||
} catch (e) {
|
||||
print('初始化题目失败: $e');
|
||||
|
||||
// 尝试加载离线缓存
|
||||
final hasCache = await _hasCachedData();
|
||||
if (hasCache) {
|
||||
@@ -363,15 +356,11 @@ class PoetryLevelManager with NetworkListenerMixin {
|
||||
|
||||
/// 格式化离线题目数据
|
||||
Map<String, dynamic> _formatOfflineQuestion(Map<String, dynamic> data) {
|
||||
print('格式化离线题目,原始数据: $data');
|
||||
|
||||
// 检查是否已经是标准格式
|
||||
if (data.containsKey('question') && data.containsKey('options')) {
|
||||
final options = data['options'];
|
||||
print('发现options字段,类型: ${options.runtimeType}, 值: $options');
|
||||
// 确保options是List类型
|
||||
if (options is List) {
|
||||
print('options已经是List类型,直接返回');
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -387,49 +376,37 @@ class PoetryLevelManager with NetworkListenerMixin {
|
||||
'options': <Map<String, dynamic>>[],
|
||||
};
|
||||
|
||||
print('构建基础数据: $result');
|
||||
|
||||
// 尝试解析options字段
|
||||
dynamic optionsData = data['options'];
|
||||
if (optionsData != null) {
|
||||
print('开始解析options,类型: ${optionsData.runtimeType}');
|
||||
if (optionsData is List) {
|
||||
// 已经是List,直接使用
|
||||
result['options'] = optionsData;
|
||||
print('options是List,直接使用');
|
||||
} else if (optionsData is String) {
|
||||
// 是String,尝试解析为List
|
||||
try {
|
||||
print('options是String,尝试解析: $optionsData');
|
||||
final parsedOptions = jsonDecode(optionsData);
|
||||
print('解析结果类型: ${parsedOptions.runtimeType}');
|
||||
if (parsedOptions is List) {
|
||||
result['options'] = parsedOptions;
|
||||
print('options解析成功为List');
|
||||
}
|
||||
} catch (e) {
|
||||
print('解析options字符串失败: $e');
|
||||
// 解析失败
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print('当前options: ${result['options']}');
|
||||
|
||||
// 如果没有有效的options,尝试从其他字段构建
|
||||
if ((result['options'] as List).isEmpty) {
|
||||
print('options为空,尝试从其他字段构建');
|
||||
final options = <Map<String, dynamic>>[];
|
||||
for (int i = 1; i <= 4; i++) {
|
||||
final optionKey = 'option_$i';
|
||||
if (data.containsKey(optionKey)) {
|
||||
options.add({'index': i, 'content': data[optionKey]});
|
||||
print('从$optionKey构建选项');
|
||||
}
|
||||
}
|
||||
result['options'] = options;
|
||||
}
|
||||
|
||||
print('最终格式化结果: $result');
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -375,7 +375,7 @@ class _PoetryLevelPageState extends State<PoetryLevelPage>
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
print('保存答题记录失败: $e');
|
||||
// 保存失败
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user