refactor: 更新ResourceManager架构,移除forceRefresh方法并整合初始化逻辑
This commit is contained in:
@ -26,8 +26,8 @@ class HelloCommand extends BasePouchCommand {
|
|||||||
*/
|
*/
|
||||||
async loadRoleRegistry () {
|
async loadRoleRegistry () {
|
||||||
try {
|
try {
|
||||||
// 强制刷新资源发现,确保能发现新创建的角色
|
// 使用新的ResourceManager架构初始化
|
||||||
await this.resourceManager.forceRefresh()
|
await this.resourceManager.initializeWithNewArchitecture()
|
||||||
|
|
||||||
// 获取所有角色相关的资源
|
// 获取所有角色相关的资源
|
||||||
const roleRegistry = {}
|
const roleRegistry = {}
|
||||||
|
|||||||
@ -189,25 +189,7 @@ class ResourceManager {
|
|||||||
return await protocol.resolve(parsed.path, parsed.queryParams)
|
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
|
module.exports = ResourceManager
|
||||||
Reference in New Issue
Block a user