mirror of
https://github.com/yJason/ClashX-Dashboard.git
synced 2026-02-04 10:02:26 +08:00
feat: memory overview item
This commit is contained in:
@@ -41,6 +41,15 @@ extension ClashApiDatasStorage: ApiRequestStreamDelegate {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func didUpdateMemory(memory: Int64) {
|
||||
let v = ByteCountFormatter().string(fromByteCount: memory)
|
||||
|
||||
if overviewData.memory != v {
|
||||
overviewData.memory = v
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fileprivate let TrafficHistoryLimit = 120
|
||||
@@ -56,6 +65,8 @@ class ClashOverviewData: ObservableObject, Identifiable {
|
||||
|
||||
@Published var activeConns = "0"
|
||||
|
||||
@Published var memory = "0 MB"
|
||||
|
||||
@Published var downloadHistories = [CGFloat](repeating: 0, count: TrafficHistoryLimit)
|
||||
@Published var uploadHistories = [CGFloat](repeating: 0, count: TrafficHistoryLimit)
|
||||
|
||||
|
||||
@@ -15,13 +15,21 @@ struct OverviewView: View {
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 25) {
|
||||
HStack() {
|
||||
|
||||
|
||||
|
||||
LazyVGrid(columns: Array(repeating: GridItem(.flexible(minimum: 155)), count: 4)) {
|
||||
|
||||
OverviewTopItemView(name: "Upload", value: $data.uploadString)
|
||||
OverviewTopItemView(name: "Download", value: $data.downloadString)
|
||||
OverviewTopItemView(name: "Upload Total", value: $data.uploadTotal)
|
||||
OverviewTopItemView(name: "Download Total", value: $data.downloadTotal)
|
||||
|
||||
OverviewTopItemView(name: "Active Connections", value: $data.activeConns)
|
||||
OverviewTopItemView(name: "Memory Usage", value: $data.memory)
|
||||
}
|
||||
|
||||
|
||||
|
||||
HStack {
|
||||
RoundedRectangle(cornerRadius: 2)
|
||||
|
||||
Reference in New Issue
Block a user