refactor: Phase2 Task3 — ScreenPlugin重构为thin wrapper(通过DeviceCommand转发)

This commit is contained in:
showen
2026-03-13 07:40:06 +08:00
parent 5310a92633
commit bf41c4513f
4 changed files with 89 additions and 93 deletions

View File

@@ -47,3 +47,17 @@
- 用户体验设计:★★★★☆
## 首次任务评分: 8/10
## DevicePlugin 阶段二 Task 3 经验2026-03-13
- ScreenPlugin 重构为 thin wrapper
- 删除 wake_lock_child 和 cursor_hidden 字段,不再直接管理子进程
- start_wake_lock/stop_wake_lock 改为发送 DeviceCommand::SetSleepInhibit 消息
- set_cursor_hidden 改为发送 DeviceCommand::SetCursorVisible 消息
- 通过 ctx.tx.send(Envelope) 向 DevicePlugin 发送命令
- 保持 handle_message 对 ScreenLockRequest/CursorVisibility 的接口不变
- 移除所有 #[cfg(target_os = "linux")] 条件编译(平台适配交给 DevicePlugin
- dependencies() 从 vec![] 改为 vec!["device".to_string()]
- Platform 从 Platform::Linux 改为 Platform::Any跨平台能力由 DevicePlugin 提供)
- 代码行数从 176 行减少到 ~60 行(减少约 66%
- 测试更新src/core/tests.rs 中 screen_plugin_must_have_no_dependencies 改为 screen_plugin_must_depend_on_device
- 架构优势ScreenPlugin 现在只做消息转发,硬件操作统一由 DevicePlugin 管理