feat(app): 搭建菜单栏应用骨架与模块化源码目录
- 入口改为 MenuBarExtra 常驻形态,无 Dock 图标 - 源码按 App / Features / Core / UI / Resources 分层组织 - 新增 MenuPanelView 菜单栏弹出面板占位视图 - Core/Monitors、Core/Models 预留采样器与数据模型位置 - 各模块目录附 README 说明;说明文件加入 Target 成员例外 - 预留 kymoTests / kymoUITests 测试目录 说明文件存放于同步源码目录内,已通过 PBXFileSystemSynchronizedBuildFileExceptionSet 排除出编译与资源拷贝,保证构建产物干净。
This commit is contained in:
@@ -13,11 +13,34 @@
|
|||||||
/* Begin PBXFileSystemSynchronizedRootGroup section */
|
/* Begin PBXFileSystemSynchronizedRootGroup section */
|
||||||
D9E51E75309338B0000608DE /* kymo */ = {
|
D9E51E75309338B0000608DE /* kymo */ = {
|
||||||
isa = PBXFileSystemSynchronizedRootGroup;
|
isa = PBXFileSystemSynchronizedRootGroup;
|
||||||
|
exceptions = (
|
||||||
|
AA00000000000000000000A1 /* Exceptions for "kymo" folder in "kymo" target */,
|
||||||
|
);
|
||||||
path = kymo;
|
path = kymo;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
/* End PBXFileSystemSynchronizedRootGroup section */
|
/* End PBXFileSystemSynchronizedRootGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
||||||
|
AA00000000000000000000A1 /* Exceptions for "kymo" folder in "kymo" target */ = {
|
||||||
|
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
|
||||||
|
membershipExceptions = (
|
||||||
|
Core/Extensions/.gitkeep,
|
||||||
|
Core/Monitors/.gitkeep,
|
||||||
|
Core/Models/.gitkeep,
|
||||||
|
Core/README.md,
|
||||||
|
Features/Dashboard/.gitkeep,
|
||||||
|
Features/README.md,
|
||||||
|
Features/Settings/.gitkeep,
|
||||||
|
Resources/README.md,
|
||||||
|
UI/Charts/.gitkeep,
|
||||||
|
UI/Components/.gitkeep,
|
||||||
|
UI/README.md,
|
||||||
|
);
|
||||||
|
target = D9E51E72309338B0000608DE /* kymo */;
|
||||||
|
};
|
||||||
|
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
D9E51E70309338B0000608DE /* Frameworks */ = {
|
D9E51E70309338B0000608DE /* Frameworks */ = {
|
||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
|||||||
@@ -7,11 +7,16 @@
|
|||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
|
/// 应用入口。
|
||||||
|
///
|
||||||
|
/// Kymo 是一款菜单栏常驻应用:不显示 Dock 图标与主窗口,
|
||||||
|
/// 通过 `MenuBarExtra` 场景在系统菜单栏展示状态并承载监控面板。
|
||||||
@main
|
@main
|
||||||
struct kymoApp: App {
|
struct kymoApp: App {
|
||||||
var body: some Scene {
|
var body: some Scene {
|
||||||
WindowGroup {
|
MenuBarExtra("Kymo", systemImage: "gauge") {
|
||||||
ContentView()
|
MenuPanelView()
|
||||||
}
|
}
|
||||||
|
.menuBarExtraStyle(.window)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
# Core
|
||||||
|
|
||||||
|
与 UI 无关的核心能力层,可被所有 Feature 复用,也是单元测试的主要覆盖对象。
|
||||||
|
|
||||||
|
| 子目录 | 职责 |
|
||||||
|
| --- | --- |
|
||||||
|
| `Monitors/` | 资源采样器:CPU、内存、磁盘、网络、GPU、电池、传感器等,统一实现采样协议,由采样调度器驱动 |
|
||||||
|
| `Models/` | 指标与配置的数据模型(如 `MetricsSnapshot`、各项指标结构体) |
|
||||||
|
| `Extensions/` | Foundation / AppKit / 标准库的类型扩展与工具方法 |
|
||||||
|
|
||||||
|
分层与数据流设计见 [docs/architecture.md](../../docs/architecture.md),
|
||||||
|
各指标的底层系统 API 选型见 [docs/monitoring.md](../../docs/monitoring.md)。
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
//
|
||||||
|
// MenuPanelView.swift
|
||||||
|
// kymo
|
||||||
|
//
|
||||||
|
// Created by Airnan on 2026/10/29.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
/// 菜单栏弹出面板:后续将在这里展示 CPU / 内存 / 磁盘 / 网络等实时监控数据。
|
||||||
|
struct MenuPanelView: View {
|
||||||
|
var body: some View {
|
||||||
|
VStack(alignment: .leading, spacing: 12) {
|
||||||
|
Label("Kymo 资源监控", systemImage: "gauge")
|
||||||
|
.font(.headline)
|
||||||
|
|
||||||
|
Text("监控面板开发中,敬请期待…")
|
||||||
|
.font(.subheadline)
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
}
|
||||||
|
.padding(16)
|
||||||
|
.frame(width: 280, alignment: .leading)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#Preview {
|
||||||
|
MenuPanelView()
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# Features
|
||||||
|
|
||||||
|
按「特性(Feature)」垂直拆分的业务模块,每个子目录自包含其视图、视图模型与子组件。
|
||||||
|
|
||||||
|
| 子目录 | 职责 | 状态 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `MenuBar/` | 菜单栏状态项与弹出监控面板 | 骨架已就绪 |
|
||||||
|
| `Dashboard/` | 监控总览面板(图表化展示) | 规划中 |
|
||||||
|
| `Settings/` | 设置窗口:刷新频率、显示项、开机自启等 | 规划中 |
|
||||||
|
|
||||||
|
新增 Feature 的原则:只依赖 `Core` 与 `UI`,不横向依赖其他 Feature。
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# Resources
|
||||||
|
|
||||||
|
文本与静态资源目录:
|
||||||
|
|
||||||
|
- 本地化字符串(String Catalog,如 `Localizable.xcstrings`)
|
||||||
|
- 预置 JSON 配置等静态数据
|
||||||
|
|
||||||
|
颜色、图片类资源统一放在上层的 `Assets.xcassets`,不要放在本目录。
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# UI
|
||||||
|
|
||||||
|
与具体业务无关、可复用的界面组件层。
|
||||||
|
|
||||||
|
| 子目录 | 职责 |
|
||||||
|
| --- | --- |
|
||||||
|
| `Charts/` | 迷你图表:趋势折线、环形进度、占用率色带等 |
|
||||||
|
| `Components/` | 通用小组件:指标行、分隔卡片、数值标签等 |
|
||||||
|
|
||||||
|
组件要求:数据通过入参传入、无全局副作用,便于在菜单栏面板与 Dashboard 间复用。
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# kymoTests
|
||||||
|
|
||||||
|
单元测试目录。当前工程尚未创建测试 Target,添加步骤见
|
||||||
|
[docs/development.md](../docs/development.md)「添加测试 Target」一节。
|
||||||
|
|
||||||
|
建议覆盖范围:
|
||||||
|
|
||||||
|
- `Core/Models`:指标快照与模型的解析、合并逻辑
|
||||||
|
- `Core/Monitors`:采样差分计算(注入模拟的两次系统计数)
|
||||||
|
- 格式化工具:速率、容量、百分比等展示格式
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# kymoUITests
|
||||||
|
|
||||||
|
UI 自动化测试目录(尚未创建对应 Target)。菜单栏应用(MenuBarExtra)的 UI 自动化
|
||||||
|
能力有限,优先保证单元测试覆盖,UI 测试按需补充。
|
||||||
|
|
||||||
|
添加步骤见 [docs/development.md](../docs/development.md)。
|
||||||
Reference in New Issue
Block a user