- 菜单栏可每项独立(点击弹出该项窄详情)或合并为一个(点击打开主窗口),详情区块可在设置中勾选 - 网络详情:镜像流量历史、ICMP 连接探测格子、接口与 Wi-Fi、本地与公网 IPv4 / IPv6、SVG 国旗归属地与 ASN、各进程流量 - DNS:刷新缓存,一键切换自动 / Cloudflare / Google / 腾讯 / 阿里云或手动填写;辅助工具协议升至 3,服务名与地址二次校验 - 主窗口:侧边栏切换仪表盘、各指标详情与工具页,宽高可调,卡片按比例伸缩 - 统一外观:白底蓝 / 黑底蓝,窗口、设置与弹窗共用底色,去掉玻璃效果 - 新增网络解析、DNS 校验与国旗代码校验的单元测试;更新 README、架构文档与隐私说明
35 lines
1.3 KiB
Swift
35 lines
1.3 KiB
Swift
import AppKit
|
|
import SwiftUI
|
|
|
|
/// 弹窗窗口的底板:圆角裁切的普通容器,背景由 SwiftUI 内容绘制
|
|
@MainActor
|
|
enum PanelContainer {
|
|
/// 容器必须从内容的尺寸开始:若从 0 开始,窗口把它撑满时自动调整会把内容再放大一倍
|
|
static func make(containing content: NSView, cornerRadius: CGFloat) -> NSView {
|
|
let container = NSView(frame: content.frame)
|
|
container.wantsLayer = true
|
|
container.layer?.cornerRadius = cornerRadius
|
|
container.layer?.cornerCurve = .continuous
|
|
container.layer?.masksToBounds = true
|
|
content.autoresizingMask = [.width, .height]
|
|
container.addSubview(content)
|
|
return container
|
|
}
|
|
}
|
|
|
|
/// 内容铺满标题栏后,标题栏区域由 SwiftUI 接收点击;放在顶栏背后,按住空白处可以拖动窗口
|
|
struct WindowDragArea: NSViewRepresentable {
|
|
final class DragView: NSView {
|
|
override func mouseDown(with event: NSEvent) {
|
|
if event.clickCount == 2 {
|
|
window?.performZoom(nil)
|
|
} else {
|
|
window?.performDrag(with: event)
|
|
}
|
|
}
|
|
}
|
|
|
|
func makeNSView(context: Context) -> DragView { DragView() }
|
|
func updateNSView(_ nsView: DragView, context: Context) {}
|
|
}
|