SarahXia0405 commited on
Commit
95d3cb3
·
verified ·
1 Parent(s): 8e91a82

Update web/src/components/ChatArea.tsx

Browse files
Files changed (1) hide show
  1. web/src/components/ChatArea.tsx +26 -6
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
- <div className="min-w-0">
938
- <div className="truncate text-sm font-medium">{uf.file.name}</div>
939
- <div className="text-xs text-muted-foreground">
940
- {uf.type}
 
 
 
 
 
 
 
 
 
 
 
941
  </div>
 
 
 
 
 
942
  </div>
943
 
944
- {/* 垃圾桶:直接删 props(UI + state 同步删) */}
945
  <Button
946
  variant="ghost"
947
  size="icon"
948
- onClick={() => onRemoveFile(i)} // 或者 onRemoveFile(uf) 也行(因为 App 现在兼容了)
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" />