From 89227ff802a3a19609b9db2e6d8780f22a7afbf7 Mon Sep 17 00:00:00 2001 From: GeWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Fri, 6 Feb 2026 23:05:09 +0800 Subject: [PATCH] =?UTF-8?q?refactor(ui):=20=E4=BC=98=E5=8C=96UiRouterBase?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E9=A1=B5=E9=9D=A2=E9=94=80=E6=AF=81=E5=92=8C?= =?UTF-8?q?=E9=9A=90=E8=97=8F=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 区分永久移除和临时隐藏的处理流程,销毁时才调用OnExit方法 - 重构日志消息以更准确反映操作类型 - 简化离开守卫检查的循环逻辑,提高代码可读性 - 添加注释说明销毁与隐藏的不同行为 - 调整日志输出格式,保持一致性 - [release ci] --- GFramework.Game/ui/UiRouterBase.cs | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/GFramework.Game/ui/UiRouterBase.cs b/GFramework.Game/ui/UiRouterBase.cs index e6ec761..e7f272f 100644 --- a/GFramework.Game/ui/UiRouterBase.cs +++ b/GFramework.Game/ui/UiRouterBase.cs @@ -556,18 +556,27 @@ public abstract class UiRouterBase : AbstractSystem, IUiRouter if (!layerDict.TryGetValue(uiKey, out var page)) return; - page.OnExit(); - page.OnHide(); - if (destroy) { + // 永久移除 + page.OnExit(); // ✅ 只在 Destroy 时 Exit _uiRoot.RemoveUiPage(page); layerDict.Remove(uiKey); - Log.Debug("Suspend & Destroy UI from layer: {0}, layer={1}", uiKey, layer); + + Log.Debug( + "Hide & Destroy UI from layer: {0}, layer={1}", + uiKey, layer + ); } else { - Log.Debug("Suspend & Suspend UI from layer: {0}, layer={1}", uiKey, layer); + // 临时隐藏(可恢复) + page.OnHide(); // ✅ Hide ≠ Exit + + Log.Debug( + "Hide UI from layer (suspend): {0}, layer={1}", + uiKey, layer + ); } } @@ -695,11 +704,9 @@ public abstract class UiRouterBase : AbstractSystem, IUiRouter return false; } - if (guard.CanInterrupt) - { - Log.Debug("Leave guard {0} passed, can interrupt = true", guard.GetType().Name); - return true; - } + if (!guard.CanInterrupt) continue; + Log.Debug("Leave guard {0} passed, can interrupt = true", guard.GetType().Name); + return true; } catch (Exception ex) {