Spaces:
Sleeping
Sleeping
Update web/src/components/ChatArea.tsx
Browse files
web/src/components/ChatArea.tsx
CHANGED
|
@@ -932,20 +932,40 @@ export function ChatArea({
|
|
| 932 |
{uploadedFiles.map((uf, i) => {
|
| 933 |
const key = `${uf.file.name}::${uf.file.size}::${uf.file.lastModified}`;
|
| 934 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 935 |
return (
|
| 936 |
<div key={key} className="flex items-center justify-between gap-2 rounded-md border px-3 py-2">
|
| 937 |
-
|
| 938 |
-
|
| 939 |
-
<div className="
|
| 940 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 941 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 942 |
</div>
|
| 943 |
|
| 944 |
-
{/*
|
| 945 |
<Button
|
| 946 |
variant="ghost"
|
| 947 |
size="icon"
|
| 948 |
-
onClick={() => onRemoveFile(i)}
|
| 949 |
title="Remove"
|
| 950 |
>
|
| 951 |
<Trash2 className="h-4 w-4" />
|
|
|
|
| 932 |
{uploadedFiles.map((uf, i) => {
|
| 933 |
const key = `${uf.file.name}::${uf.file.size}::${uf.file.lastModified}`;
|
| 934 |
|
| 935 |
+
const ext = uf.file.name.toLowerCase();
|
| 936 |
+
const isImage = [".jpg", ".jpeg", ".png", ".gif", ".webp"].some((e) => ext.endsWith(e));
|
| 937 |
+
const thumbUrl = isImage ? getOrCreate(uf.file) : null;
|
| 938 |
+
|
| 939 |
return (
|
| 940 |
<div key={key} className="flex items-center justify-between gap-2 rounded-md border px-3 py-2">
|
| 941 |
+
{/* ✅ Thumbnail (only for images) */}
|
| 942 |
+
{isImage ? (
|
| 943 |
+
<div className="h-10 w-10 flex-shrink-0 rounded-lg overflow-hidden border border-border bg-muted">
|
| 944 |
+
{thumbUrl ? (
|
| 945 |
+
<img
|
| 946 |
+
src={thumbUrl}
|
| 947 |
+
alt={uf.file.name}
|
| 948 |
+
className="h-full w-full object-cover"
|
| 949 |
+
draggable={false}
|
| 950 |
+
/>
|
| 951 |
+
) : (
|
| 952 |
+
<div className="h-full w-full flex items-center justify-center">
|
| 953 |
+
<ImageIcon className="h-4 w-4 text-muted-foreground" />
|
| 954 |
+
</div>
|
| 955 |
+
)}
|
| 956 |
</div>
|
| 957 |
+
) : null}
|
| 958 |
+
|
| 959 |
+
<div className="min-w-0 flex-1">
|
| 960 |
+
<div className="truncate text-sm font-medium">{uf.file.name}</div>
|
| 961 |
+
<div className="text-xs text-muted-foreground">{uf.type}</div>
|
| 962 |
</div>
|
| 963 |
|
| 964 |
+
{/* ✅ 原样保留删除逻辑 */}
|
| 965 |
<Button
|
| 966 |
variant="ghost"
|
| 967 |
size="icon"
|
| 968 |
+
onClick={() => onRemoveFile(i)}
|
| 969 |
title="Remove"
|
| 970 |
>
|
| 971 |
<Trash2 className="h-4 w-4" />
|