fix(ui): 修正风扇转轴与速率图并精简进程表

This commit is contained in:
2026-11-15 19:21:18 +08:00
parent 99e558625b
commit 60c146f8b7
21 changed files with 303 additions and 107 deletions
+24 -10
View File
@@ -62,18 +62,32 @@ private struct Host: View {
let coordinator = table.delegate as! NativeProcessTable.Coordinator
let probe = DelegateProbe(state, coordinator)
table.delegate = probe
precondition(table.numberOfRows == 500 && table.tableColumns.count == 7)
precondition(table.tableColumns.map(\.identifier.rawValue) == ["pid", "name", "cpu", "memory", "power", "threads", "path"],
"The path column must follow all process metrics")
precondition(table.numberOfRows == 500 && table.tableColumns.count == 6)
precondition(table.tableColumns.map(\.identifier.rawValue) == ["pid", "name", "cpu", "memory", "power", "threads"],
"Only the six metric columns must be visible")
precondition(table.frame.width >= table.enclosingScrollView!.contentSize.width - 1, "Native table must fill its viewport")
precondition(coordinator.createdCells > 0 && coordinator.createdCells < 200, "Rows must be virtualized")
let pathCell = table.view(atColumn: table.tableColumns.count - 1, row: 0, makeIfNecessary: true) as! NSTableCellView
precondition(pathCell.textField?.stringValue == "/test/worker-0")
let copyPath = coordinator.menu(row: 0)!.items[2]
let copyMenu = coordinator.menu(row: 0)!, copyPath = copyMenu.items[2]
precondition(copyPath.isEnabled && copyPath.representedObject as? String == "/test/worker-0")
for ascending in [false, true] {
table.sortDescriptors = [NSSortDescriptor(key: "path", ascending: ascending)]
await until { state.sorting == [ProcessSort(key: .path, order: ascending ? .forward : .reverse)] }
let savedPasteboard = NSPasteboard.general.pasteboardItems?.map { item in
item.types.compactMap { type in item.data(forType: type).map { (type, $0) } }
} ?? []
copyMenu.performActionForItem(at: 2)
precondition(NSPasteboard.general.string(forType: .string) == "/test/worker-0",
"Hiding the path column must preserve the real Copy Path action")
NSPasteboard.general.clearContents()
let restored = savedPasteboard.map { values in
let item = NSPasteboardItem(); for (type, data) in values { item.setData(data, forType: type) }; return item
}
NSPasteboard.general.writeObjects(restored)
for width: CGFloat in [900,628,340] {
window.setContentSize(CGSize(width: width, height: 260))
try? await Task.sleep(for: .milliseconds(100)); host.layoutSubtreeIfNeeded()
precondition(abs(host.bounds.width - width) < 1)
let scroll = table.enclosingScrollView!
precondition(!scroll.hasHorizontalScroller)
precondition(table.rect(ofColumn: 5).maxX <= scroll.contentView.bounds.width + 1,
"All six columns must fit the viewport without horizontal scrolling: \(width), \(table.rect(ofColumn: 5)), \(scroll.contentView.bounds)")
}
let memoryColumn = table.tableColumns.firstIndex { $0.identifier.rawValue == "memory" }!
let memoryCell = table.view(atColumn: memoryColumn, row: 0, makeIfNecessary: true) as! NSTableCellView
@@ -124,7 +138,7 @@ private struct Host: View {
window.sendEvent(escape)
await until { state.exits == 1 }
window.orderOut(nil); window.close()
print("PASS: real native table virtualization/reuse, deferred delegate writes, identity selection, sorting, copy menu, missing paths, removal, locale and in-window Esc event routing")
print("PASS: six columns fit narrow/regular viewports, real hidden-path copy, native table virtualization/reuse, deferred delegate writes, identity selection, sorting, copy menu, missing paths, removal, locale and in-window Esc event routing")
fflush(stdout); NSApp.terminate(nil)
}
NSApp.run()