为 audioplayers_android 模块单独设置 Java 1.8,其他模块保持 Java 17
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../../constants/app_constants.dart';
|
||||
import '../../../utils/audio_manager.dart';
|
||||
import './widgets.dart';
|
||||
import '../../home/home-load.dart';
|
||||
import '../../../controllers/load/locally.dart';
|
||||
@@ -20,7 +21,7 @@ class AppFunSettingsPage extends StatefulWidget {
|
||||
class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
|
||||
bool _autoRefreshEnabled = false;
|
||||
bool _debugInfoEnabled = false;
|
||||
bool _soundEnabled = true;
|
||||
bool _soundEnabled = false; // 默认关闭
|
||||
bool _vibrationEnabled = true;
|
||||
bool _darkModeEnabled = false;
|
||||
bool _preloadEnabled = true;
|
||||
@@ -31,6 +32,7 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
|
||||
static const String _autoRefreshKey = 'auto_refresh_enabled';
|
||||
static const String _debugInfoKey = 'debug_info_enabled';
|
||||
static const String _globalTipsKey = 'global_tips_enabled'; // 添加全局Tips开关key
|
||||
static const String _soundEnabledKey = 'sound_enabled'; // 声音反馈开关key
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -47,6 +49,7 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
|
||||
_globalTipsEnabled =
|
||||
prefs.getBool(_globalTipsKey) ?? true; // 加载全局Tips开关状态
|
||||
_preloadEnabled = prefs.getBool('preload_enabled') ?? true;
|
||||
_soundEnabled = prefs.getBool(_soundEnabledKey) ?? false; // 加载声音反馈状态
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -82,13 +85,15 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
|
||||
}
|
||||
}
|
||||
|
||||
// 设置全局Tips开关
|
||||
Future<void> _setGlobalTips(bool value) async {
|
||||
// 设置声音反馈
|
||||
Future<void> _setSoundEnabled(bool value) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setBool(_globalTipsKey, value);
|
||||
await prefs.setBool(_soundEnabledKey, value);
|
||||
// 更新 AudioManager 的静音状态
|
||||
AudioManager().setMuted(!value);
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_globalTipsEnabled = value;
|
||||
_soundEnabled = value;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -159,14 +164,22 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
|
||||
'显示一些使用技巧',
|
||||
Icons.volume_up,
|
||||
_globalTipsEnabled,
|
||||
(value) => _setGlobalTips(value),
|
||||
(value) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setBool(_globalTipsKey, value);
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_globalTipsEnabled = value;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
_buildSwitchItem(
|
||||
'声音反馈',
|
||||
'操作时播放提示音',
|
||||
Icons.volume_up,
|
||||
_soundEnabled,
|
||||
(value) => setState(() => _soundEnabled = value),
|
||||
_setSoundEnabled,
|
||||
),
|
||||
_buildSwitchItem(
|
||||
'震动反馈',
|
||||
|
||||
@@ -173,16 +173,10 @@ class _OfflineDataPageState extends State<OfflineDataPage> {
|
||||
if (response.isSuccess && response.jsonData != null) {
|
||||
final responseData = response.jsonData;
|
||||
|
||||
print('API完整响应: $responseData');
|
||||
|
||||
// 检查API返回格式
|
||||
if (responseData['code'] == 0 && responseData['data'] != null) {
|
||||
final itemData = responseData['data'] as Map<String, dynamic>;
|
||||
|
||||
print('API返回的data字段: $itemData');
|
||||
print('API返回的options字段: ${itemData['options']}');
|
||||
print('options字段类型: ${itemData['options']?.runtimeType}');
|
||||
|
||||
// 对于答题数据,确保options字段被正确序列化
|
||||
if (_selectedType == DownloadType.quiz) {
|
||||
// 深拷贝数据,避免修改原始数据
|
||||
@@ -194,22 +188,16 @@ class _OfflineDataPageState extends State<OfflineDataPage> {
|
||||
if (dataToStore['options'] is List) {
|
||||
// 将List转换为JSON字符串
|
||||
dataToStore['options'] = jsonEncode(dataToStore['options']);
|
||||
print('存储答题数据options: ${dataToStore['options']}');
|
||||
} else if (dataToStore['options'] is String) {
|
||||
// 已经是字符串,直接使用
|
||||
print('options已经是字符串,直接使用: ${dataToStore['options']}');
|
||||
} else {
|
||||
print('options类型异常: ${dataToStore['options'].runtimeType}');
|
||||
}
|
||||
} else {
|
||||
print('警告:options字段不存在或为null');
|
||||
// 如果没有options,添加一个空数组
|
||||
dataToStore['options'] = jsonEncode([]);
|
||||
}
|
||||
|
||||
// 将整个Map转换为JSON字符串存储
|
||||
final storedString = jsonEncode(dataToStore);
|
||||
print('存储答题数据完整: $storedString');
|
||||
currentData.add(storedString);
|
||||
} else {
|
||||
currentData.add(itemData.toString());
|
||||
@@ -231,8 +219,6 @@ class _OfflineDataPageState extends State<OfflineDataPage> {
|
||||
_cachedCount = currentData.length;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
print('API返回错误: ${responseData['msg'] ?? '未知错误'}');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user