fix. 컴포넌트 리팩토링, 타입 명시적 적용

This commit is contained in:
clkim
2025-09-17 15:43:47 +09:00
parent d9c26e651d
commit 4f3ac0e84a
13 changed files with 57 additions and 65 deletions

View File

@@ -1,9 +1,12 @@
<script setup lang="ts">
interface ImageSource {
mobileSrc?: string
pcSrc?: string
}
interface Props {
tag: string
text?: string
imageSrc?: any
imageClass?: string
imageSrc?: ImageSource
}
const props = defineProps<Props>()
@@ -14,23 +17,21 @@ const sanitizedContent = computed(() => {
</script>
<template>
<component :is="tag" v-bind="$attrs">
<template v-if="imageSrc && 'mobileSrc' in imageSrc">
<!-- 모바일 이미지 (sm 미만) -->
<img
v-if="imageSrc.mobileSrc"
:src="imageSrc.mobileSrc"
:alt="text"
:class="`${props.imageClass} sm:hidden`"
/>
<!-- PC 이미지 (sm 이상) -->
<img
v-if="imageSrc.pcSrc"
:src="imageSrc.pcSrc"
:alt="text"
:class="`${props.imageClass} hidden sm:block`"
/>
</template>
<span v-else-if="text" v-dompurify-html="sanitizedContent" />
</component>
<template v-if="imageSrc && 'mobileSrc' in imageSrc">
<!-- 모바일 이미지 (sm 미만) -->
<img
v-if="imageSrc.mobileSrc"
:src="imageSrc.mobileSrc"
:alt="text"
class="sm:hidden w-full h-full object-contain"
/>
<!-- PC 이미지 (sm 이상) -->
<img
v-if="imageSrc.pcSrc"
:src="imageSrc.pcSrc"
:alt="text"
class="hidden sm:block w-full h-full object-contain"
/>
</template>
<span v-else-if="text" v-dompurify-html="sanitizedContent" />
</template>