去除print

This commit is contained in:
Developer
2026-03-30 03:04:36 +08:00
parent 99464d8fe6
commit 71e853587c
3 changed files with 47 additions and 81 deletions

View File

@@ -367,8 +367,6 @@ class _PopularPageState extends State<PopularPage>
} }
} }
} catch (e) { } catch (e) {
print('请求异常: $e');
print('异常类型: ${e.runtimeType}');
if (mounted) { if (mounted) {
setState(() { setState(() {
_errorMessage = '网络请求失败,请检查网络连接'; _errorMessage = '网络请求失败,请检查网络连接';

View File

@@ -81,9 +81,7 @@ class AutoRefreshManager {
} }
void _debugLog(String message) { void _debugLog(String message) {
if (kDebugMode) { if (kDebugMode) {}
print('AutoRefreshManager: $message');
}
} }
} }
@@ -182,9 +180,7 @@ class DebugInfoManager {
} }
void _debugLog(String message) { void _debugLog(String message) {
if (kDebugMode) { if (kDebugMode) {}
print('DebugInfoManager: $message');
}
} }
} }
@@ -330,8 +326,6 @@ class OfflineDataManager {
} }
void _debugLog(String message) { void _debugLog(String message) {
if (kDebugMode) { if (kDebugMode) {}
print('OfflineDataManager: $message');
}
} }
} }

View File

