mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: clear outdated logs
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -234,6 +234,7 @@ Commit Hash: ${BuildConfig.commitHash}''',
|
||||
onLongPress: clearLogs,
|
||||
leading: const Icon(Icons.bug_report_outlined),
|
||||
title: const Text('错误日志'),
|
||||
subtitle: Text('长按清除日志', style: subTitleStyle),
|
||||
trailing: Icon(Icons.arrow_forward, size: 16, color: outline),
|
||||
),
|
||||
ListTile(
|
||||
|
||||
@@ -15,6 +15,7 @@ class _LogsPageState extends State<LogsPage> {
|
||||
late File logsPath;
|
||||
late String fileContent;
|
||||
List logsContent = [];
|
||||
DateTime? latestLog;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -22,6 +23,16 @@ class _LogsPageState extends State<LogsPage> {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
if (latestLog != null) {
|
||||
if (DateTime.now().difference(latestLog!) >= Duration(days: 14)) {
|
||||
clearLogs();
|
||||
}
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void getPath() async {
|
||||
logsPath = await getLogsPath();
|
||||
fileContent = await logsPath.readAsString();
|
||||
@@ -53,6 +64,7 @@ class _LogsPageState extends State<LogsPage> {
|
||||
date = DateTime.parse(
|
||||
l.split("Crash occurred on")[1].trim(), //.split('.')[0],
|
||||
);
|
||||
latestLog ??= date;
|
||||
} catch (e) {
|
||||
debugPrint(e.toString());
|
||||
date = l.toString();
|
||||
|
||||
Reference in New Issue
Block a user