From 0f69eec64db690d19bbfaf0a89f3f4fe305c7adc Mon Sep 17 00:00:00 2001 From: AskaEth Date: Thu, 5 Nov 2026 00:11:01 +0800 Subject: [PATCH] =?UTF-8?q?refactor(presenter):=20M114=20mock=20=E7=9A=84?= =?UTF-8?q?=E3=80=8C=E5=8F=96=E6=B6=88=E7=99=BB=E5=BD=95=E3=80=8D=E6=90=AC?= =?UTF-8?q?=E8=BF=9B=20mock/accounts.rs=EF=BC=88=E5=AE=88=20400=20?= =?UTF-8?q?=E8=A1=8C=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/presenter/src/mock.rs | 12 ++---------- crates/presenter/src/mock/accounts.rs | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/crates/presenter/src/mock.rs b/crates/presenter/src/mock.rs index 8899191..a8fd500 100644 --- a/crates/presenter/src/mock.rs +++ b/crates/presenter/src/mock.rs @@ -284,16 +284,8 @@ impl Backend for MockBackend { ))); } AppCommand::RefreshAll => self.seed_accounts(), - // 与真 host 同一契约:取消登录把**两条轨**都收回 Idle(M114 r3 / 复审 r2 P2-1 的 - // 断言与截图都依赖这条;mock 的 `_ => {}` 兜底会让 Close 看起来「没反应」)。 - AppCommand::CancelDeviceLogin => { - self.emit(AppEvent::Core(CoreEvent::DeviceLoginChanged( - crate::dto::DeviceLoginView::new(), - ))); - self.emit(AppEvent::Core(CoreEvent::AuthlibLoginChanged( - crate::dto::AuthlibLoginView::new(), - ))); - } + // 与真 host 同一契约:取消登录把两条轨都收回 Idle(否则 Close 在 mock 下「没反应」) + AppCommand::CancelDeviceLogin => self.cancel_login(), AppCommand::RefreshLogSessions | AppCommand::StopAgent => {} // 其余指令(安装向导/账户/Java/设置/通知)由真实 host 承接:mock 不模拟 _ => {} diff --git a/crates/presenter/src/mock/accounts.rs b/crates/presenter/src/mock/accounts.rs index 61f78cd..668fc01 100644 --- a/crates/presenter/src/mock/accounts.rs +++ b/crates/presenter/src/mock/accounts.rs @@ -16,6 +16,21 @@ use crate::dto::{ LoginFailure, }; +impl super::MockBackend { + /// 取消登录:两条轨都发 Idle(真 host 的 `CancelDeviceLogin` 就是这么做的)。 + /// + /// 为什么放在 mock 里也要认真做:M114 的 `Close` 回归闸与「关掉之后」的取证图都走这条 + /// 通道——mock 用 `_ => {}` 兜底的话,Close 会看起来「点了没反应」,断言会假红/假绿。 + pub(super) fn cancel_login(&mut self) { + self.emit(crate::dto::AppEvent::Core( + crate::dto::CoreEvent::DeviceLoginChanged(DeviceLoginView::new()), + )); + self.emit(crate::dto::AppEvent::Core( + crate::dto::CoreEvent::AuthlibLoginChanged(AuthlibLoginView::new()), + )); + } +} + /// 场景名(`ULL_ACCOUNT_STATE`;未知值按 `list` 处理)。 pub(super) fn scenario() -> String { std::env::var("ULL_ACCOUNT_STATE")