feat: handle loading states

This commit is contained in:
AnotiaWang
2025-02-11 21:37:11 +08:00
parent 8c81b9a425
commit 501e25d835
5 changed files with 87 additions and 41 deletions

View File

@ -13,6 +13,7 @@
})
const selectedNode = ref<TreeNode>()
const searchResults = ref<Record<string, PartialSearchResult>>({})
const isLoading = ref(false)
function handleResearchProgress(step: ResearchStep) {
let node: TreeNode | null = null
@ -94,6 +95,7 @@
case 'complete':
emit('complete', step)
isLoading.value = false
break
}
}
@ -132,6 +134,7 @@
tree.value.children = []
selectedNode.value = undefined
searchResults.value = {}
isLoading.value = true
try {
await deepResearch({
query,
@ -141,11 +144,14 @@
})
} catch (error) {
console.error('Research failed:', error)
} finally {
isLoading.value = false
}
}
defineExpose({
startResearch,
isLoading,
})
</script>