enh: prepend image filename with prompt

This commit is contained in:
Timothy J. Baek 2024-09-18 01:04:20 +02:00
parent 63b3076d64
commit 614c219010
2 changed files with 4 additions and 4 deletions

View File

@ -344,7 +344,7 @@
{#each message.files as file} {#each message.files as file}
<div> <div>
{#if file.type === 'image'} {#if file.type === 'image'}
<Image src={file.url} /> <Image src={file.url} alt={message.content} />
{/if} {/if}
</div> </div>
{/each} {/each}

View File

@ -9,14 +9,14 @@
let previewElement = null; let previewElement = null;
const downloadImage = (url, filename) => { const downloadImage = (url, filename, prefixName = '') => {
fetch(url) fetch(url)
.then((response) => response.blob()) .then((response) => response.blob())
.then((blob) => { .then((blob) => {
const objectUrl = window.URL.createObjectURL(blob); const objectUrl = window.URL.createObjectURL(blob);
const link = document.createElement('a'); const link = document.createElement('a');
link.href = objectUrl; link.href = objectUrl;
link.download = filename; link.download = `${prefixName}${filename}`;
document.body.appendChild(link); document.body.appendChild(link);
link.click(); link.click();
document.body.removeChild(link); document.body.removeChild(link);
@ -87,7 +87,7 @@
<button <button
class=" p-5" class=" p-5"
on:click={() => { on:click={() => {
downloadImage(src, src.substring(src.lastIndexOf('/') + 1)); downloadImage(src, src.substring(src.lastIndexOf('/') + 1), alt);
}} }}
> >
<svg <svg