fix. 컴포넌트 리팩토링, 타입 명시적 적용
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user