Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -275,7 +275,6 @@
|
|||||||
arrows
|
arrows
|
||||||
height="100%"
|
height="100%"
|
||||||
class="product-card-carousel rounded-borders"
|
class="product-card-carousel rounded-borders"
|
||||||
@update:model-value="onProductCardSlideChange"
|
|
||||||
>
|
>
|
||||||
<q-carousel-slide
|
<q-carousel-slide
|
||||||
v-for="(img, idx) in productCardImages"
|
v-for="(img, idx) in productCardImages"
|
||||||
@@ -666,39 +665,6 @@ function sortImagesForDisplay(list) {
|
|||||||
return Array.isArray(list) ? [...list] : []
|
return Array.isArray(list) ? [...list] : []
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseGalleryHashIndex() {
|
|
||||||
if (typeof window === 'undefined') return 0
|
|
||||||
const hash = String(window.location?.hash || '').trim()
|
|
||||||
const m = hash.match(/^#([a-z0-9_-]+)-(\d+)$/i)
|
|
||||||
if (!m) return 0
|
|
||||||
const group = String(m[1] || '').toLowerCase()
|
|
||||||
if (group !== 'gallery') return 0
|
|
||||||
const n = Number(m[2] || 1)
|
|
||||||
if (!Number.isFinite(n) || n < 1) return 0
|
|
||||||
return n - 1
|
|
||||||
}
|
|
||||||
|
|
||||||
function setGalleryHashIndex(idx) {
|
|
||||||
if (typeof window === 'undefined') return
|
|
||||||
const n = Math.max(1, Number(idx || 0) + 1)
|
|
||||||
const targetHash = `#gallery-${n}`
|
|
||||||
if (window.location.hash === targetHash) return
|
|
||||||
const url = `${window.location.pathname}${window.location.search}${targetHash}`
|
|
||||||
window.history.replaceState(null, '', url)
|
|
||||||
}
|
|
||||||
|
|
||||||
function applyGalleryHashIndex() {
|
|
||||||
const idx = parseGalleryHashIndex()
|
|
||||||
const maxCard = Math.max(productCardImages.value.length - 1, 0)
|
|
||||||
if (productCardDialog.value && productCardImages.value.length) {
|
|
||||||
productCardSlide.value = Math.min(Math.max(idx, 0), maxCard)
|
|
||||||
}
|
|
||||||
const maxFull = Math.max(fullscreenImages.value.length - 1, 0)
|
|
||||||
if (productImageFullscreenDialog.value && fullscreenImages.value.length) {
|
|
||||||
productImageFullscreenSlide.value = Math.min(Math.max(idx, 0), maxFull)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function resolveProductImageUrlForCarousel(item) {
|
async function resolveProductImageUrlForCarousel(item) {
|
||||||
const resolved = resolveProductImageUrl(item)
|
const resolved = resolveProductImageUrl(item)
|
||||||
const contentUrl = String(resolved.contentUrl || '').trim()
|
const contentUrl = String(resolved.contentUrl || '').trim()
|
||||||
@@ -1354,9 +1320,7 @@ async function openProductCard(grp1, grp2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
productCardImages.value = uniqueImages
|
productCardImages.value = uniqueImages
|
||||||
const hashIndex = parseGalleryHashIndex()
|
productCardSlide.value = 0
|
||||||
productCardSlide.value = Math.min(Math.max(hashIndex, 0), Math.max(uniqueImages.length - 1, 0))
|
|
||||||
setGalleryHashIndex(productCardSlide.value)
|
|
||||||
productCardData.value = {
|
productCardData.value = {
|
||||||
productCode,
|
productCode,
|
||||||
colorCode,
|
colorCode,
|
||||||
@@ -1381,7 +1345,6 @@ function openProductImageFullscreen(src) {
|
|||||||
productImageFullscreenSrc.value = value
|
productImageFullscreenSrc.value = value
|
||||||
const idx = Math.max(0, fullscreenImages.value.findIndex((x) => String(x || '').trim() === value))
|
const idx = Math.max(0, fullscreenImages.value.findIndex((x) => String(x || '').trim() === value))
|
||||||
productImageFullscreenSlide.value = idx
|
productImageFullscreenSlide.value = idx
|
||||||
setGalleryHashIndex(idx)
|
|
||||||
productImageFullscreenZoom.value = 1
|
productImageFullscreenZoom.value = 1
|
||||||
productImageFullscreenOffsetX.value = 0
|
productImageFullscreenOffsetX.value = 0
|
||||||
productImageFullscreenOffsetY.value = 0
|
productImageFullscreenOffsetY.value = 0
|
||||||
@@ -1440,17 +1403,12 @@ function onFullscreenMouseUp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onFullscreenSlideChange() {
|
function onFullscreenSlideChange() {
|
||||||
setGalleryHashIndex(productImageFullscreenSlide.value)
|
|
||||||
productImageFullscreenZoom.value = 1
|
productImageFullscreenZoom.value = 1
|
||||||
productImageFullscreenOffsetX.value = 0
|
productImageFullscreenOffsetX.value = 0
|
||||||
productImageFullscreenOffsetY.value = 0
|
productImageFullscreenOffsetY.value = 0
|
||||||
productImageFullscreenDragging.value = false
|
productImageFullscreenDragging.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
function onProductCardSlideChange() {
|
|
||||||
setGalleryHashIndex(productCardSlide.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetForm() {
|
function resetForm() {
|
||||||
filters.value = createEmptyFilters()
|
filters.value = createEmptyFilters()
|
||||||
rawRows.value = []
|
rawRows.value = []
|
||||||
@@ -1483,14 +1441,11 @@ onMounted(() => {
|
|||||||
void loadFilterOptions(true)
|
void loadFilterOptions(true)
|
||||||
window.addEventListener('mousemove', onFullscreenMouseMove)
|
window.addEventListener('mousemove', onFullscreenMouseMove)
|
||||||
window.addEventListener('mouseup', onFullscreenMouseUp)
|
window.addEventListener('mouseup', onFullscreenMouseUp)
|
||||||
window.addEventListener('hashchange', applyGalleryHashIndex)
|
|
||||||
applyGalleryHashIndex()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
window.removeEventListener('mousemove', onFullscreenMouseMove)
|
window.removeEventListener('mousemove', onFullscreenMouseMove)
|
||||||
window.removeEventListener('mouseup', onFullscreenMouseUp)
|
window.removeEventListener('mouseup', onFullscreenMouseUp)
|
||||||
window.removeEventListener('hashchange', applyGalleryHashIndex)
|
|
||||||
if (filterOptionsDebounceTimer) {
|
if (filterOptionsDebounceTimer) {
|
||||||
clearTimeout(filterOptionsDebounceTimer)
|
clearTimeout(filterOptionsDebounceTimer)
|
||||||
filterOptionsDebounceTimer = null
|
filterOptionsDebounceTimer = null
|
||||||
|
|||||||
@@ -260,7 +260,6 @@
|
|||||||
arrows
|
arrows
|
||||||
height="100%"
|
height="100%"
|
||||||
class="product-card-carousel rounded-borders"
|
class="product-card-carousel rounded-borders"
|
||||||
@update:model-value="onProductCardSlideChange"
|
|
||||||
>
|
>
|
||||||
<q-carousel-slide
|
<q-carousel-slide
|
||||||
v-for="(img, idx) in productCardImages"
|
v-for="(img, idx) in productCardImages"
|
||||||
@@ -645,39 +644,6 @@ function sortImagesForDisplay(list) {
|
|||||||
return Array.isArray(list) ? [...list] : []
|
return Array.isArray(list) ? [...list] : []
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseGalleryHashIndex() {
|
|
||||||
if (typeof window === 'undefined') return 0
|
|
||||||
const hash = String(window.location?.hash || '').trim()
|
|
||||||
const m = hash.match(/^#([a-z0-9_-]+)-(\d+)$/i)
|
|
||||||
if (!m) return 0
|
|
||||||
const group = String(m[1] || '').toLowerCase()
|
|
||||||
if (group !== 'gallery') return 0
|
|
||||||
const n = Number(m[2] || 1)
|
|
||||||
if (!Number.isFinite(n) || n < 1) return 0
|
|
||||||
return n - 1
|
|
||||||
}
|
|
||||||
|
|
||||||
function setGalleryHashIndex(idx) {
|
|
||||||
if (typeof window === 'undefined') return
|
|
||||||
const n = Math.max(1, Number(idx || 0) + 1)
|
|
||||||
const targetHash = `#gallery-${n}`
|
|
||||||
if (window.location.hash === targetHash) return
|
|
||||||
const url = `${window.location.pathname}${window.location.search}${targetHash}`
|
|
||||||
window.history.replaceState(null, '', url)
|
|
||||||
}
|
|
||||||
|
|
||||||
function applyGalleryHashIndex() {
|
|
||||||
const idx = parseGalleryHashIndex()
|
|
||||||
const maxCard = Math.max(productCardImages.value.length - 1, 0)
|
|
||||||
if (productCardDialog.value && productCardImages.value.length) {
|
|
||||||
productCardSlide.value = Math.min(Math.max(idx, 0), maxCard)
|
|
||||||
}
|
|
||||||
const maxFull = Math.max(fullscreenImages.value.length - 1, 0)
|
|
||||||
if (productImageFullscreenDialog.value && fullscreenImages.value.length) {
|
|
||||||
productImageFullscreenSlide.value = Math.min(Math.max(idx, 0), maxFull)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function resolveProductImageUrlForCarousel(item) {
|
async function resolveProductImageUrlForCarousel(item) {
|
||||||
const resolved = resolveProductImageUrl(item)
|
const resolved = resolveProductImageUrl(item)
|
||||||
const contentUrl = String(resolved.contentUrl || '').trim()
|
const contentUrl = String(resolved.contentUrl || '').trim()
|
||||||
@@ -1164,9 +1130,7 @@ async function openProductCard(grp1, grp2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
productCardImages.value = uniqueImages
|
productCardImages.value = uniqueImages
|
||||||
const hashIndex = parseGalleryHashIndex()
|
productCardSlide.value = 0
|
||||||
productCardSlide.value = Math.min(Math.max(hashIndex, 0), Math.max(uniqueImages.length - 1, 0))
|
|
||||||
setGalleryHashIndex(productCardSlide.value)
|
|
||||||
productCardData.value = {
|
productCardData.value = {
|
||||||
productCode,
|
productCode,
|
||||||
colorCode,
|
colorCode,
|
||||||
@@ -1191,7 +1155,6 @@ function openProductImageFullscreen(src) {
|
|||||||
productImageFullscreenSrc.value = value
|
productImageFullscreenSrc.value = value
|
||||||
const idx = Math.max(0, fullscreenImages.value.findIndex((x) => String(x || '').trim() === value))
|
const idx = Math.max(0, fullscreenImages.value.findIndex((x) => String(x || '').trim() === value))
|
||||||
productImageFullscreenSlide.value = idx
|
productImageFullscreenSlide.value = idx
|
||||||
setGalleryHashIndex(idx)
|
|
||||||
productImageFullscreenZoom.value = 1
|
productImageFullscreenZoom.value = 1
|
||||||
productImageFullscreenOffsetX.value = 0
|
productImageFullscreenOffsetX.value = 0
|
||||||
productImageFullscreenOffsetY.value = 0
|
productImageFullscreenOffsetY.value = 0
|
||||||
@@ -1250,17 +1213,12 @@ function onFullscreenMouseUp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onFullscreenSlideChange() {
|
function onFullscreenSlideChange() {
|
||||||
setGalleryHashIndex(productImageFullscreenSlide.value)
|
|
||||||
productImageFullscreenZoom.value = 1
|
productImageFullscreenZoom.value = 1
|
||||||
productImageFullscreenOffsetX.value = 0
|
productImageFullscreenOffsetX.value = 0
|
||||||
productImageFullscreenOffsetY.value = 0
|
productImageFullscreenOffsetY.value = 0
|
||||||
productImageFullscreenDragging.value = false
|
productImageFullscreenDragging.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
function onProductCardSlideChange() {
|
|
||||||
setGalleryHashIndex(productCardSlide.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetForm() {
|
function resetForm() {
|
||||||
selectedProductCode.value = ''
|
selectedProductCode.value = ''
|
||||||
rawRows.value = []
|
rawRows.value = []
|
||||||
@@ -1290,7 +1248,6 @@ function resetForm() {
|
|||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
window.removeEventListener('mousemove', onFullscreenMouseMove)
|
window.removeEventListener('mousemove', onFullscreenMouseMove)
|
||||||
window.removeEventListener('mouseup', onFullscreenMouseUp)
|
window.removeEventListener('mouseup', onFullscreenMouseUp)
|
||||||
window.removeEventListener('hashchange', applyGalleryHashIndex)
|
|
||||||
for (const url of productImageBlobUrls.value) {
|
for (const url of productImageBlobUrls.value) {
|
||||||
try { URL.revokeObjectURL(url) } catch {}
|
try { URL.revokeObjectURL(url) } catch {}
|
||||||
}
|
}
|
||||||
@@ -1301,8 +1258,6 @@ onMounted(() => {
|
|||||||
loadProductOptions()
|
loadProductOptions()
|
||||||
window.addEventListener('mousemove', onFullscreenMouseMove)
|
window.addEventListener('mousemove', onFullscreenMouseMove)
|
||||||
window.addEventListener('mouseup', onFullscreenMouseUp)
|
window.addEventListener('mouseup', onFullscreenMouseUp)
|
||||||
window.addEventListener('hashchange', applyGalleryHashIndex)
|
|
||||||
applyGalleryHashIndex()
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user