get image update
This commit is contained in:
parent
51436141a4
commit
339abe4c84
2 changed files with 28 additions and 12 deletions
|
|
@ -15,22 +15,29 @@ const fileList = ref([])
|
|||
|
||||
onMounted(async () => {
|
||||
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 = [
|
||||
{
|
||||
name: 'full.jpg',
|
||||
name: 'thumbnail.jpg',
|
||||
url: imgUrl,
|
||||
status: 'finished',
|
||||
},
|
||||
]
|
||||
} catch (error) {
|
||||
fileList.value = []
|
||||
if (!error.message?.includes('404')) {
|
||||
console.error('Error getting image: ', error)
|
||||
if (!error.message.includes('404')) {
|
||||
console.error('Error getting thumbnail: ', error)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
|||
|
|
@ -77,21 +77,29 @@ async function handleUpload({ fileList: newFileList }) {
|
|||
|
||||
onMounted(async () => {
|
||||
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 = [
|
||||
{
|
||||
name: 'full.jpg',
|
||||
url: imgUrl,
|
||||
status: 'finished',
|
||||
},
|
||||
]
|
||||
];
|
||||
} catch (error) {
|
||||
fileList.value = []
|
||||
if (!error.message?.includes('404')) {
|
||||
console.error('Error getting image: ', error)
|
||||
fileList.value = [];
|
||||
if (!error.message.includes('404')) {
|
||||
console.error('Error getting image: ', error);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
const showConfirmDelete = ref(false)
|
||||
|
||||
|
|
@ -207,7 +215,8 @@ const cancelDelete = () => {
|
|||
|
||||
.preview-container {
|
||||
display: block;
|
||||
width: 100%;
|
||||
width: 50%;
|
||||
min-width: 250px;
|
||||
max-width: 400px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue