Refactor Dashboard traffic cards with line charts

This commit is contained in:
世界
2025-12-06 21:19:37 +08:00
parent 52efbd97d2
commit 0e206cc452
17 changed files with 299 additions and 93 deletions
+9
View File
@@ -67,6 +67,9 @@ public class CommandClient: ObservableObject {
@Published public var hasAnyConnection: Bool = false
public var rawConnections: LibboxConnections?
@Published public var uplinkHistory: [CGFloat] = Array(repeating: 0, count: 30)
@Published public var downlinkHistory: [CGFloat] = Array(repeating: 0, count: 30)
// Batch processing for logs
private var pendingLogs: [LogEntry] = []
private var logBatchTimer: DispatchWorkItem?
@@ -270,6 +273,12 @@ public class CommandClient: ObservableObject {
func writeStatus(_ message: LibboxStatusMessage?) {
DispatchQueue.main.async { [self] in
commandClient.status = message
if let message = message, message.trafficAvailable {
commandClient.uplinkHistory.removeFirst()
commandClient.uplinkHistory.append(CGFloat(message.uplink))
commandClient.downlinkHistory.removeFirst()
commandClient.downlinkHistory.append(CGFloat(message.downlink))
}
}
}