fix network
This commit is contained in:
parent
dee3e26c33
commit
906456a543
@ -242,21 +242,47 @@ struct NetworkDeviceGroupView: View {
|
||||
@Environment(AppContext.self) private var appContext: AppContext
|
||||
@State private var selectedId: Int?
|
||||
|
||||
// 侧边栏宽度
|
||||
private let sidebarWidth: CGFloat = 240
|
||||
|
||||
var body: some View {
|
||||
NavigationSplitView {
|
||||
List(appContext.networkContext.nodeList, id: \.id, selection: $selectedId) { node in
|
||||
NetworkNodeHeadView(node: node)
|
||||
.tag(node.id)
|
||||
HStack(spacing: 0) {
|
||||
// --- 1. 自定义侧边栏 (Sidebar) ---
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
// 顶部留白:避开 macOS 窗口左上角的红绿灯按钮
|
||||
// 如果你的 WindowStyle 是 .hiddenTitleBar,这个 Padding 非常重要
|
||||
Color.clear.frame(height: 28)
|
||||
|
||||
List(appContext.networkContext.nodeList, id: \.id, selection: $selectedId) { node in
|
||||
NetworkNodeHeadView(node: node)
|
||||
// 技巧:在 HStack 方案中,tag 配合 List 的 selection 依然有效
|
||||
.tag(node.id)
|
||||
.listRowSeparator(.hidden)
|
||||
}
|
||||
.listStyle(.inset) // 使用 inset 样式在自定义侧边栏中更美观
|
||||
.scrollContentBackground(.hidden) // 隐藏默认白色背景,显示下方的磨砂材质
|
||||
}
|
||||
.listStyle(.sidebar)
|
||||
.navigationSplitViewColumnWidth(min: 200, ideal: 220)
|
||||
} detail: {
|
||||
if let selectedNode = appContext.networkContext.getNode(id: selectedId) {
|
||||
NetworkNodeDetailView(node: selectedNode)
|
||||
} else {
|
||||
ContentUnavailableView("选择成员设备", systemImage: "macbook.and.iphone", description: Text("查看详细网络信息和服务"))
|
||||
.frame(width: sidebarWidth)
|
||||
|
||||
Divider() // 分割线
|
||||
|
||||
// --- 2. 详情区域 (Detail) ---
|
||||
ZStack {
|
||||
if let selectedNode = appContext.networkContext.getNode(id: selectedId) {
|
||||
NetworkNodeDetailView(node: selectedNode)
|
||||
.transition(.opacity.animation(.easeInOut(duration: 0.2)))
|
||||
} else {
|
||||
ContentUnavailableView(
|
||||
"选择成员设备",
|
||||
systemImage: "macbook.and.iphone",
|
||||
description: Text("查看详细网络信息和服务")
|
||||
)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.background(Color(nsColor: .windowBackgroundColor)) // 详情页使用标准窗口背景色
|
||||
}
|
||||
.ignoresSafeArea() // 真正顶到最上方
|
||||
.onAppear {
|
||||
if selectedId == nil {
|
||||
selectedId = appContext.networkContext.firstNodeId()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user