diff --git a/web/src/app/(main)/chat/page.tsx b/web/src/app/(main)/chat/page.tsx index a96b05d..952ae07 100644 --- a/web/src/app/(main)/chat/page.tsx +++ b/web/src/app/(main)/chat/page.tsx @@ -171,7 +171,7 @@ function Composer({ stopDisabled?: boolean; // 方式1 文件上传:传了 onPickFiles 才显示回形针按钮 + 附件 chip 预览。 attachments?: ChatAttachment[]; - onPickFiles?: (files: FileList | null) => void; + onPickFiles?: (files: File[]) => void; onRemoveAttachment?: (path: string) => void; uploading?: boolean; allowBtw?: boolean; @@ -222,8 +222,11 @@ function Composer({ multiple className="hidden" onChange={(e) => { - onPickFiles(e.target.files); + // FileList 与 input 元素活绑定:必须先快照成数组,再清空 value, + // 否则异步的 onPickFiles(比如草稿态要先建会话)恢复执行时会拿到空列表。 + const picked = Array.from(e.target.files ?? []); e.target.value = ""; // allow re-picking the same file + if (picked.length > 0) onPickFiles(picked); }} />