From efd7ababd237193660c15c8c18cecab84bcd7382 Mon Sep 17 00:00:00 2001
From: GeWuYou <95328647+GeWuYou@users.noreply.github.com>
Date: Tue, 3 Feb 2026 20:20:41 +0800
Subject: [PATCH] =?UTF-8?q?feat(ui):=20=E6=B7=BB=E5=8A=A0=E5=9F=BA?=
=?UTF-8?q?=E4=BA=8E=E5=AE=9E=E4=BE=8B=E7=9A=84UI=E6=98=BE=E7=A4=BA?=
=?UTF-8?q?=E6=96=B9=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 在UiRouterBase中新增Show方法,支持通过IUiPageBehavior实例显示UI
- 为IUiRouter接口添加对应的Show方法重载签名
- 添加详细的XML文档注释说明参数用途
- 临时禁用publish-docs工作流以解决文档生成问题
- [release ci]
---
.github/workflows/publish-docs.yml | 15 ++++++-----
GFramework.Game.Abstractions/ui/IUiRouter.cs | 17 ++++++++++++
GFramework.Game/ui/UiRouterBase.cs | 28 ++++++++++++++++++++
3 files changed, 53 insertions(+), 7 deletions(-)
diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml
index b956ba2..43a3cf7 100644
--- a/.github/workflows/publish-docs.yml
+++ b/.github/workflows/publish-docs.yml
@@ -1,5 +1,6 @@
# 工作流名称:Publish Docs
# 该工作流用于在推送到 main 分支时自动构建并发布文档到 GitHub Pages。
+# 暂时关了,目前这个文档生成有问题,以后再改
name: Publish Docs
@@ -7,13 +8,13 @@ name: Publish Docs
# 定义工作流的触发规则。当代码仓库发生特定事件时,将自动执行相关操作。
# 此处配置表示:当向仓库推送(push)带有标签(tag)的提交时触发工作流。
# 标签匹配规则为通配符 '*',即任意标签都会触发。
-on:
- push:
- branches:
- - '**'
- tags:
- - '*'
- workflow_dispatch:
+#on:
+# push:
+# branches:
+# - '**'
+# tags:
+# - '*'
+# workflow_dispatch:
# 权限配置:指定工作流所需的权限。
# actions: read - 允许读取 GitHub Actions 相关信息。
diff --git a/GFramework.Game.Abstractions/ui/IUiRouter.cs b/GFramework.Game.Abstractions/ui/IUiRouter.cs
index cc6c2e9..c8a07db 100644
--- a/GFramework.Game.Abstractions/ui/IUiRouter.cs
+++ b/GFramework.Game.Abstractions/ui/IUiRouter.cs
@@ -143,12 +143,29 @@ public interface IUiRouter : ISystem
///
/// 在指定层级显示UI(Overlay / Modal / Toast等)
///
+ /// 要显示的UI页面的唯一标识符
+ /// UI显示的层级,例如 Overlay、Modal 或 Toast
+ /// 可选参数,用于传递给UI页面的初始化数据
+ /// UI实例策略,默认为复用已存在的实例
void Show(
string uiKey,
UiLayer layer,
IUiPageEnterParam? param = null,
UiInstancePolicy instancePolicy = UiInstancePolicy.Reuse);
+ ///
+ /// 在指定层级显示UI(Overlay / Modal / Toast等)
+ ///
+ /// 要显示的UI页面行为对象
+ /// UI显示的层级,例如 Overlay、Modal 或 Toast
+ /// 传递给UI页面的初始化数据
+ /// 是否立即进入UI页面,默认为 false
+ void Show(
+ IUiPageBehavior page,
+ UiLayer layer,
+ IUiPageEnterParam? param,
+ bool enter = false);
+
///
/// 在指定层级显示UI(基于已存在实例)
///
diff --git a/GFramework.Game/ui/UiRouterBase.cs b/GFramework.Game/ui/UiRouterBase.cs
index f480281..ee6ce1d 100644
--- a/GFramework.Game/ui/UiRouterBase.cs
+++ b/GFramework.Game/ui/UiRouterBase.cs
@@ -534,6 +534,34 @@ public abstract class UiRouterBase : AbstractSystem, IUiRouter
Log.Debug("Show existing UI instance in layer: {0}, layer={1}", uiKey, layer);
}
+ ///
+ /// 在指定层级显示UI(基于实例)
+ ///
+ public void Show(
+ IUiPageBehavior page,
+ UiLayer layer,
+ IUiPageEnterParam? param,
+ bool enter = false)
+ {
+ if (layer == UiLayer.Page)
+ throw new ArgumentException("Use Push() for Page layer");
+
+ var uiKey = page.Key;
+
+ if (!_layers.ContainsKey(layer))
+ _layers[layer] = new Dictionary();
+
+ _layers[layer][uiKey] = page;
+ _uiRoot.AddUiPage(page, layer);
+
+ if (enter)
+ page.OnEnter(param);
+
+ page.OnShow();
+
+ Log.Debug("Show existing UI instance in layer: {0}, layer={1}", uiKey, layer);
+ }
+
///
/// 隐藏指定层级的UI
///