基于WebView2实现的Win11桌面框架,利用插件自定义
Moli
2026-05-03 9806138b910904d2f982ebf9471b295fb6939715
docs/architecture/detailed-design.md
@@ -517,6 +517,7 @@
| `height` | `40` | 当前显示器高度 |
| `scale` | `0.5` | `3.0` |
| `opacity` | `0.1` | `1.0` |
| `displayPriority` | `desktopLayer` | `appLayer` |
位置约束:
@@ -582,7 +583,7 @@
| `SetGlobalLocked(true)` | 所有组件拒绝拖拽缩放 |
| `ReloadPlugins` | 重新扫描插件目录,保留同 id 组件布局 |
| `DisableWallpaper` | 关闭壁纸窗口,保留壁纸配置 |
| `UpdateWidgetLayout` | 校验、应用窗口、保存布局、广播事件 |
| `UpdateWidgetLayout` | 校验、应用窗口、保存布局、广播事件,包含 `displayPriority` 更新 |
所有命令都通过 `DesktopRuntimeCoordinator` 进入,托盘、管理窗口、HTTP API 不直接调用底层服务。
@@ -700,12 +701,33 @@
| Tab | 内容 |
| --- | --- |
| 状态 | 当前运行状态、WebView2 Runtime、API 监听、显示器信息 |
| 壁纸 | 当前壁纸插件、启停、重载、静音、点击穿透、显示器选择 |
| 组件 | 组件列表、显示隐藏、锁定、透明度、点击穿透、重载 |
| 插件 | 插件扫描结果、manifest 错误、启用禁用 |
| 诊断 | 日志摘要、错误列表、打开日志目录、重置布局 |
| 壁纸 | 当前壁纸插件、启停、重载、静音、点击穿透、显示器选择、本地文件选择 |
| 组件 | 组件列表、显示隐藏、锁定、透明度、点击穿透、显示优先级、右键编辑位置/大小、打开 `layout.json` |
| 插件 | 插件扫描结果、manifest 错误、启用禁用、右键打开 `plugin.json` / `plugins.json` |
| 诊断 | 日志摘要、错误列表、打开日志目录、二次确认恢复默认 |
管理窗口不得作为桌面覆盖层,必须是普通 WPF 工具窗口。
### Built-in Audio Visualizer
默认样例插件:
```text
samples/plugins/sample.audio-visualizer/
  plugin.json
  index.html
```
默认布局由 `DefaultContentInstaller` 特判:
- `x = 0`
- `width = SystemParameters.PrimaryScreenWidth`
- `y = SystemParameters.PrimaryScreenHeight * 2 / 3`
- `height = min(SystemParameters.PrimaryScreenHeight * 0.25, manifest.defaultLayout.height)`
- `locked = true`
- `clickThrough = true`
MVP 插件端通过 Web Audio API 尝试捕获带音频的屏幕流。若系统或用户授权不允许,则使用占位律动,避免桌面视觉出现空白。真实无授权声卡输出采集作为后续 `IAudioLoopbackService` 扩展。
## Diagnostics Detailed Design
@@ -907,4 +929,3 @@
| 日志库 | `Microsoft.Extensions.Logging` + 文件 provider 或 Serilog | 如果需要结构化日志和滚动文件,优先 Serilog |
| WebView2 用户数据目录 | `%LocalAppData%\DesktopEnhancer\WebView2` | 多 profile 需求出现后再拆 |
| 默认 API 端口 | `8765` | 端口冲突时允许用户在配置中修改 |