feat:智能体探索窗口预加载完善
This commit is contained in:
@@ -71,6 +71,77 @@ function handleBlur() {
|
||||
}, 200)
|
||||
}
|
||||
|
||||
// 🆕 预加载所有任务的智能体评分数据(顺序加载,确保任务详情已填充)
|
||||
async function preloadAllTaskAgentScores(outlineData: any, goal: string) {
|
||||
const tasks = outlineData['Collaboration Process'] || []
|
||||
|
||||
if (tasks.length === 0) {
|
||||
console.log('ℹ️ 没有任务需要预加载评分数据')
|
||||
return
|
||||
}
|
||||
|
||||
console.log(`🚀 开始预加载 ${tasks.length} 个任务的智能体评分数据...`)
|
||||
|
||||
// 🆕 顺序预加载:等待每个任务详情填充完成后再预加载其评分
|
||||
for (const task of tasks) {
|
||||
// 确保任务有 Id
|
||||
if (!task.Id) {
|
||||
task.Id = `task-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`
|
||||
}
|
||||
|
||||
const taskId = task.Id
|
||||
|
||||
// 检查是否已有缓存数据
|
||||
if (agentsStore.hasTaskScoreData(taskId)) {
|
||||
console.log(`⏭️ 任务 "${task.StepName}" (${taskId}) 已有缓存数据,跳过`)
|
||||
continue
|
||||
}
|
||||
|
||||
// 🆕 等待任务详情填充完成(通过检查 AgentSelection 是否存在)
|
||||
// 最多等待 60 秒,超时则跳过该任务
|
||||
let waitCount = 0
|
||||
const maxWait = 60 // 60 * 500ms = 30秒
|
||||
while (!task.AgentSelection && waitCount < maxWait) {
|
||||
await new Promise(resolve => setTimeout(resolve, 500))
|
||||
waitCount++
|
||||
}
|
||||
|
||||
if (!task.AgentSelection) {
|
||||
console.warn(`⚠️ 任务 "${task.StepName}" (${taskId}) 详情未填充完成,跳过评分预加载`)
|
||||
continue
|
||||
}
|
||||
|
||||
try {
|
||||
// 调用初始化接口获取评分数据
|
||||
const agentScores = await api.agentSelectModifyInit({
|
||||
goal: goal,
|
||||
stepTask: {
|
||||
StepName: task.StepName,
|
||||
TaskContent: task.TaskContent,
|
||||
InputObject_List: task.InputObject_List,
|
||||
OutputObject: task.OutputObject
|
||||
}
|
||||
})
|
||||
|
||||
// 提取维度列表
|
||||
const firstAgent = Object.keys(agentScores)[0]
|
||||
const aspectList = firstAgent ? Object.keys(agentScores[firstAgent] || {}) : []
|
||||
|
||||
// 存储到 store(按任务ID存储)
|
||||
agentsStore.setTaskScoreData(taskId, {
|
||||
aspectList,
|
||||
agentScores
|
||||
})
|
||||
|
||||
console.log(`✅ 任务 "${task.StepName}" (${taskId}) 的评分数据预加载完成,维度数: ${aspectList.length}`)
|
||||
} catch (error) {
|
||||
console.error(`❌ 任务 "${task.StepName}" (${taskId}) 的评分数据预加载失败:`, error)
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`🎉 所有 ${tasks.length} 个任务的智能体评分数据预加载完成(或已跳过)`)
|
||||
}
|
||||
|
||||
// 重置文本区域高度到最小行数
|
||||
function resetTextareaHeight() {
|
||||
nextTick(() => {
|
||||
@@ -158,6 +229,9 @@ async function handleSearch() {
|
||||
outlineLoaded = true
|
||||
emit('search', searchValue.value)
|
||||
|
||||
// 🆕 预加载所有任务的智能体评分数据(在后台静默执行)
|
||||
preloadAllTaskAgentScores(outlineData, searchValue.value)
|
||||
|
||||
// 开始填充步骤详情,设置状态
|
||||
isFillingSteps.value = true
|
||||
|
||||
|
||||
Reference in New Issue
Block a user