Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -76,12 +76,23 @@ func imageFileMatches(fileName, dim1, dim3 string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
matchesToken := func(token, target string) bool {
|
||||||
|
if token == target {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
// "002" filtresi, dosya adindaki "002_1" gibi varyantlari da yakalamali.
|
||||||
|
if len(target) == 3 && isAllDigits(target) && strings.HasPrefix(token, target+"_") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
hasToken := func(target string) bool {
|
hasToken := func(target string) bool {
|
||||||
if target == "" {
|
if target == "" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
for _, t := range tokens {
|
for _, t := range tokens {
|
||||||
if t == target {
|
if matchesToken(t, target) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -236,52 +247,73 @@ ORDER BY
|
|||||||
}
|
}
|
||||||
|
|
||||||
if dim1Upper != "" || dim3Upper != "" {
|
if dim1Upper != "" || dim3Upper != "" {
|
||||||
targetDimval1 := make(map[string]struct{}, 4)
|
if dim3Upper != "" {
|
||||||
for _, it := range matchedByName {
|
// dim3 verildiginde kesin varyant listesi oncelikli.
|
||||||
if dv := rowDim1ByID[it.ID]; dv != "" {
|
if len(matchedByName) > 0 {
|
||||||
targetDimval1[dv] = struct{}{}
|
items = matchedByName
|
||||||
|
} else if len(matchedByDim) > 0 {
|
||||||
|
items = matchedByDim
|
||||||
|
} else if len(matchedByNameDim1Only) > 0 {
|
||||||
|
// dim3 pattern'i olmayan legacy tek-renk isimlerde dim1-only fallback.
|
||||||
|
hasDim3Pattern := false
|
||||||
|
for _, it := range matchedByNameDim1Only {
|
||||||
|
if imageFileHasDim3Pattern(it.FileName) {
|
||||||
|
hasDim3Pattern = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !hasDim3Pattern {
|
||||||
|
targetDimval1 := make(map[string]struct{}, 4)
|
||||||
|
for _, it := range matchedByNameDim1Only {
|
||||||
|
if dv := rowDim1ByID[it.ID]; dv != "" {
|
||||||
|
targetDimval1[dv] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
clustered := make([]ProductImageItem, 0, len(items))
|
||||||
|
for _, it := range items {
|
||||||
|
if _, ok := targetDimval1[rowDim1ByID[it.ID]]; ok {
|
||||||
|
clustered = append(clustered, it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
items = clustered
|
||||||
|
} else {
|
||||||
|
items = []ProductImageItem{}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
items = []ProductImageItem{}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
if len(targetDimval1) == 0 && dim3Upper == "" {
|
targetDimval1 := make(map[string]struct{}, 4)
|
||||||
for _, it := range matchedByNameDim1Only {
|
for _, it := range matchedByName {
|
||||||
if dv := rowDim1ByID[it.ID]; dv != "" {
|
if dv := rowDim1ByID[it.ID]; dv != "" {
|
||||||
targetDimval1[dv] = struct{}{}
|
targetDimval1[dv] = struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if len(targetDimval1) == 0 {
|
||||||
if len(targetDimval1) == 0 && dim3Upper != "" && len(matchedByNameDim1Only) > 0 {
|
|
||||||
hasDim3Pattern := false
|
|
||||||
for _, it := range matchedByNameDim1Only {
|
|
||||||
if imageFileHasDim3Pattern(it.FileName) {
|
|
||||||
hasDim3Pattern = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !hasDim3Pattern {
|
|
||||||
for _, it := range matchedByNameDim1Only {
|
for _, it := range matchedByNameDim1Only {
|
||||||
if dv := rowDim1ByID[it.ID]; dv != "" {
|
if dv := rowDim1ByID[it.ID]; dv != "" {
|
||||||
targetDimval1[dv] = struct{}{}
|
targetDimval1[dv] = struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if len(targetDimval1) > 0 {
|
if len(targetDimval1) > 0 {
|
||||||
clustered := make([]ProductImageItem, 0, len(items))
|
clustered := make([]ProductImageItem, 0, len(items))
|
||||||
for _, it := range items {
|
for _, it := range items {
|
||||||
if _, ok := targetDimval1[rowDim1ByID[it.ID]]; ok {
|
if _, ok := targetDimval1[rowDim1ByID[it.ID]]; ok {
|
||||||
clustered = append(clustered, it)
|
clustered = append(clustered, it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
items = clustered
|
||||||
|
} else if len(matchedByDim) > 0 {
|
||||||
|
items = matchedByDim
|
||||||
|
} else if len(matchedByName) > 0 {
|
||||||
|
items = matchedByName
|
||||||
|
} else if len(matchedByNameDim1Only) > 0 {
|
||||||
|
items = matchedByNameDim1Only
|
||||||
|
} else {
|
||||||
|
items = []ProductImageItem{}
|
||||||
}
|
}
|
||||||
items = clustered
|
|
||||||
} else if len(matchedByDim) > 0 {
|
|
||||||
items = matchedByDim
|
|
||||||
} else if len(matchedByName) > 0 {
|
|
||||||
items = matchedByName
|
|
||||||
} else if dim3Upper == "" && len(matchedByNameDim1Only) > 0 {
|
|
||||||
items = matchedByNameDim1Only
|
|
||||||
} else {
|
|
||||||
items = []ProductImageItem{}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -539,6 +539,25 @@ function resolveProductImageUrl(item) {
|
|||||||
return { contentUrl, publicUrl }
|
return { contentUrl, publicUrl }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function resolveProductImageUrlForCarousel(item) {
|
||||||
|
const resolved = resolveProductImageUrl(item)
|
||||||
|
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 String(resolved.publicUrl || contentUrl || '').trim()
|
||||||
|
}
|
||||||
|
|
||||||
function getProductImageUrl(code, color, secondColor = '') {
|
function getProductImageUrl(code, color, secondColor = '') {
|
||||||
const key = buildImageKey(code, color, secondColor)
|
const key = buildImageKey(code, color, secondColor)
|
||||||
const existing = productImageCache.value[key]
|
const existing = productImageCache.value[key]
|
||||||
@@ -1073,12 +1092,10 @@ async function openProductCard(grp1, grp2) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const images = list
|
const imageCandidates = await Promise.all(
|
||||||
.map((item) => {
|
list.map((item) => resolveProductImageUrlForCarousel(item))
|
||||||
const resolved = resolveProductImageUrl(item)
|
)
|
||||||
return resolved.publicUrl || resolved.contentUrl || ''
|
const images = imageCandidates.filter((x) => String(x || '').trim() !== '')
|
||||||
})
|
|
||||||
.filter((x) => String(x || '').trim() !== '')
|
|
||||||
const uniqueImages = Array.from(new Set(images))
|
const uniqueImages = Array.from(new Set(images))
|
||||||
|
|
||||||
if (!uniqueImages.length) {
|
if (!uniqueImages.length) {
|
||||||
|
|||||||
@@ -526,6 +526,25 @@ function resolveProductImageUrl(item) {
|
|||||||
return { contentUrl, publicUrl }
|
return { contentUrl, publicUrl }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function resolveProductImageUrlForCarousel(item) {
|
||||||
|
const resolved = resolveProductImageUrl(item)
|
||||||
|
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 String(resolved.publicUrl || contentUrl || '').trim()
|
||||||
|
}
|
||||||
|
|
||||||
function getProductImageUrl(code, color, secondColor = '') {
|
function getProductImageUrl(code, color, secondColor = '') {
|
||||||
const key = buildImageKey(code, color, secondColor)
|
const key = buildImageKey(code, color, secondColor)
|
||||||
const existing = productImageCache.value[key]
|
const existing = productImageCache.value[key]
|
||||||
@@ -945,12 +964,10 @@ async function openProductCard(grp1, grp2) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const images = list
|
const imageCandidates = await Promise.all(
|
||||||
.map((item) => {
|
list.map((item) => resolveProductImageUrlForCarousel(item))
|
||||||
const resolved = resolveProductImageUrl(item)
|
)
|
||||||
return resolved.publicUrl || resolved.contentUrl || ''
|
const images = imageCandidates.filter((x) => String(x || '').trim() !== '')
|
||||||
})
|
|
||||||
.filter((x) => String(x || '').trim() !== '')
|
|
||||||
const uniqueImages = Array.from(new Set(images))
|
const uniqueImages = Array.from(new Set(images))
|
||||||
|
|
||||||
if (!uniqueImages.length) {
|
if (!uniqueImages.length) {
|
||||||
|
|||||||
Reference in New Issue
Block a user