From 0fb6c4d255f4fb6a089653fb1f7ae0a1a2ebf638 Mon Sep 17 00:00:00 2001 From: sp mac bookpro 2605 Date: Mon, 1 Jun 2026 15:46:09 +0800 Subject: [PATCH] fix: knowledge status fallback and avatar partial update --- src/api.ts | 2 ++ src/pages/AgentEditor/components/AvatarSelector.tsx | 2 +- src/pages/AgentEditor/components/CapabilitySettings.tsx | 6 +++--- src/pages/AgentEditor/hooks/useAgentEditor.ts | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/api.ts b/src/api.ts index 2bd7449..93c4806 100644 --- a/src/api.ts +++ b/src/api.ts @@ -135,6 +135,8 @@ export const AgentAPI = { update: (id: string, payload: Partial) => api.put(`/agents/${id}`, payload).then((r) => r.data), remove: (id: string) => api.delete(`/agents/${id}`).then((r) => r.data), + updateAvatar: (id: string, avatar: string) => api.patch(`/agents/${id}/avatar`, { avatar }).then((r) => r.data), + uploadKnowledge: (id: string, files: File[]) => { const fd = new FormData(); files.forEach((f) => fd.append('files', f)); diff --git a/src/pages/AgentEditor/components/AvatarSelector.tsx b/src/pages/AgentEditor/components/AvatarSelector.tsx index 1e1a7bf..5d777eb 100644 --- a/src/pages/AgentEditor/components/AvatarSelector.tsx +++ b/src/pages/AgentEditor/components/AvatarSelector.tsx @@ -39,7 +39,7 @@ export default function AvatarSelector({ key={url} onClick={async () => { if (!agent?.id) return; - await AgentAPI.update(agent.id, { avatar: url }); + await AgentAPI.updateAvatar(agent.id, url); onCancel(); await onAvatarChange(); }} diff --git a/src/pages/AgentEditor/components/CapabilitySettings.tsx b/src/pages/AgentEditor/components/CapabilitySettings.tsx index c9ad4f7..30079d3 100644 --- a/src/pages/AgentEditor/components/CapabilitySettings.tsx +++ b/src/pages/AgentEditor/components/CapabilitySettings.tsx @@ -237,9 +237,9 @@ export default function CapabilitySettings({
{item.originalName} - {(item.size / 1024).toFixed(1)} KB ·{' '} - - {STATUS_TAG[item.status].text} + {item.size ? `${(item.size / 1024).toFixed(1)} KB` : ''} ·{' '} + + {STATUS_TAG[(item.status || 'ready')].text}
diff --git a/src/pages/AgentEditor/hooks/useAgentEditor.ts b/src/pages/AgentEditor/hooks/useAgentEditor.ts index 2112699..b20b0cf 100644 --- a/src/pages/AgentEditor/hooks/useAgentEditor.ts +++ b/src/pages/AgentEditor/hooks/useAgentEditor.ts @@ -167,7 +167,7 @@ export function useAgentEditor({ id, isNew, form, message, navigate }: UseAgentE if (!id) return false; try { const url = await uploadAvatar(file as File); - await AgentAPI.update(id, { avatar: url }); + await AgentAPI.updateAvatar(id, url); message.success('头像已更新'); setAvatarSelectorOpen(false); refresh();