From 09e119d50f3531dd0dd664c4585b0c72c79ff1fc Mon Sep 17 00:00:00 2001 From: sean Date: Thu, 12 Jun 2025 17:57:16 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=96=B0ResourceManager?= =?UTF-8?q?=E6=9E=B6=E6=9E=84=EF=BC=8C=E7=A7=BB=E9=99=A4forceRefresh?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=B9=B6=E6=95=B4=E5=90=88=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/core/pouch/commands/HelloCommand.js | 4 ++-- src/lib/core/resource/resourceManager.js | 22 +++------------------ 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/src/lib/core/pouch/commands/HelloCommand.js b/src/lib/core/pouch/commands/HelloCommand.js index 06cf96f..076010b 100644 --- a/src/lib/core/pouch/commands/HelloCommand.js +++ b/src/lib/core/pouch/commands/HelloCommand.js @@ -26,8 +26,8 @@ class HelloCommand extends BasePouchCommand { */ async loadRoleRegistry () { try { - // 强制刷新资源发现,确保能发现新创建的角色 - await this.resourceManager.forceRefresh() + // 使用新的ResourceManager架构初始化 + await this.resourceManager.initializeWithNewArchitecture() // 获取所有角色相关的资源 const roleRegistry = {} diff --git a/src/lib/core/resource/resourceManager.js b/src/lib/core/resource/resourceManager.js index 09a4d93..ffa9df1 100644 --- a/src/lib/core/resource/resourceManager.js +++ b/src/lib/core/resource/resourceManager.js @@ -189,25 +189,7 @@ class ResourceManager { return await protocol.resolve(parsed.path, parsed.queryParams) } - /** - * 强制重新初始化资源发现(清除缓存) - * 用于解决新创建角色无法被发现的问题 - */ - async forceRefresh() { - // 1. 清除ResourceManager的初始化状态 - this.initialized = false - - // 2. 清空注册表 - this.registry.clear() - - // 3. 清除所有发现器的缓存 - if (this.discoveryManager && this.discoveryManager.clearCache) { - this.discoveryManager.clearCache() - } - - // 4. 重新初始化 - await this.initializeWithNewArchitecture() - } + /** * 获取所有已注册的协议 @@ -281,6 +263,8 @@ class ResourceManager { } } } + + } module.exports = ResourceManager \ No newline at end of file