get image update

This commit is contained in:
nquidox 2025-10-26 21:33:06 +03:00
parent 51436141a4
commit 339abe4c84
2 changed files with 28 additions and 12 deletions

View file

@ -15,22 +15,29 @@ const fileList = ref([])
onMounted(async () => { onMounted(async () => {
try { try {
const imgUrl = await getImageUrl(props.merch.merch_uuid, 'thumbnail') const imgUrl = getImageUrl(props.merch.merch_uuid, 'thumbnail')
await new Promise((resolve, reject) => {
const img = new Image()
img.src = imgUrl
img.onload = () => resolve(imgUrl)
img.onerror = () => reject(new Error('Image not found'))
})
fileList.value = [ fileList.value = [
{ {
name: 'full.jpg', name: 'thumbnail.jpg',
url: imgUrl, url: imgUrl,
status: 'finished', status: 'finished',
}, },
] ]
} catch (error) { } catch (error) {
fileList.value = [] fileList.value = []
if (!error.message?.includes('404')) { if (!error.message.includes('404')) {
console.error('Error getting image: ', error) console.error('Error getting thumbnail: ', error)
} }
} }
}) })
</script> </script>
<template> <template>

View file

@ -77,21 +77,29 @@ async function handleUpload({ fileList: newFileList }) {
onMounted(async () => { onMounted(async () => {
try { try {
const imgUrl = await getImageUrl(props.merchUuid, 'full') const imgUrl = getImageUrl(props.merchUuid, 'full');
await new Promise((resolve, reject) => {
const img = new Image();
img.src = imgUrl;
img.onload = () => resolve(imgUrl);
img.onerror = () => reject(new Error('Image not found'));
});
fileList.value = [ fileList.value = [
{ {
name: 'full.jpg', name: 'full.jpg',
url: imgUrl, url: imgUrl,
status: 'finished', status: 'finished',
}, },
] ];
} catch (error) { } catch (error) {
fileList.value = [] fileList.value = [];
if (!error.message?.includes('404')) { if (!error.message.includes('404')) {
console.error('Error getting image: ', error) console.error('Error getting image: ', error);
} }
} }
}) });
const showConfirmDelete = ref(false) const showConfirmDelete = ref(false)
@ -207,7 +215,8 @@ const cancelDelete = () => {
.preview-container { .preview-container {
display: block; display: block;
width: 100%; width: 50%;
min-width: 250px;
max-width: 400px; max-width: 400px;
margin: 0 auto; margin: 0 auto;
} }