feat(design): 应用明亮指标配色与不透明实色面板

This commit is contained in:
2026-11-03 13:11:57 +08:00
parent df96d6853f
commit 92e8187038
19 changed files with 201 additions and 132 deletions
+1 -1
View File
@@ -62,7 +62,7 @@ GPU 通过 IOAccelerator 的 PerformanceStatistics / Device Utilization % 读取
- 当前正式入口为统一 `MenuPanelView`:第一排 CPU/GPU/电池,电池宽高比 4:3、CPU/GPU 均分余宽;第二排内存/存储/网络等宽。宽度按所属屏幕 visibleFrame 限制在 1240pt 内,高度上限 820pt;≥1160pt 三列、≥900pt 两列、其他单列。三列且高度至少 810pt 时两排完整布局,参考尺寸两排分别 230/240pt,进程区使用剩余空间(最小 170pt)。其他尺寸资源独立滚动,进程常驻;三列低高度仍保持上述比例与顺序。原生 Table 自带纵横滚动与单元格复用,不在资源滚动容器内。首次布局计入屏幕与窗口 chrome,布局后约束完整 frame 原点并水平居中。NSPanel 固定/关闭策略和 key/main 资格已有独立检查;实际外部点击与多屏专项待补。 - 当前正式入口为统一 `MenuPanelView`:第一排 CPU/GPU/电池,电池宽高比 4:3、CPU/GPU 均分余宽;第二排内存/存储/网络等宽。宽度按所属屏幕 visibleFrame 限制在 1240pt 内,高度上限 820pt;≥1160pt 三列、≥900pt 两列、其他单列。三列且高度至少 810pt 时两排完整布局,参考尺寸两排分别 230/240pt,进程区使用剩余空间(最小 170pt)。其他尺寸资源独立滚动,进程常驻;三列低高度仍保持上述比例与顺序。原生 Table 自带纵横滚动与单元格复用,不在资源滚动容器内。首次布局计入屏幕与窗口 chrome,布局后约束完整 frame 原点并水平居中。NSPanel 固定/关闭策略和 key/main 资格已有独立检查;实际外部点击与多屏专项待补。
- `PanelWindowObserver` 仅观察所属窗口的屏幕/移动/缩放,测量尺寸并约束居中;可见性由 MenuPanelController 开关与内容挂载生命周期通知 Store,不根据失焦推断关闭。 - `PanelWindowObserver` 仅观察所属窗口的屏幕/移动/缩放,测量尺寸并约束居中;可见性由 MenuPanelController 开关与内容挂载生命周期通知 Store,不根据失焦推断关闭。
- `PanelTrendChart` 只接收时间戳、最多三序列、颜色/量纲/图例文本;Canvas 按真实时间定位,带三段刻度、网格和独立分段面积。CPU 同时绘制总体/用户/系统,网络上下行、存储读写共用量级。曲线使用相邻点间不超调的三次贝塞尔;缺失值、显式中断标记和超过 max(5s, 相邻样本预期间隔较大值×2) 的间隙断线。图例始终显示最新值;悬浮时使用独立浮层显示历史时刻与各序列值,保留游标/交点,不覆盖图例数据。图表通过 Anchor Preference 上报绘图区锚点、悬浮位置与内容,ResourceCard 在卡片最外层 overlay 统一绘制浮层,避免局部 zIndex 无法越过时间刻度/卡片字段;按实际本地化内容尺寸测量并约束在卡片内。浮层不参与鼠标命中,不创建顶层窗口;背景使用 NSVisualEffectView 的 popover/withinWindow 材质模糊下方内容,轻叠资源色,减少透明度时回退实色;原生材质视图也透传鼠标。CPU 使用青绿/紫红/金色区分,所有数据序列统一使用圆滑实线,未知仍为 --。真实追加时只运行一次 0.35 秒时间轴平移/新点揭示;UI 渲染帧最多保留 61 点,包含一个移出样本,旧首尾域连续插值到新首尾域,左端线段随动画裁出,不能先删除左端点。动画任务由提交后的帧状态触发,无独立 Timer 或后台循环;暂停间隙与重置不插值,减少动态效果时立即更新。CPU/GPU/电量固定 0–100%,内存按物理总字节;动态量级扩大立即,缩小连续十次低于一半后调整。 - `PanelTrendChart` 只接收时间戳、最多三序列、颜色/量纲/图例文本;Canvas 按真实时间定位,带三段刻度、网格和独立分段面积。CPU 同时绘制总体/用户/系统,网络上下行、存储读写共用量级。曲线使用相邻点间不超调的三次贝塞尔;缺失值、显式中断标记和超过 max(5s, 相邻样本预期间隔较大值×2) 的间隙断线。图例始终显示最新值;悬浮时使用独立浮层显示历史时刻与各序列值,保留游标/交点,不覆盖图例数据。图表通过 Anchor Preference 上报绘图区锚点、悬浮位置与内容,ResourceCard 在卡片最外层 overlay 统一绘制浮层,避免局部 zIndex 无法越过时间刻度/卡片字段;按实际本地化内容尺寸测量并约束在卡片内。浮层不参与鼠标命中,不创建顶层窗口;背景使用 NSVisualEffectView 的 popover/withinWindow 材质模糊下方内容,轻叠资源色,减少透明度时回退实色;原生材质视图也透传鼠标。CPU 使用青绿/紫红/金色区分,所有数据序列统一使用圆滑实线,未知仍为 --。真实追加时只运行一次 0.35 秒时间轴平移/新点揭示;UI 渲染帧最多保留 61 点,包含一个移出样本,旧首尾域连续插值到新首尾域,左端线段随动画裁出,不能先删除左端点。动画任务由提交后的帧状态触发,无独立 Timer 或后台循环;暂停间隙与重置不插值,减少动态效果时立即更新。CPU/GPU/电量固定 0–100%,内存按物理总字节;动态量级扩大立即,缩小连续十次低于一半后调整。
- 各卡标题与彩色主值均为 13pt、共享基线同行,数值组件复用系统 numericText 数字翻动/模糊过渡并遵循减少动态效果;进程行不施加该动画。PanelCard 资源深浅色 alpha=0.68,减少透明度时改为系统实色窗口背景。操作强调色仍由偏好决定;刷新控件、图钉、保持唤醒、暂停/恢复、设置、退出胶囊位于顶栏右侧。顶栏左侧为品牌、版本及缓存的本机产品名/芯片,产品名不可读时退回 hw.model,不读取序列号。原采样状态/更新时间与底栏移除。 - 各卡标题与彩色主值均为 13pt、共享基线同行,数值组件复用系统 numericText 数字翻动/模糊过渡并遵循减少动态效果;进程行不施加该动画。PanelBackground / PanelCard 深浅色均为不透明实色,主面板与按钮组不使用玻璃材质;NSPanel 保留透明窗口壳仅用于圆角外部。深色强调色为薄荷青 #35D6BD、莓粉 #F56DA6、嫩绿 #93D45B、晴蓝 #6FA0FF、暖金 #FFC15A、浅紫 #BE8AFF,浅色提供同色相较深版本以保证可读性。网络下载/上传为蓝/金,存储读/写为金/紫,CPU 总体/用户/系统为青/粉/金;图表浮窗及原生控件弹窗继续使用模糊材质,遵循减少透明度设置。操作强调色仍由偏好决定;刷新控件、图钉、保持唤醒、暂停/恢复、设置、退出胶囊位于顶栏右侧。顶栏左侧为品牌、版本及缓存的本机产品名/芯片,产品名不可读时退回 hw.model,不读取序列号。原采样状态/更新时间与底栏移除。
- NetworkPathObserver 从系统路径的偏好首位接口提供默认接口名称([NWPath 接口按偏好排序](https://developer.apple.com/documentation/network/nwpath)),网络卡默认直接展示该接口的 IPv4,若无则展示 IPv6;未知不随意选择另一个接口。手动切换接口时同步展示该接口地址。getifaddrs 元数据、接口速率和路径状态仍独立采集;不把接口 IP 当作公网出口地址。 - NetworkPathObserver 从系统路径的偏好首位接口提供默认接口名称([NWPath 接口按偏好排序](https://developer.apple.com/documentation/network/nwpath)),网络卡默认直接展示该接口的 IPv4,若无则展示 IPv6;未知不随意选择另一个接口。手动切换接口时同步展示该接口地址。getifaddrs 元数据、接口速率和路径状态仍独立采集;不把接口 IP 当作公网出口地址。
- 进程表支持 CPU/内存(RSS)排序、名称/PID/路径搜索、同卡内选中路径展示/复制与读取覆盖计数。投影按采样/筛选/排序事件计算并缓存,不在 body 或滚动中重复排序;hover、搜索/焦点和选中冻结旧身份顺序,新增项追加到其后。完整路径在表下方同卡展示以保持固定行高;选中进程退出短暂提示后移除,关闭面板拆卸表并清掉路径状态。路径不持久化,不收集参数或环境变量。 - 进程表支持 CPU/内存(RSS)排序、名称/PID/路径搜索、同卡内选中路径展示/复制与读取覆盖计数。投影按采样/筛选/排序事件计算并缓存,不在 body 或滚动中重复排序;hover、搜索/焦点和选中冻结旧身份顺序,新增项追加到其后。完整路径在表下方同卡展示以保持固定行高;选中进程退出短暂提示后移除,关闭面板拆卸表并清掉路径状态。路径不持久化,不收集参数或环境变量。
- 旧 MetricRow / HoverDetailPresenter / DetailPlacement 与旧迷你趋势源码暂保留作迁移参照,正式面板已无调用;待真实 UI 回归后在 P6 清理并同步其历史检查程序,不能把源码存在理解为仍有双套交互。 - 旧 MetricRow / HoverDetailPresenter / DetailPlacement 与旧迷你趋势源码暂保留作迁移参照,正式面板已无调用;待真实 UI 回归后在 P6 清理并同步其历史检查程序,不能把源码存在理解为仍有双套交互。
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

+20
View File
@@ -0,0 +1,20 @@
# 实色面板与明亮配色(2026-11-03)
用户确认采用 [深色配色概念图](design/solid-panel-dark-palette-v3.png)。本次只落地色彩与背景材质,不以概念图中示例数字、额外指标或布局偏差为新增功能需求。
主面板、资源卡片、进程区、顶栏按钮组使用不透明实色;图表悬浮窗继续使用 withinWindow 模糊材质,原生菜单/popover 保持系统浮层。NSPanel 的透明窗口壳仅保留圆角外部,不代表内容透明。设置窗口沿用原生样式。
| 角色 | 深色 | 浅色 |
| --- | --- | --- |
| 面板 | #171A21 | #EDF0F5 |
| 卡片 | #222731 | #FAFBFD |
| CPU / 总体 | #35D6BD | #008B83 |
| GPU / CPU 用户 | #F56DA6 | #C93F78 |
| 电池 | #93D45B | #4C882E |
| 内存 / 网络下载 | #6FA0FF | #4268D5 |
| 存储读取 / CPU 系统 / 网络上传 | #FFC15A | #AD6D0D |
| 网络标题 / 存储写入 | #BE8AFF | #8554C8 |
色彩以 Assets.xcassets 的语义资源统一管理,图表、图例、主值、核心与进程条共用。浅色采用同色相较深版本,避免亮色直接放在浅背景上的低对比度。数字/曲线动画、采样、窗口交互不变。
验证包括 Debug 构建、实际编译资源深浅两套颜色的 alpha、CPU 序列色差和图形对卡片至少 3:1 对比度检查,以及实际 ResourceCard / PanelTrendChart 的深浅渲染。图表浮层材质代码保持原样;本轮不扩大为正式 NSPanel 全链路交互、主观动效或多屏验收。
+8
View File
@@ -122,3 +122,11 @@ Debug / Release 首版构建通过;不能据此标记 P1、P3、P4 退出条
核心与进程 CPU 进度条原先直接叠放两个 Capsule,填充宽度小于高度时未受到背景轨道的圆角轮廓约束。现共用 MetricProgressBar:有限比例钳制到 0–1,非有限输入显示空轨道;零值不绘制填充,背景与填充整体按轨道 Capsule 裁剪。 核心与进程 CPU 进度条原先直接叠放两个 Capsule,填充宽度小于高度时未受到背景轨道的圆角轮廓约束。现共用 MetricProgressBar:有限比例钳制到 0–1,非有限输入显示空轨道;零值不绘制填充,背景与填充整体按轨道 Capsule 裁剪。
验证:Debug 构建通过;用实际组件在 82×7 和 45×6 两种尺寸下进行 ImageRenderer 渲染,检查 0、0.001、0.01、0.05、0.1、0.5、1、负值、超范围值、NaN 与无穷值,填充均不越过圆角轨道。未重启用户应用,正式面板交互未重复验证。临时渲染程序、图片、缓存与构建已清理。 验证:Debug 构建通过;用实际组件在 82×7 和 45×6 两种尺寸下进行 ImageRenderer 渲染,检查 0、0.001、0.01、0.05、0.1、0.5、1、负值、超范围值、NaN 与无穷值,填充均不越过圆角轨道。未重启用户应用,正式面板交互未重复验证。临时渲染程序、图片、缓存与构建已清理。
### 明亮配色与实色面板(2026-11-03)
采用用户确认的深色概念配色,见 [配色说明](solid-panel-palette.md)。主面板 #171A21、卡片 #222731 均 alpha=1;移除主面板 ultraThinMaterial 与顶栏按钮组 glassEffect。CPU 青/粉/金、网络蓝/金、存储金/紫,六类指标主色统一由资源控制;浅色使用同色相较深版本。TooltipMaterialBackground、原生菜单/popover 与设置页材质不变。
通过:Debug 构建;PanelAssetChecks 从编译后的实际应用读取深浅资源,检查面板/卡片/指标 alpha、CPU 序列色相差至少 36°、指标/序列对卡片图形对比度至少 3:1。原来的 RGB 欧氏距离阈值不能直接表达新调色的色相分离,故改为环形色相间隔并新增实际亮度对比度校验。
使用实际 ResourceCard、PanelTrendChart、MetricProgressBar 和编译资源,通过 ImageRenderer 渲染固定样本的两排六卡片,深浅两种模式确认实色层级、明亮强调色与复合曲线区分。该样例使用简化文本/固定样本,不是完整 MenuPanelView 截图,不证明正式 NSPanel 悬浮事件或真实数据;本轮未重启用户应用。临时渲染程序、图片、缓存及构建产物清理,用户既有本地化改动未纳入提交。
@@ -5,30 +5,30 @@
"color": { "color": {
"color-space": "srgb", "color-space": "srgb",
"components": { "components": {
"red": "0.180", "red": "0.298039",
"green": "0.430", "green": "0.533333",
"blue": "0.180", "blue": "0.180392",
"alpha": "1.000" "alpha": "1.000"
} }
} }
}, },
{ {
"idiom": "universal", "idiom": "universal",
"color": {
"color-space": "srgb",
"components": {
"red": "0.576471",
"green": "0.831373",
"blue": "0.356863",
"alpha": "1.000"
}
},
"appearances": [ "appearances": [
{ {
"appearance": "luminosity", "appearance": "luminosity",
"value": "dark" "value": "dark"
} }
], ]
"color": {
"color-space": "srgb",
"components": {
"red": "0.500",
"green": "0.850",
"blue": "0.430",
"alpha": "1.000"
}
}
} }
], ],
"info": { "info": {
@@ -5,30 +5,30 @@
"color": { "color": {
"color-space": "srgb", "color-space": "srgb",
"components": { "components": {
"red": "0.000", "red": "0.000000",
"green": "0.370", "green": "0.545098",
"blue": "0.400", "blue": "0.513725",
"alpha": "1.000" "alpha": "1.000"
} }
} }
}, },
{ {
"idiom": "universal", "idiom": "universal",
"color": {
"color-space": "srgb",
"components": {
"red": "0.207843",
"green": "0.839216",
"blue": "0.741176",
"alpha": "1.000"
}
},
"appearances": [ "appearances": [
{ {
"appearance": "luminosity", "appearance": "luminosity",
"value": "dark" "value": "dark"
} }
], ]
"color": {
"color-space": "srgb",
"components": {
"red": "0.250",
"green": "0.850",
"blue": "0.780",
"alpha": "1.000"
}
}
} }
], ],
"info": { "info": {
@@ -5,30 +5,30 @@
"color": { "color": {
"color-space": "srgb", "color-space": "srgb",
"components": { "components": {
"red": "0.600", "red": "0.678431",
"green": "0.300", "green": "0.427451",
"blue": "0.020", "blue": "0.050980",
"alpha": "1.000" "alpha": "1.000"
} }
} }
}, },
{ {
"idiom": "universal", "idiom": "universal",
"color": {
"color-space": "srgb",
"components": {
"red": "1.000000",
"green": "0.756863",
"blue": "0.352941",
"alpha": "1.000"
}
},
"appearances": [ "appearances": [
{ {
"appearance": "luminosity", "appearance": "luminosity",
"value": "dark" "value": "dark"
} }
], ]
"color": {
"color-space": "srgb",
"components": {
"red": "1.000",
"green": "0.670",
"blue": "0.280",
"alpha": "1.000"
}
}
} }
], ],
"info": { "info": {
@@ -5,30 +5,30 @@
"color": { "color": {
"color-space": "srgb", "color-space": "srgb",
"components": { "components": {
"red": "0.480", "red": "0.788235",
"green": "0.220", "green": "0.247059",
"blue": "0.700", "blue": "0.470588",
"alpha": "1.000" "alpha": "1.000"
} }
} }
}, },
{ {
"idiom": "universal", "idiom": "universal",
"color": {
"color-space": "srgb",
"components": {
"red": "0.960784",
"green": "0.427451",
"blue": "0.650980",
"alpha": "1.000"
}
},
"appearances": [ "appearances": [
{ {
"appearance": "luminosity", "appearance": "luminosity",
"value": "dark" "value": "dark"
} }
], ]
"color": {
"color-space": "srgb",
"components": {
"red": "0.760",
"green": "0.550",
"blue": "1.000",
"alpha": "1.000"
}
}
} }
], ],
"info": { "info": {
@@ -5,30 +5,30 @@
"color": { "color": {
"color-space": "srgb", "color-space": "srgb",
"components": { "components": {
"red": "0.250", "red": "0.258824",
"green": "0.320", "green": "0.407843",
"blue": "0.750", "blue": "0.835294",
"alpha": "1.000" "alpha": "1.000"
} }
} }
}, },
{ {
"idiom": "universal", "idiom": "universal",
"color": {
"color-space": "srgb",
"components": {
"red": "0.435294",
"green": "0.627451",
"blue": "1.000000",
"alpha": "1.000"
}
},
"appearances": [ "appearances": [
{ {
"appearance": "luminosity", "appearance": "luminosity",
"value": "dark" "value": "dark"
} }
], ]
"color": {
"color-space": "srgb",
"components": {
"red": "0.550",
"green": "0.640",
"blue": "1.000",
"alpha": "1.000"
}
}
} }
], ],
"info": { "info": {
@@ -5,30 +5,30 @@
"color": { "color": {
"color-space": "srgb", "color-space": "srgb",
"components": { "components": {
"red": "0.000", "red": "0.521569",
"green": "0.380", "green": "0.329412",
"blue": "0.650", "blue": "0.784314",
"alpha": "1.000" "alpha": "1.000"
} }
} }
}, },
{ {
"idiom": "universal", "idiom": "universal",
"color": {
"color-space": "srgb",
"components": {
"red": "0.745098",
"green": "0.541176",
"blue": "1.000000",
"alpha": "1.000"
}
},
"appearances": [ "appearances": [
{ {
"appearance": "luminosity", "appearance": "luminosity",
"value": "dark" "value": "dark"
} }
], ]
"color": {
"color-space": "srgb",
"components": {
"red": "0.350",
"green": "0.720",
"blue": "1.000",
"alpha": "1.000"
}
}
} }
], ],
"info": { "info": {
@@ -0,0 +1,38 @@
{
"colors": [
{
"idiom": "universal",
"color": {
"color-space": "srgb",
"components": {
"red": "0.929412",
"green": "0.941176",
"blue": "0.960784",
"alpha": "1.000"
}
}
},
{
"idiom": "universal",
"color": {
"color-space": "srgb",
"components": {
"red": "0.090196",
"green": "0.101961",
"blue": "0.129412",
"alpha": "1.000"
}
},
"appearances": [
{
"appearance": "luminosity",
"value": "dark"
}
]
}
],
"info": {
"author": "xcode",
"version": 1
}
}
@@ -5,30 +5,30 @@
"color": { "color": {
"color-space": "srgb", "color-space": "srgb",
"components": { "components": {
"red": "0.960", "red": "0.980392",
"green": "0.970", "green": "0.984314",
"blue": "0.990", "blue": "0.992157",
"alpha": "0.680" "alpha": "1.000"
} }
} }
}, },
{ {
"idiom": "universal", "idiom": "universal",
"color": {
"color-space": "srgb",
"components": {
"red": "0.133333",
"green": "0.152941",
"blue": "0.192157",
"alpha": "1.000"
}
},
"appearances": [ "appearances": [
{ {
"appearance": "luminosity", "appearance": "luminosity",
"value": "dark" "value": "dark"
} }
], ]
"color": {
"color-space": "srgb",
"components": {
"red": "0.100",
"green": "0.120",
"blue": "0.160",
"alpha": "0.680"
}
}
} }
], ],
"info": { "info": {
@@ -5,9 +5,9 @@
"color": { "color": {
"color-space": "srgb", "color-space": "srgb",
"components": { "components": {
"red": "0.620", "red": "0.678431",
"green": "0.340", "green": "0.427451",
"blue": "0.000", "blue": "0.050980",
"alpha": "1.000" "alpha": "1.000"
} }
} }
@@ -17,9 +17,9 @@
"color": { "color": {
"color-space": "srgb", "color-space": "srgb",
"components": { "components": {
"red": "1.000", "red": "1.000000",
"green": "0.760", "green": "0.756863",
"blue": "0.240", "blue": "0.352941",
"alpha": "1.000" "alpha": "1.000"
} }
}, },
@@ -5,9 +5,9 @@
"color": { "color": {
"color-space": "srgb", "color-space": "srgb",
"components": { "components": {
"red": "0.700", "red": "0.678431",
"green": "0.260", "green": "0.427451",
"blue": "0.000", "blue": "0.050980",
"alpha": "1.000" "alpha": "1.000"
} }
} }
@@ -17,9 +17,9 @@
"color": { "color": {
"color-space": "srgb", "color-space": "srgb",
"components": { "components": {
"red": "1.000", "red": "1.000000",
"green": "0.620", "green": "0.756863",
"blue": "0.200", "blue": "0.352941",
"alpha": "1.000" "alpha": "1.000"
} }
}, },
@@ -5,9 +5,9 @@
"color": { "color": {
"color-space": "srgb", "color-space": "srgb",
"components": { "components": {
"red": "0.700", "red": "0.788235",
"green": "0.040", "green": "0.247059",
"blue": "0.460", "blue": "0.470588",
"alpha": "1.000" "alpha": "1.000"
} }
} }
@@ -17,9 +17,9 @@
"color": { "color": {
"color-space": "srgb", "color-space": "srgb",
"components": { "components": {
"red": "1.000", "red": "0.960784",
"green": "0.400", "green": "0.427451",
"blue": "0.750", "blue": "0.650980",
"alpha": "1.000" "alpha": "1.000"
} }
}, },
+4 -4
View File
@@ -60,7 +60,7 @@ struct MenuPanelView: View {
.onChange(of: snapshot.network?.map(\.identity)) { _, keys in .onChange(of: snapshot.network?.map(\.identity)) { _, keys in
if !selectedInterface.isEmpty && !(keys ?? []).contains(selectedInterface) { selectedInterface = "" } if !selectedInterface.isEmpty && !(keys ?? []).contains(selectedInterface) { selectedInterface = "" }
} }
.background(.ultraThinMaterial, in: .rect(cornerRadius: 18)) .background(Color("PanelBackground"), in: .rect(cornerRadius: 18))
.clipShape(.rect(cornerRadius: 18)) .clipShape(.rect(cornerRadius: 18))
.modifier(AppearanceStyle(preferences: preferences)) .modifier(AppearanceStyle(preferences: preferences))
} }
@@ -180,7 +180,7 @@ struct MenuPanelView: View {
Text(verbatim: "\(item.name) · \(item.addresses.first(where: { !$0.contains(":") }) ?? item.addresses.first ?? "--")") Text(verbatim: "\(item.name) · \(item.addresses.first(where: { !$0.contains(":") }) ?? item.addresses.first ?? "--")")
.font(.system(size: 10)).lineLimit(1).minimumScaleFactor(0.8).textSelection(.enabled) .font(.system(size: 10)).lineLimit(1).minimumScaleFactor(0.8).textSelection(.enabled)
} else { Text("panel.addressUnknown").foregroundStyle(.secondary) } } else { Text("panel.addressUnknown").foregroundStyle(.secondary) }
PanelTrendChart(dates: networkDates, first: networkDownloads, second: networkUploads, color: Color("MetricNetwork"), secondColor: Color("SeriesUpload"), fixedScale: nil, firstLabel: "network.download", secondLabel: "network.upload", expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: networkIntervals).id(selectedInterface) PanelTrendChart(dates: networkDates, first: networkDownloads, second: networkUploads, color: Color("MetricMemory"), secondColor: Color("SeriesUpload"), fixedScale: nil, firstLabel: "network.download", secondLabel: "network.upload", expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: networkIntervals).id(selectedInterface)
if !network.isEmpty && total(\.download) == nil { Text("panel.rateBaseline").foregroundStyle(.secondary) } if !network.isEmpty && total(\.download) == nil { Text("panel.rateBaseline").foregroundStyle(.secondary) }
HStack { line("network.received", network.isEmpty ? "--" : MetricFormat.bytes(network.reduce(0) { $0 + $1.received })); line("network.sent", network.isEmpty ? "--" : MetricFormat.bytes(network.reduce(0) { $0 + $1.sent })) } HStack { line("network.received", network.isEmpty ? "--" : MetricFormat.bytes(network.reduce(0) { $0 + $1.received })); line("network.sent", network.isEmpty ? "--" : MetricFormat.bytes(network.reduce(0) { $0 + $1.sent })) }
switch snapshot.networkPath { switch snapshot.networkPath {
@@ -228,7 +228,7 @@ struct MenuPanelView: View {
ResourceCard(title: "metric.disk", symbol: "internaldrive", color: Color("MetricDisk"), value: snapshot.disk.map { String(format: "%.0f / %.0f GB", Double($0.total - min($0.total, $0.available)) / 1_000_000_000, Double($0.total) / 1_000_000_000) } ?? "--") { ResourceCard(title: "metric.disk", symbol: "internaldrive", color: Color("MetricDisk"), value: snapshot.disk.map { String(format: "%.0f / %.0f GB", Double($0.total - min($0.total, $0.available)) / 1_000_000_000, Double($0.total) / 1_000_000_000) } ?? "--") {
PanelTrendChart(dates: samples.map(\.date), first: samples.map(\.read), second: samples.map(\.write), color: Color("MetricDisk"), secondColor: Color("MetricMemory"), fixedScale: nil, firstLabel: "disk.read", secondLabel: "disk.write", expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: chartIntervals) PanelTrendChart(dates: samples.map(\.date), first: samples.map(\.read), second: samples.map(\.write), color: Color("MetricDisk"), secondColor: Color("MetricNetwork"), fixedScale: nil, firstLabel: "disk.read", secondLabel: "disk.write", expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: chartIntervals)
Text("disk.physicalIO").foregroundStyle(.secondary) Text("disk.physicalIO").foregroundStyle(.secondary)
HStack { line("disk.read", MetricFormat.rate(snapshot.diskIO?.read)); line("disk.write", MetricFormat.rate(snapshot.diskIO?.written)) } HStack { line("disk.read", MetricFormat.rate(snapshot.diskIO?.read)); line("disk.write", MetricFormat.rate(snapshot.diskIO?.written)) }
HStack { line("disk.remainingLife", MetricFormat.percent(snapshot.diskHealth?.remainingLife)); line("disk.powerOnHours", snapshot.diskHealth?.powerOnHours.map { "\($0) h" } ?? "--") } HStack { line("disk.remainingLife", MetricFormat.percent(snapshot.diskHealth?.remainingLife)); line("disk.powerOnHours", snapshot.diskHealth?.powerOnHours.map { "\($0) h" } ?? "--") }
@@ -318,7 +318,7 @@ struct MenuPanelView: View {
} }
.buttonStyle(PanelControlButtonStyle()) .buttonStyle(PanelControlButtonStyle())
.padding(4) .padding(4)
.glassEffect(.regular, in: .capsule) .background(Color("PanelCard"), in: .capsule)
} }
.controlSize(.small) .controlSize(.small)
.padding(.horizontal, 2).padding(.vertical, 0) .padding(.horizontal, 2).padding(.vertical, 0)
+1 -8
View File
@@ -15,15 +15,8 @@ struct AnimatedMetricText: View {
struct PanelCardBackground: ViewModifier { struct PanelCardBackground: ViewModifier {
let radius: CGFloat let radius: CGFloat
@Environment(\.accessibilityReduceTransparency) private var reduceTransparency
func body(content: Content) -> some View { func body(content: Content) -> some View {
content.background { content.background(RoundedRectangle(cornerRadius: radius).fill(Color("PanelCard")))
if reduceTransparency {
RoundedRectangle(cornerRadius: radius).fill(Color(nsColor: .windowBackgroundColor))
} else {
RoundedRectangle(cornerRadius: radius).fill(Color("PanelCard"))
}
}
} }
} }
+18 -8
View File
@@ -1,27 +1,37 @@
import AppKit import AppKit
@main struct PanelAssetChecks { @main struct PanelAssetChecks {
static func luminance(_ color: NSColor) -> Double {
func linear(_ x: CGFloat) -> Double {
let value = Double(x)
return value <= 0.04045 ? value / 12.92 : pow((value + 0.055) / 1.055, 2.4)
}
return 0.2126 * linear(color.redComponent) + 0.7152 * linear(color.greenComponent) + 0.0722 * linear(color.blueComponent)
}
static func main() { static func main() {
let bundle = Bundle(path: CommandLine.arguments[1])! let bundle = Bundle(path: CommandLine.arguments[1])!
for appearance in [NSAppearance.Name.aqua, .darkAqua] { for appearance in [NSAppearance.Name.aqua, .darkAqua] {
NSAppearance(named: appearance)!.performAsCurrentDrawingAppearance { NSAppearance(named: appearance)!.performAsCurrentDrawingAppearance {
for name in ["PanelCard", "PanelTooltip", "MetricCPU", "MetricGPU", "MetricMemory", "MetricNetwork", "MetricDisk", "MetricBattery", "SeriesUser", "SeriesSystem", "SeriesUpload"] { for name in ["PanelBackground", "PanelCard", "PanelTooltip", "MetricCPU", "MetricGPU", "MetricMemory", "MetricNetwork", "MetricDisk", "MetricBattery", "SeriesUser", "SeriesSystem", "SeriesUpload"] {
guard let color = NSColor(named: NSColor.Name(name), bundle: bundle)?.usingColorSpace(.sRGB) else { fatalError("Missing color: \(name)") } guard let color = NSColor(named: NSColor.Name(name), bundle: bundle)?.usingColorSpace(.sRGB) else { fatalError("Missing color: \(name)") }
precondition(abs(color.alphaComponent - (name == "PanelCard" ? 0.68 : name == "PanelTooltip" ? 0.97 : 1)) < 0.005, "Unexpected alpha \(name)") precondition(abs(color.alphaComponent - (name == "PanelTooltip" ? 0.97 : 1)) < 0.005, "Unexpected alpha \(name)")
if name == "MetricGPU" && appearance == .darkAqua { precondition(color.blueComponent > 0.99) } if name.hasPrefix("Metric") || name.hasPrefix("Series") {
let card = NSColor(named: "PanelCard", bundle: bundle)!.usingColorSpace(.sRGB)!
let a = luminance(color), b = luminance(card)
precondition((max(a, b) + 0.05) / (min(a, b) + 0.05) >= 3, "Insufficient graphical contrast: \(name) / \(appearance)")
}
} }
let names = ["MetricCPU", "SeriesUser", "SeriesSystem"] let names = ["MetricCPU", "SeriesUser", "SeriesSystem"]
let colors = names.map { NSColor(named: NSColor.Name($0), bundle: bundle)!.usingColorSpace(.sRGB)! } let colors = names.map { NSColor(named: NSColor.Name($0), bundle: bundle)!.usingColorSpace(.sRGB)! }
for i in 0..<colors.count { for i in 0..<colors.count {
for j in (i + 1)..<colors.count { for j in (i + 1)..<colors.count {
let distance = pow(colors[i].redComponent - colors[j].redComponent, 2) let delta = abs(colors[i].hueComponent - colors[j].hueComponent)
+ pow(colors[i].greenComponent - colors[j].greenComponent, 2) precondition(min(delta, 1 - delta) >= 0.1, "CPU series hues too close")
+ pow(colors[i].blueComponent - colors[j].blueComponent, 2)
precondition(distance > 0.25, "CPU series hues too close")
} }
} }
} }
} }
print("PASS: compiled light/dark semantic colors exist, card translucent/semantic colors opaque, GPU blue component is normalized") print("PASS: compiled light/dark semantic colors exist, panel/card opaque, semantic colors opaque, CPU series distinct and graphical contrast >= 3:1")
} }
} }
+1 -1
View File
@@ -134,7 +134,7 @@ swiftc -parse-as-library -module-cache-path /private/tmp/kymo-unified-cache \
/private/tmp/kymo-panel-asset-checks /absolute/path/to/kymo.app /private/tmp/kymo-panel-asset-checks /absolute/path/to/kymo.app
``` ```
前者覆盖屏幕预算、边界约束和 2000 行投影,不证明原生定位或滚动手感;后者读取编译资源,防止整数色值被解释为 1/255,并确认卡片半透明、指标色不透明。 前者覆盖屏幕预算、边界约束和 2000 行投影,不证明原生定位或滚动手感;后者读取编译资源,确认主面板/卡片不透明、浮层资源保留既有透明度,检查 CPU 三序列色相间隔至少 36°,以及所有指标/序列颜色对卡片背景的图形对比度至少 3:1。
复合图几何检查(真实时间追加、满历史平移、暂停断线、缺失/非有限值): 复合图几何检查(真实时间追加、满历史平移、暂停断线、缺失/非有限值):