Fix product performance grouped JSON build
This commit is contained in:
@@ -423,7 +423,6 @@ const productImageListByCode = ref({})
|
||||
const productImageListLoading = ref({})
|
||||
const productImageFallbackByKey = ref({})
|
||||
const productImageContentLoading = ref({})
|
||||
const productImageBlobUrls = ref([])
|
||||
const productImageListBlockedUntil = ref(0)
|
||||
const productCardDialog = ref(false)
|
||||
const productCardData = ref({})
|
||||
@@ -702,24 +701,13 @@ function clearGalleryQueryIndex() {
|
||||
|
||||
async function resolveProductImageUrlForCarousel(item) {
|
||||
const resolved = resolveProductImageUrl(item)
|
||||
const contentUrl = String(resolved.contentUrl || '').trim()
|
||||
if (contentUrl) return contentUrl
|
||||
|
||||
const directUrl = String(resolved.fullUrl || resolved.thumbUrl || resolved.publicUrl || '').trim()
|
||||
if (directUrl) return directUrl
|
||||
|
||||
const contentUrl = String(resolved.contentUrl || '').trim()
|
||||
if (contentUrl) {
|
||||
try {
|
||||
const blobRes = await api.get(contentUrl, { baseURL: '', responseType: 'blob' })
|
||||
const blob = blobRes?.data
|
||||
if (blob instanceof Blob) {
|
||||
const objectUrl = URL.createObjectURL(blob)
|
||||
productImageBlobUrls.value.push(objectUrl)
|
||||
return objectUrl
|
||||
}
|
||||
} catch {
|
||||
// fall through to public url
|
||||
}
|
||||
}
|
||||
return contentUrl
|
||||
return ''
|
||||
}
|
||||
|
||||
function getProductImageUrl(code, color, secondColor = '', dim1Id = '', dim3Id = '') {
|
||||
@@ -769,9 +757,9 @@ async function flushProductImageBatch() {
|
||||
const list = Array.isArray(item.images) ? item.images : []
|
||||
const first = list[0] || null
|
||||
const resolved = resolveProductImageUrl(first)
|
||||
const url = resolved.thumbUrl || resolved.fullUrl || resolved.publicUrl || resolved.contentUrl || ''
|
||||
const url = resolved.contentUrl || resolved.thumbUrl || resolved.fullUrl || resolved.publicUrl || ''
|
||||
productImageCache.value[key] = String(url || '').trim()
|
||||
productImageFallbackByKey.value[key] = resolved.fullUrl || resolved.publicUrl || resolved.contentUrl || ''
|
||||
productImageFallbackByKey.value[key] = resolved.thumbUrl || resolved.fullUrl || resolved.publicUrl || ''
|
||||
if (queued) productImageListByCode.value[queued.listKey] = list
|
||||
delete productImageLoading.value[key]
|
||||
}
|
||||
@@ -860,11 +848,11 @@ async function ensureProductImage(code, color, secondColor = '', dim1Id = '', di
|
||||
|
||||
productImageCache.value[key] = String(
|
||||
preferredCardUrl ||
|
||||
primaryResolved.fullUrl || primaryResolved.publicUrl || primaryResolved.thumbUrl || primaryResolved.contentUrl ||
|
||||
secondaryResolved.fullUrl || secondaryResolved.publicUrl || secondaryResolved.thumbUrl || secondaryResolved.contentUrl ||
|
||||
primaryResolved.contentUrl || primaryResolved.fullUrl || primaryResolved.publicUrl || primaryResolved.thumbUrl ||
|
||||
secondaryResolved.contentUrl || secondaryResolved.fullUrl || secondaryResolved.publicUrl || secondaryResolved.thumbUrl ||
|
||||
''
|
||||
).trim()
|
||||
productImageFallbackByKey.value[key] = primaryResolved.fullUrl || primaryResolved.publicUrl || primaryResolved.contentUrl || secondaryResolved.fullUrl || secondaryResolved.publicUrl || secondaryResolved.contentUrl || ''
|
||||
productImageFallbackByKey.value[key] = primaryResolved.fullUrl || primaryResolved.publicUrl || primaryResolved.thumbUrl || secondaryResolved.fullUrl || secondaryResolved.publicUrl || secondaryResolved.thumbUrl || ''
|
||||
} catch (err) {
|
||||
console.warn('[ProductStockByAttributes] product image fetch failed', { code, color, err })
|
||||
productImageCache.value[key] = ''
|
||||
@@ -1576,10 +1564,6 @@ onUnmounted(() => {
|
||||
clearTimeout(filterOptionsDebounceTimer)
|
||||
filterOptionsDebounceTimer = null
|
||||
}
|
||||
for (const url of productImageBlobUrls.value) {
|
||||
try { URL.revokeObjectURL(url) } catch {}
|
||||
}
|
||||
productImageBlobUrls.value = []
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user