Improve performance for Logs

This commit is contained in:
世界
2025-11-26 22:25:51 +08:00
parent f6d14dbb8a
commit 32f5bf1f3b
4 changed files with 96 additions and 19 deletions
@@ -25,9 +25,21 @@ public class LogViewModel: ObservableObject {
private var lastEffectiveLevel: Int?
private var lastSearchText = ""
// Performance optimization: limit visible logs to prevent UI lag
private static let maxVisibleLogs = 1000
public var isEmpty: Bool { commandClient.logList.isEmpty }
public var isConnected: Bool { commandClient.isConnected }
// Only show last N logs for performance, but keep all in filteredLogs for export
public var visibleLogs: [LogEntry] {
if filteredLogs.count <= Self.maxVisibleLogs {
return filteredLogs
} else {
return Array(filteredLogs.suffix(Self.maxVisibleLogs))
}
}
public init(commandClient: CommandClient) {
self.commandClient = commandClient