fix: knowledge status fallback and avatar partial update

main
sp mac bookpro 2605 2026-06-01 15:46:09 +08:00
parent 8d31644f80
commit 0fb6c4d255
4 changed files with 7 additions and 5 deletions

View File

@ -135,6 +135,8 @@ export const AgentAPI = {
update: (id: string, payload: Partial<Agent>) => api.put<Agent>(`/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<Agent>(`/agents/${id}/avatar`, { avatar }).then((r) => r.data),
uploadKnowledge: (id: string, files: File[]) => {
const fd = new FormData();
files.forEach((f) => fd.append('files', f));

View File

@ -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();
}}

View File

@ -237,9 +237,9 @@ export default function CapabilitySettings({
<div className="flex flex-col gap-1 overflow-hidden">
<span className="text-sm font-medium truncate">{item.originalName}</span>
<span className="text-[10px] text-gray-400">
{(item.size / 1024).toFixed(1)} KB ·{' '}
<Tag color={STATUS_TAG[item.status].color} className="m-0 text-[10px] px-1">
{STATUS_TAG[item.status].text}
{item.size ? `${(item.size / 1024).toFixed(1)} KB` : ''} ·{' '}
<Tag color={STATUS_TAG[(item.status || 'ready')].color} className="m-0 text-[10px] px-1">
{STATUS_TAG[(item.status || 'ready')].text}
</Tag>
</span>
</div>

View File

@ -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();