fix:刷新缓存
This commit is contained in:
@ -83,14 +83,10 @@ ${COMMANDS.HELLO}
|
|||||||
async getRoleInfo (roleId) {
|
async getRoleInfo (roleId) {
|
||||||
logger.debug(`[ActionCommand] getRoleInfo调用,角色ID: ${roleId}`)
|
logger.debug(`[ActionCommand] getRoleInfo调用,角色ID: ${roleId}`)
|
||||||
|
|
||||||
// 懒加载HelloCommand实例
|
// 总是创建新的HelloCommand实例,确保获取最新的角色信息
|
||||||
if (!this.helloCommand) {
|
logger.debug(`[ActionCommand] 创建新的HelloCommand实例以获取最新角色信息`)
|
||||||
logger.debug(`[ActionCommand] 创建新的HelloCommand实例`)
|
|
||||||
const HelloCommand = require('./HelloCommand')
|
const HelloCommand = require('./HelloCommand')
|
||||||
this.helloCommand = new HelloCommand()
|
this.helloCommand = new HelloCommand()
|
||||||
} else {
|
|
||||||
logger.debug(`[ActionCommand] 复用现有HelloCommand实例`)
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = await this.helloCommand.getRoleInfo(roleId)
|
const result = await this.helloCommand.getRoleInfo(roleId)
|
||||||
logger.debug(`[ActionCommand] HelloCommand.getRoleInfo返回:`, result)
|
logger.debug(`[ActionCommand] HelloCommand.getRoleInfo返回:`, result)
|
||||||
|
|||||||
@ -26,8 +26,8 @@ class HelloCommand extends BasePouchCommand {
|
|||||||
*/
|
*/
|
||||||
async loadRoleRegistry () {
|
async loadRoleRegistry () {
|
||||||
try {
|
try {
|
||||||
// 使用新的ResourceManager架构初始化
|
// 强制刷新资源发现,确保能发现新创建的角色
|
||||||
await this.resourceManager.initializeWithNewArchitecture()
|
await this.resourceManager.forceRefresh()
|
||||||
|
|
||||||
// 获取所有角色相关的资源
|
// 获取所有角色相关的资源
|
||||||
const roleRegistry = {}
|
const roleRegistry = {}
|
||||||
|
|||||||
@ -189,6 +189,26 @@ 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()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有已注册的协议
|
* 获取所有已注册的协议
|
||||||
* @returns {Array<string>} 协议名称列表
|
* @returns {Array<string>} 协议名称列表
|
||||||
|
|||||||
Reference in New Issue
Block a user