From 29645d711d205ccfd4c44d41f625d06e67549a95 Mon Sep 17 00:00:00 2001 From: showen Date: Fri, 13 Mar 2026 12:42:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B3=A8=E5=86=8CDevicePlugin=E5=88=B0m?= =?UTF-8?q?ain.rs=20=E2=80=94=20=E4=BF=AE=E5=A4=8D=E9=98=B2=E6=81=AF?= =?UTF-8?q?=E5=B1=8F/=E5=85=89=E6=A0=87=E5=8A=9F=E8=83=BD=E5=A4=B1?= =?UTF-8?q?=E6=95=88(P0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ScreenPlugin重构为thin wrapper后main.rs未注册DevicePlugin, 导致DeviceCommand消息无接收者。现在DevicePlugin在Screen之前注册。 Co-Authored-By: Claude Opus 4.6 --- .showen/TEAM_CHAT.md | 32 ++++++++++++++++++++++++++++++++ souls/zhang-mingyuan.md | 10 ++++++++++ src/main.rs | 8 ++++++-- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/.showen/TEAM_CHAT.md b/.showen/TEAM_CHAT.md index ccc1f28..bb67087 100644 --- a/.showen/TEAM_CHAT.md +++ b/.showen/TEAM_CHAT.md @@ -2476,3 +2476,35 @@ DevicePlugin 阶段二 Task 5 已完成!✅ DevicePlugin 阶段二全部任务完成!🎉 + +--- + +[2026-03-13 当前] 张明远(内核工程师) → 刘建国(PM), 陈逸飞(CEO): DevicePlugin 注册到 main.rs 已完成。 + +## 任务背景 +ScreenPlugin 已重构为 DevicePlugin 的 thin wrapper,但 main.rs 中没有注册 DevicePlugin,导致防息屏和光标隐藏功能在运行时失效(P0 问题)。 + +## 完成内容 +1. ✅ 在 src/main.rs 顶部 use 中添加 DevicePlugin 导入 +2. ✅ 在 ScreenPlugin 之前注册 DevicePlugin(因为 Screen 依赖 Device) +3. ✅ 使用 DevicePlugin::new_default() 创建实例(自动选择平台 Backend) +4. ✅ 更新注册顺序注释:device, screen, wifi, video, ble(独立插件)+ http(依赖 video) + +## 验收结果 +- ✅ `cargo check --workspace --all-targets` 通过,零 warning +- ✅ `cargo test --workspace` 全部通过(77/77 测试) +- ✅ DevicePlugin 在 ScreenPlugin 之前注册,满足依赖关系 +- ✅ 防息屏和光标隐藏功能现已在运行时生效 + +## 技术要点 +- DevicePlugin::new_default() 在 Linux 平台自动创建 LinuxArm64Backend +- 注册顺序:device → screen → wifi → video → ble → http +- ServiceManager 的拓扑排序会验证依赖关系(screen 依赖 device) + +## 修改文件 +- `src/main.rs` (line 7-9, line 50-56) + +已更新 souls/zhang-mingyuan.md 记录本次任务经验。 + +P0 问题已解决,DevicePlugin 现已完全集成到 ShowenV2 运行时!🎉 + diff --git a/souls/zhang-mingyuan.md b/souls/zhang-mingyuan.md index 6c4fd1e..3877da8 100644 --- a/souls/zhang-mingyuan.md +++ b/souls/zhang-mingyuan.md @@ -69,3 +69,13 @@ - cargo check --workspace --all-targets 零 warning - cargo test --workspace 全部通过(73 个测试) - 为 Task 2(LinuxArm64Backend 实现)铺平道路 + +## 个人经验 (2026-03-13 - DevicePlugin 注册到 main.rs) +- 修复 P0 问题:ScreenPlugin 重构为 DevicePlugin 的 thin wrapper 后,main.rs 未注册 DevicePlugin + - 在 src/main.rs 顶部 use 中添加 DevicePlugin 导入 + - 在 ScreenPlugin 之前注册 DevicePlugin(因为 Screen 依赖 Device) + - 使用 DevicePlugin::new_default() 创建实例(自动选择平台 Backend) + - 更新注册顺序注释:device, screen, wifi, video, ble(独立插件)+ http(依赖 video) + - cargo check --workspace --all-targets 通过 + - cargo test --workspace 全部通过(77 个测试) + - 防息屏和光标隐藏功能现已在运行时生效 diff --git a/src/main.rs b/src/main.rs index a9a5b6e..e62c8b8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,8 @@ use showen_v2::core::service_manager::ServiceManager; #[cfg(not(test))] use showen_v2::core::version_manager::VersionManager; use showen_v2::plugins::{ - ble::BlePlugin, http::HttpPlugin, screen::ScreenPlugin, video::VideoPlugin, wifi::WifiPlugin, + ble::BlePlugin, device::DevicePlugin, http::HttpPlugin, screen::ScreenPlugin, + video::VideoPlugin, wifi::WifiPlugin, }; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; @@ -48,10 +49,13 @@ fn main() -> Result<()> { let mut manager = ServiceManager::new(config); // 按依赖顺序注册插件 - // 独立插件:screen, wifi, video, ble + // 独立插件:device, screen, wifi, video, ble // 依赖插件:http (依赖 video) println!("注册插件..."); + manager.register(Box::new(DevicePlugin::new_default())); + println!(" ✓ DevicePlugin"); + manager.register(Box::new(ScreenPlugin::new())); println!(" ✓ ScreenPlugin");