@@ -44,7 +44,7 @@ class _HistoryPageState extends State<HistoryPage> {
_isLoading = false; _isLoading = false;
}); });
} catch (e) { } catch (e) {
print('加载历史记录失败: $e'); // print('加载历史记录失败: $e');
setState(() { setState(() {
_isLoading = false; _isLoading = false;
}); });
@@ -74,7 +74,7 @@ class _HistoryPageState extends State<HistoryPage> {
_filteredHistoryList = searchResults; _filteredHistoryList = searchResults;
}); });
} catch (e) { } catch (e) {
print('搜索历史记录失败: $e'); // print('搜索历史记录失败: $e');
} }
} }
@@ -88,16 +88,17 @@ class _HistoryPageState extends State<HistoryPage> {
switch (sortType) { switch (sortType) {
case 0: // 时间倒序 case 0: // 时间倒序
sortedList.sort((a, b) => sortedList.sort(
(b['timestamp'] ?? 0).compareTo(a['timestamp'] ?? 0)); (a, b) => (b['timestamp'] ?? 0).compareTo(a['timestamp'] ?? 0),
);
break; break;
case 1: // 时间正序 case 1: // 时间正序
sortedList.sort((a, b) => sortedList.sort(
(a['timestamp'] ?? 0).compareTo(b['timestamp'] ?? 0)); (a, b) => (a['timestamp'] ?? 0).compareTo(b['timestamp'] ?? 0),
);
break; break;
case 2: // 按名称排序 case 2: // 按名称排序
sortedList.sort((a, b) => sortedList.sort((a, b) => (a['name'] ?? '').compareTo(b['name'] ?? ''));
(a['name'] ?? '').compareTo(b['name'] ?? ''));
break; break;
} }
@@ -129,17 +130,14 @@ class _HistoryPageState extends State<HistoryPage> {
_showSnackBar('清空失败'); _showSnackBar('清空失败');
} }
} catch (e) { } catch (e) {
print('清空历史记录失败: $e'); //('清空历史记录失败: $e');
_showSnackBar('清空失败'); _showSnackBar('清空失败');
} }
} }
// === 删除单条记录 === // === 删除单条记录 ===
Future<void> _deleteHistoryItem(int index, Map<String, dynamic> item) async { Future<void> _deleteHistoryItem(int index, Map<String, dynamic> item) async {
final confirmed = await _showConfirmDialog( final confirmed = await _showConfirmDialog('删除记录', '确定要删除这条历史记录吗?');
'删除记录',
'确定要删除这条历史记录吗?',
);
if (confirmed == null || !confirmed) return; if (confirmed == null || !confirmed) return;
@@ -223,7 +221,8 @@ class _HistoryPageState extends State<HistoryPage> {
Text('本月: ${stats['thisMonthCount']}'), Text('本月: ${stats['thisMonthCount']}'),
const SizedBox(height: 16), const SizedBox(height: 16),
const Text('热门朝代:'), const Text('热门朝代:'),
if (stats['topDynasties'] != null && stats['topDynasties'] is Map) ...[ if (stats['topDynasties'] != null &&
stats['topDynasties'] is Map) ...[
...(stats['topDynasties'] as Map<String, int>).entries ...(stats['topDynasties'] as Map<String, int>).entries
.map((entry) => Text('${entry.key}: ${entry.value}')) .map((entry) => Text('${entry.key}: ${entry.value}'))
.toList(), .toList(),
@@ -291,24 +290,15 @@ class _HistoryPageState extends State<HistoryPage> {
centerTitle: true, centerTitle: true,
actions: [ actions: [
IconButton( IconButton(
icon: Icon( icon: Icon(Icons.delete_sweep, color: AppConstants.primaryColor),
Icons.delete_sweep,
color: AppConstants.primaryColor,
),
onPressed: _historyList.isEmpty ? null : _clearHistory, onPressed: _historyList.isEmpty ? null : _clearHistory,
), ),
IconButton( IconButton(
icon: Icon( icon: Icon(Icons.bar_chart, color: AppConstants.primaryColor),
Icons.bar_chart,
color: AppConstants.primaryColor,
),
onPressed: _showStatsDialog, onPressed: _showStatsDialog,
), ),
IconButton( IconButton(
icon: Icon( icon: Icon(Icons.file_download, color: AppConstants.primaryColor),
Icons.file_download,
color: AppConstants.primaryColor,
),
onPressed: _exportHistory, onPressed: _exportHistory,
), ),
], ],
@@ -340,7 +330,10 @@ class _HistoryPageState extends State<HistoryPage> {
), ),
filled: true, filled: true,
fillColor: Colors.white, fillColor: Colors.white,
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), contentPadding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 12,
),
), ),
), ),
); );
@@ -394,10 +387,7 @@ class _HistoryPageState extends State<HistoryPage> {
SizedBox(height: 16), SizedBox(height: 16),
Text( Text(
'加载历史记录...', '加载历史记录...',
style: TextStyle( style: TextStyle(fontSize: 16, color: Colors.grey[600]!),
fontSize: 16,
color: Colors.grey[600]!,
),
), ),
], ],
), ),
@@ -410,18 +400,11 @@ class _HistoryPageState extends State<HistoryPage> {
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Icon( Icon(Icons.history, size: 64, color: Colors.grey[400]!),
Icons.history,
size: 64,
color: Colors.grey[400]!,
),
SizedBox(height: 16), SizedBox(height: 16),
Text( Text(
'暂无历史记录', '暂无历史记录',
style: TextStyle( style: TextStyle(fontSize: 16, color: Colors.grey[600]!),
fontSize: 16,
color: Colors.grey[600]!,
),
), ),
SizedBox(height: 16), SizedBox(height: 16),
ElevatedButton( ElevatedButton(
@@ -460,10 +443,7 @@ class _HistoryPageState extends State<HistoryPage> {
), ),
title: Text( title: Text(
item['name'] ?? '未知诗词', item['name'] ?? '未知诗词',
style: const TextStyle( style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
fontSize: 14,
fontWeight: FontWeight.w500,
),
maxLines: 2, maxLines: 2,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
@@ -472,18 +452,12 @@ class _HistoryPageState extends State<HistoryPage> {
children: [ children: [
Text( Text(
'${item['alias'] ?? '未知朝代'}${item['date'] ?? ''}', '${item['alias'] ?? '未知朝代'}${item['date'] ?? ''}',
style: const TextStyle( style: const TextStyle(fontSize: 12, color: Colors.grey),
fontSize: 12,
color: Colors.grey,
),
), ),
if (item['introduce']?.toString().isNotEmpty == true) if (item['introduce']?.toString().isNotEmpty == true)
Text( Text(
item['introduce']?.toString() ?? '', item['introduce']?.toString() ?? '',
style: TextStyle( style: TextStyle(fontSize: 11, color: Colors.grey[600]!),
fontSize: 11,
color: Colors.grey[600]!,
),
maxLines: 2, maxLines: 2,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),