diff --git a/lib/main.dart b/lib/main.dart index 89955b6a..7097f320 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -68,45 +68,50 @@ void main() async { Request(); await Request.setCookie(); RecommendFilter(); - // 异常捕获 logo记录 - const String buildConfig = '''\n + + if (GStorage.enableLog) { + // 异常捕获 logo记录 + const String buildConfig = '''\n Build Time: ${BuildConfig.buildTime} Commit Hash: ${BuildConfig.commitHash}'''; - final Catcher2Options debugConfig = Catcher2Options( - SilentReportMode(), - [ - FileHandler(await getLogsPath()), - ConsoleHandler( - enableDeviceParameters: false, - enableApplicationParameters: false, - enableCustomParameters: true, - ) - ], - customParameters: { - 'BuildConfig': buildConfig, - }, - ); + final Catcher2Options debugConfig = Catcher2Options( + SilentReportMode(), + [ + FileHandler(await getLogsPath()), + ConsoleHandler( + enableDeviceParameters: false, + enableApplicationParameters: false, + enableCustomParameters: true, + ) + ], + customParameters: { + 'BuildConfig': buildConfig, + }, + ); - final Catcher2Options releaseConfig = Catcher2Options( - SilentReportMode(), - [ - FileHandler(await getLogsPath()), - ConsoleHandler( - enableCustomParameters: true, - ) - ], - customParameters: { - 'BuildConfig': buildConfig, - }, - ); + final Catcher2Options releaseConfig = Catcher2Options( + SilentReportMode(), + [ + FileHandler(await getLogsPath()), + ConsoleHandler( + enableCustomParameters: true, + ) + ], + customParameters: { + 'BuildConfig': buildConfig, + }, + ); - Catcher2( - debugConfig: debugConfig, - releaseConfig: releaseConfig, - runAppFunction: () { - runApp(const MyApp()); - }, - ); + Catcher2( + debugConfig: debugConfig, + releaseConfig: releaseConfig, + runAppFunction: () { + runApp(const MyApp()); + }, + ); + } else { + runApp(const MyApp()); + } // 小白条、导航栏沉浸 SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); diff --git a/lib/pages/setting/pages/logs.dart b/lib/pages/setting/pages/logs.dart index f2ffe4bc..60f1bf5a 100644 --- a/lib/pages/setting/pages/logs.dart +++ b/lib/pages/setting/pages/logs.dart @@ -3,9 +3,11 @@ import 'dart:io'; import 'package:PiliPlus/common/widgets/loading_widget/loading_widget.dart'; import 'package:PiliPlus/services/loggeer.dart'; import 'package:PiliPlus/utils/page_utils.dart'; +import 'package:PiliPlus/utils/storage.dart'; import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/foundation.dart' show kDebugMode; import 'package:flutter/material.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; class LogsPage extends StatefulWidget { const LogsPage({super.key}); @@ -19,6 +21,7 @@ class _LogsPageState extends State { late String fileContent; List logsContent = []; DateTime? latestLog; + late bool enableLog = GStorage.enableLog; @override void initState() { @@ -114,6 +117,11 @@ class _LogsPageState extends State { PopupMenuButton( onSelected: (String type) { switch (type) { + case 'log': + enableLog = !enableLog; + GStorage.setting.put(SettingBoxKey.enableLog, enableLog); + SmartDialog.showToast('已${enableLog ? '开启' : '关闭'},重启生效'); + break; case 'copy': copyLogs(); break; @@ -128,6 +136,10 @@ class _LogsPageState extends State { } }, itemBuilder: (BuildContext context) => >[ + PopupMenuItem( + value: 'log', + child: Text('${enableLog ? '关闭' : '开启'}日志'), + ), const PopupMenuItem( value: 'copy', child: Text('复制日志'), diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index 5837146e..ee373bd6 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -497,6 +497,9 @@ class GStorage { static String get banWordForDyn => GStorage.setting.get(SettingBoxKey.banWordForDyn, defaultValue: ''); + static bool get enableLog => + setting.get(SettingBoxKey.enableLog, defaultValue: true); + static List get dynamicDetailRatio => List.from(setting .get(SettingBoxKey.dynamicDetailRatio, defaultValue: const [60.0, 40.0])); @@ -794,6 +797,7 @@ class SettingBoxKey { pageTransition = 'pageTransition', optTabletNav = 'optTabletNav', banWordForDyn = 'banWordForDyn', + enableLog = 'enableLog', // WebDAV webdavUri = 'webdavUri',