fix. 슬라이드 이미지 mo 노출되는 현상 수정

This commit is contained in:
clkim
2025-10-22 17:37:23 +09:00
parent 69e46595bc
commit 1d3cd18ada

View File

@@ -1,5 +1,7 @@
<script setup lang="ts">
import type { PageDataResourceGroup } from '#layers/types/api/pageData'
import { getResolvedHost, getColorCode } from '#layers/utils/styleUtil'
import { isTypeImage, isTypeText } from '#layers/utils/dataUtil'
interface Props {
resourcesData?: PageDataResourceGroup
@@ -11,10 +13,18 @@ const props = withDefaults(defineProps<Props>(), {
objectFit: 'contain',
})
const { getCurrentSrc } = useResponsiveSrc()
const imagePaths = computed(() => {
if (!props.resourcesData?.res_path) return null
const imageSrc = computed(() => {
return getCurrentSrc(props.resourcesData?.res_path)
const pcPath =
props.resourcesData.res_path.path_pc || props.resourcesData.res_path.path_mo
const moPath =
props.resourcesData.res_path.path_mo || props.resourcesData.res_path.path_pc
return {
pc: pcPath ? getResolvedHost(pcPath) : '',
mo: moPath ? getResolvedHost(moPath) : '',
}
})
const displayText = computed(() => {
return props.resourcesData?.display?.text || 'image'
@@ -34,13 +44,16 @@ const sanitizedContent = computed(() => {
<template>
<!-- 이미지 -->
<img
v-if="isTypeImage(resourcesData?.resource_type) && imageSrc"
:src="imageSrc"
:alt="alt || displayText"
:class="`w-full h-full object-${objectFit}`"
loading="lazy"
/>
<picture v-if="isTypeImage(resourcesData?.resource_type) && imagePaths">
<source media="(min-width: 1024px)" :srcset="imagePaths.pc" />
<source media="(max-width: 1023px)" :srcset="imagePaths.mo" />
<img
:src="imagePaths.pc"
:alt="alt || displayText"
:class="`w-full h-full object-${objectFit}`"
loading="lazy"
/>
</picture>
<!-- 텍스트 -->
<span
v-else-if="isTypeText(resourcesData?.resource_type)"