fix(ui): 缩小卡片并还原设计稿紧凑排布

This commit is contained in:
2026-11-15 17:14:42 +08:00
parent 3c1a2baace
commit d87aa3ccc5
29 changed files with 609 additions and 272 deletions
@@ -15,21 +15,21 @@ extension MenuPanelView {
).id(selectedInterface)
}
) {
HStack(spacing: 12) {
networkTotal(
"network.received", value: network.isEmpty ? "--" : MetricFormat.bytes(network.reduce(0) { $0 + $1.received }),
symbol: "arrow.down", color: Color("MetricMemory"))
networkTotal(
"network.sent", value: network.isEmpty ? "--" : MetricFormat.bytes(network.reduce(0) { $0 + $1.sent }),
symbol: "arrow.up", color: Color("SeriesUpload"))
}
VStack(spacing: 4) {
HStack(spacing: 3) {
Text("network.totalShort").foregroundStyle(.secondary)
Image(systemName: "arrow.down").foregroundStyle(Color("MetricMemory"))
MetricText(value: network.isEmpty ? "--" : MetricFormat.bytes(network.reduce(0) { $0 + $1.received }))
Text("·").foregroundStyle(.secondary)
Image(systemName: "arrow.up").foregroundStyle(Color("SeriesUpload"))
MetricText(value: network.isEmpty ? "--" : MetricFormat.bytes(network.reduce(0) { $0 + $1.sent }))
}.font(.system(size: 8)).lineLimit(1).minimumScaleFactor(0.75)
VStack(spacing: 3) {
networkAddress("network.public", address: publicIPAddress)
networkAddress(
"network.local",
address: addressInterface?.addresses.first(where: { !$0.contains(":") }) ?? addressInterface?.addresses.first)
}
.font(PanelStyle.label)
.font(.system(size: 9))
.accessibilityElement(children: .contain)
.accessibilityLabel(Text("network.addresses"))
}
@@ -44,7 +44,7 @@ extension MenuPanelView {
ForEach(snapshot.network ?? [], id: \.identity) { item in
Text(verbatim: item.name).tag(item.identity)
}
}.labelsHidden().controlSize(.mini).frame(maxWidth: 100)
}.labelsHidden().controlSize(.mini).fixedSize().frame(maxWidth: 70)
}
.help(Text(networkStatusLabel))
.accessibilityElement(children: .contain)
@@ -54,7 +54,7 @@ extension MenuPanelView {
func networkAddress(_ title: LocalizedStringKey, address: String?) -> some View {
HStack(spacing: 3) {
Text(title).foregroundStyle(.secondary)
Text(verbatim: address ?? "--").font(PanelStyle.value).monospacedDigit().textSelection(.enabled)
Text(verbatim: address ?? "--").font(.system(size: 9, weight: .medium)).monospacedDigit().textSelection(.enabled)
.help(Text(verbatim: address ?? "--"))
.frame(maxWidth: .infinity, alignment: .leading)
if let address {
@@ -62,21 +62,12 @@ extension MenuPanelView {
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(address, forType: .string)
} label: {
Image(systemName: "doc.on.doc")
Image(systemName: "doc.on.doc").frame(width: 14, height: 14)
}
.buttonStyle(.plain).accessibilityLabel(Text("panel.copy"))
}
}.frame(maxWidth: .infinity, alignment: .leading).lineLimit(1)
}
func networkTotal(_ title: LocalizedStringKey, value: String, symbol: String, color: Color) -> some View {
CardField(title: title) {
HStack(spacing: 3) {
Image(systemName: symbol).foregroundStyle(color)
MetricText(value: value)
}
}
}
var networkStatusLabel: LocalizedStringKey {
switch snapshot.networkPath {
case .available: "network.pathAvailable"