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
|
@Environment(AppContext.self) private var appContext: AppContext
|
||||||
@State private var selectedId: Int?
|
@State private var selectedId: Int?
|
||||||
|
|
||||||
|
// 侧边栏宽度
|
||||||
|
private let sidebarWidth: CGFloat = 240
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationSplitView {
|
HStack(spacing: 0) {
|
||||||
List(appContext.networkContext.nodeList, id: \.id, selection: $selectedId) { node in
|
// --- 1. 自定义侧边栏 (Sidebar) ---
|
||||||
NetworkNodeHeadView(node: node)
|
VStack(alignment: .leading, spacing: 0) {
|
||||||
.tag(node.id)
|
// 顶部留白:避开 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)
|
.frame(width: sidebarWidth)
|
||||||
.navigationSplitViewColumnWidth(min: 200, ideal: 220)
|
|
||||||
} detail: {
|
Divider() // 分割线
|
||||||
if let selectedNode = appContext.networkContext.getNode(id: selectedId) {
|
|
||||||
NetworkNodeDetailView(node: selectedNode)
|
// --- 2. 详情区域 (Detail) ---
|
||||||
} else {
|
ZStack {
|
||||||
ContentUnavailableView("选择成员设备", systemImage: "macbook.and.iphone", description: Text("查看详细网络信息和服务"))
|
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 {
|
.onAppear {
|
||||||
if selectedId == nil {
|
if selectedId == nil {
|
||||||
selectedId = appContext.networkContext.firstNodeId()
|
selectedId = appContext.networkContext.firstNodeId()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user