Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Pangea-Agent
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gavin-Group
Pangea-Agent
Commits
2e585055
Commit
2e585055
authored
Dec 16, 2025
by
ligaowei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复工具列表加载失败提示问题,改进工具加载逻辑和错误处理
parent
4d825990
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
6 deletions
+54
-6
AgentManagement.vue
frontend/src/pages/AgentManagement.vue
+54
-6
No files found.
frontend/src/pages/AgentManagement.vue
View file @
2e585055
...
...
@@ -111,8 +111,15 @@
<span
v-if=
"tool.description"
style=
"float: right; color: #8492a6; font-size: 13px"
>
{{ tool.description }}
</span>
</el-option>
</el-select>
<div
v-if=
"allTools.length === 0"
style=
"margin-top: 5px; font-size: 12px; color: #f56c6c;"
>
工具列表加载失败或为空,请刷新页面重试
<div
v-if=
"allTools.length === 0 && !loadingTools && toolsLoadError"
style=
"margin-top: 5px; font-size: 12px; color: #f56c6c;"
>
工具列表加载失败,请刷新页面重试
<el-button
link
type=
"primary"
@
click=
"loadAllTools"
style=
"margin-left: 10px;"
>
重新加载
</el-button>
</div>
<div
v-if=
"allTools.length === 0 && !loadingTools && !toolsLoadError"
style=
"margin-top: 5px; font-size: 12px; color: #8492a6;"
>
暂无可用工具
</div>
<div
v-if=
"loadingTools"
style=
"margin-top: 5px; font-size: 12px; color: #8492a6;"
>
工具列表加载中...
</div>
<div
style=
"margin-top: 5px; font-size: 12px; color: #8492a6;"
>
不选择任何工具表示此Agent可以使用所有工具
...
...
@@ -210,28 +217,69 @@ const getToolCount = (agent) => {
// 添加工具相关变量
const
allTools
=
ref
([])
const
loadingTools
=
ref
(
false
)
const
toolsLoadError
=
ref
(
false
)
// 获取所有工具列表
const
loadAllTools
=
async
()
=>
{
const
loadAllTools
=
async
(
retryCount
=
0
)
=>
{
try
{
loadingTools
.
value
=
true
toolsLoadError
.
value
=
false
const
res
=
await
authStore
.
get
(
'/tools'
)
console
.
log
(
'工具API响应:'
,
res
)
allTools
.
value
=
res
.
data
.
data
||
[]
// 检查响应格式
if
(
res
&&
res
.
data
)
{
// 根据实际响应结构调整
if
(
Array
.
isArray
(
res
.
data
))
{
allTools
.
value
=
res
.
data
}
else
if
(
res
.
data
.
data
&&
Array
.
isArray
(
res
.
data
.
data
))
{
allTools
.
value
=
res
.
data
.
data
}
else
{
console
.
warn
(
'工具API响应格式不符合预期:'
,
res
.
data
)
allTools
.
value
=
[]
}
}
else
{
console
.
warn
(
'工具API响应为空或格式不正确:'
,
res
)
allTools
.
value
=
[]
}
console
.
log
(
'加载工具列表:'
,
allTools
.
value
)
toolsLoadError
.
value
=
false
}
catch
(
error
)
{
console
.
error
(
'获取工具列表失败:'
,
error
)
console
.
error
(
'错误详情:'
,
error
.
response
||
error
)
// 如果是认证错误且还有重试次数,尝试重新加载
if
(
error
.
response
?.
status
===
401
&&
retryCount
<
2
)
{
console
.
log
(
`认证失败,尝试重新加载 (
${
retryCount
+
1
}
/2)`
)
setTimeout
(()
=>
{
loadAllTools
(
retryCount
+
1
)
},
1000
)
return
}
toolsLoadError
.
value
=
true
ElMessage
.
error
(
'获取工具列表失败: '
+
(
error
.
response
?.
data
?.
message
||
error
.
message
||
'未知错误'
))
}
finally
{
loadingTools
.
value
=
false
}
}
onMounted
(()
=>
{
onMounted
(
async
()
=>
{
loadAgents
()
loadEnabledLlmConfigs
()
loadAllTools
()
// 加载工具列表
await
loadAllTools
()
// 加载工具列表
console
.
log
(
'工具列表加载完成,数量:'
,
allTools
.
value
.
length
)
// 如果工具列表为空,稍后重试一次
if
(
allTools
.
value
.
length
===
0
&&
!
toolsLoadError
.
value
)
{
setTimeout
(
async
()
=>
{
if
(
allTools
.
value
.
length
===
0
)
{
console
.
log
(
'工具列表为空,尝试重新加载'
)
await
loadAllTools
()
}
},
2000
)
}
})
// 在打开对话框时也加载工具列表
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment