fix: knowledge status fallback and avatar partial update
parent
8d31644f80
commit
0fb6c4d255
|
|
@ -135,6 +135,8 @@ export const AgentAPI = {
|
||||||
update: (id: string, payload: Partial<Agent>) => api.put<Agent>(`/agents/${id}`, payload).then((r) => r.data),
|
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),
|
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[]) => {
|
uploadKnowledge: (id: string, files: File[]) => {
|
||||||
const fd = new FormData();
|
const fd = new FormData();
|
||||||
files.forEach((f) => fd.append('files', f));
|
files.forEach((f) => fd.append('files', f));
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ export default function AvatarSelector({
|
||||||
key={url}
|
key={url}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
if (!agent?.id) return;
|
if (!agent?.id) return;
|
||||||
await AgentAPI.update(agent.id, { avatar: url });
|
await AgentAPI.updateAvatar(agent.id, url);
|
||||||
onCancel();
|
onCancel();
|
||||||
await onAvatarChange();
|
await onAvatarChange();
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -237,9 +237,9 @@ export default function CapabilitySettings({
|
||||||
<div className="flex flex-col gap-1 overflow-hidden">
|
<div className="flex flex-col gap-1 overflow-hidden">
|
||||||
<span className="text-sm font-medium truncate">{item.originalName}</span>
|
<span className="text-sm font-medium truncate">{item.originalName}</span>
|
||||||
<span className="text-[10px] text-gray-400">
|
<span className="text-[10px] text-gray-400">
|
||||||
{(item.size / 1024).toFixed(1)} KB ·{' '}
|
{item.size ? `${(item.size / 1024).toFixed(1)} KB` : ''} ·{' '}
|
||||||
<Tag color={STATUS_TAG[item.status].color} className="m-0 text-[10px] px-1">
|
<Tag color={STATUS_TAG[(item.status || 'ready')].color} className="m-0 text-[10px] px-1">
|
||||||
{STATUS_TAG[item.status].text}
|
{STATUS_TAG[(item.status || 'ready')].text}
|
||||||
</Tag>
|
</Tag>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ export function useAgentEditor({ id, isNew, form, message, navigate }: UseAgentE
|
||||||
if (!id) return false;
|
if (!id) return false;
|
||||||
try {
|
try {
|
||||||
const url = await uploadAvatar(file as File);
|
const url = await uploadAvatar(file as File);
|
||||||
await AgentAPI.update(id, { avatar: url });
|
await AgentAPI.updateAvatar(id, url);
|
||||||
message.success('头像已更新');
|
message.success('头像已更新');
|
||||||
setAvatarSelectorOpen(false);
|
setAvatarSelectorOpen(false);
|
||||||
refresh();
|
refresh();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue