|
1 | 1 | <script lang="ts"> |
2 | 2 | import { getContext } from 'svelte'; |
3 | 3 | import Tooltip from '$lib/components/common/Tooltip.svelte'; |
| 4 | + import Image from '$lib/components/common/Image.svelte'; |
4 | 5 | import GarbageBin from '$lib/components/icons/GarbageBin.svelte'; |
5 | 6 | import EditPencil from '$lib/components/icons/EditPencil.svelte'; |
6 | 7 | import ArrowForward from '$lib/components/icons/ArrowForward.svelte'; |
| 8 | + import { WEBUI_API_BASE_URL } from '$lib/constants'; |
7 | 9 |
|
8 | 10 | const i18n = getContext('i18n'); |
9 | 11 |
|
10 | 12 | export let id: string; |
11 | 13 | export let content: string; |
| 14 | + export let files: any[] = []; |
12 | 15 | export let onSendNow: (id: string) => void; |
13 | 16 | export let onEdit: (id: string) => void; |
14 | 17 | export let onDelete: (id: string) => void; |
|
21 | 24 | </div> |
22 | 25 |
|
23 | 26 | <!-- Message content --> |
24 | | - <div class="flex-1 min-w-0"> |
25 | | - <p class="text-sm text-gray-600 dark:text-gray-300 truncate">{content}</p> |
| 27 | + <div class="flex-1 min-w-0 flex items-center gap-2"> |
| 28 | + {#if files.length > 0} |
| 29 | + <div class="flex items-center gap-1 shrink-0"> |
| 30 | + {#each files as file} |
| 31 | + {#if file.type === 'image' || (file?.content_type ?? '').startsWith('image/')} |
| 32 | + {@const fileUrl = |
| 33 | + file.url?.startsWith('data') || file.url?.startsWith('http') |
| 34 | + ? file.url |
| 35 | + : `${WEBUI_API_BASE_URL}/files/${file.url}${file?.content_type ? '/content' : ''}`} |
| 36 | + <Image |
| 37 | + src={fileUrl} |
| 38 | + alt="" |
| 39 | + imageClassName="size-6 rounded-md object-cover" |
| 40 | + /> |
| 41 | + {:else} |
| 42 | + <div class="flex items-center px-1.5 py-0.5 rounded-md bg-gray-100 dark:bg-gray-800 text-xs text-gray-500 dark:text-gray-400"> |
| 43 | + <span class="max-w-[80px] truncate">{file.name ?? 'file'}</span> |
| 44 | + </div> |
| 45 | + {/if} |
| 46 | + {/each} |
| 47 | + </div> |
| 48 | + {/if} |
| 49 | + |
| 50 | + {#if content} |
| 51 | + <p class="text-sm text-gray-600 dark:text-gray-300 truncate">{content}</p> |
| 52 | + {:else if files.length === 0} |
| 53 | + <p class="text-sm text-gray-400 dark:text-gray-500 truncate italic">{$i18n.t('Empty message')}</p> |
| 54 | + {/if} |
26 | 55 | </div> |
27 | 56 |
|
28 | 57 | <!-- Actions --> |
|
0 commit comments