refactor: 优化日志输出,仅在调试模式下启用

- 为所有 print 语句添加 kDebugMode 检查
- 更新 KRLogUtil 工具类,Release 模式下禁用日志输出
- 优化 18 个文件中的 335+ 条日志语句
- 提升 Release 版本性能并增强安全性

(cherry picked from commit 301f1510ba81fe94fb08e013ca80b3ca708a2e15)
This commit is contained in:
2025-11-01 05:15:34 -07:00
committed by speakeloudest
parent b3ee1cc6dc
commit 4c5763647d
18 changed files with 665 additions and 232 deletions
@@ -8,6 +8,7 @@ import 'package:kaer_with_panels/app/services/kr_site_config_service.dart';
import 'dart:async';
import '../../../services/kr_device_info_service.dart';
import 'package:flutter/foundation.dart';
/// Crisp 聊天控制器
class KRCrispController extends GetxController {
@@ -47,7 +48,9 @@ class KRCrispController extends GetxController {
kr_isInitialized.value = true;
}
} catch (e) {
print('初始化 Crisp 时出错: $e');
if (kDebugMode) {
print('初始化 Crisp 时出错: $e');
}
if (!_kr_isDisposed) {
kr_isInitialized.value = false;
}
@@ -125,9 +128,13 @@ class KRCrispController extends GetxController {
'device_id': deviceId,
});
print('Crisp 初始化完成');
if (kDebugMode) {
print('Crisp 初始化完成');
}
} catch (e) {
print('初始化 Crisp 时出错: $e');
if (kDebugMode) {
print('初始化 Crisp 时出错: $e');
}
crispController = null;
rethrow;
}
@@ -155,7 +162,9 @@ class KRCrispController extends GetxController {
kr_isLoading.value = false;
}
} catch (e) {
print('清理 Crisp 资源时出错: $e');
if (kDebugMode) {
print('清理 Crisp 资源时出错: $e');
}
}
}