From 39890ee6a6d853fe7d6c28e29b0a9c17202e938b Mon Sep 17 00:00:00 2001 From: everpcpc Date: Sat, 4 Jul 2026 12:29:36 +0800 Subject: [PATCH] feat(settings): add logs action menu Move log sharing into an overflow menu and add a Clear All action that clears LogStore before refreshing the paginated list state. --- .../Features/Settings/SettingsLogsView.swift | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/KMReader/Features/Settings/SettingsLogsView.swift b/KMReader/Features/Settings/SettingsLogsView.swift index 2a556b08..4953834a 100644 --- a/KMReader/Features/Settings/SettingsLogsView.swift +++ b/KMReader/Features/Settings/SettingsLogsView.swift @@ -82,11 +82,25 @@ struct SettingsLogsView: View { .refreshable { await loadLogs() } - #if os(iOS) + #if os(iOS) || os(macOS) .toolbar { ToolbarItem(placement: .primaryAction) { - ShareLink(item: exportLogs()) { - Label(String(localized: "Share"), systemImage: "square.and.arrow.up") + Menu { + ShareLink(item: exportLogs()) { + Label(String(localized: "Share"), systemImage: "square.and.arrow.up") + } + + Divider() + + Button(role: .destructive) { + Task { + await clearLogs() + } + } label: { + Label(String(localized: "Clear All"), systemImage: "trash") + } + } label: { + Image(systemName: "ellipsis") } } } @@ -254,6 +268,11 @@ struct SettingsLogsView: View { pagination.items.map { formatEntry($0) }.joined(separator: "\n") } + private func clearLogs() async { + await LogStore.shared.clear() + await loadLogs() + } + private func formatEntry(_ entry: LogStore.LogEntry) -> String { let formatter = DateFormatter() formatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"