feat. getResolvedHost 함수 추가, img 컴포넌트 추가
This commit is contained in:
@@ -49,9 +49,6 @@ const componentTag = computed(() => {
|
|||||||
const isDuplication = computed(() => props.type === 'duplication')
|
const isDuplication = computed(() => props.type === 'duplication')
|
||||||
const isSingle = computed(() => props.type === 'single')
|
const isSingle = computed(() => props.type === 'single')
|
||||||
const platformIcon = computed(() => PLATFORM_ICON_MAP[props.platform])
|
const platformIcon = computed(() => PLATFORM_ICON_MAP[props.platform])
|
||||||
const duplicationImage = computed(() =>
|
|
||||||
isDuplication.value ? DUP_IMAGE_MAP[props.platform] : ''
|
|
||||||
)
|
|
||||||
|
|
||||||
const inlineStyle = computed<CSSProperties>(() => {
|
const inlineStyle = computed<CSSProperties>(() => {
|
||||||
const style: CSSProperties = {}
|
const style: CSSProperties = {}
|
||||||
@@ -63,7 +60,7 @@ const inlineStyle = computed<CSSProperties>(() => {
|
|||||||
style.color = props.textColor
|
style.color = props.textColor
|
||||||
}
|
}
|
||||||
if (props.type === 'duplication') {
|
if (props.type === 'duplication') {
|
||||||
style.backgroundImage = `url(${duplicationImage.value})`
|
style.backgroundImage = `url(${getImageHost(DUP_IMAGE_MAP[props.platform])})`
|
||||||
}
|
}
|
||||||
return style
|
return style
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ const handleCopy = async () => {
|
|||||||
target="_blank"
|
target="_blank"
|
||||||
class="sns-item"
|
class="sns-item"
|
||||||
:style="{
|
:style="{
|
||||||
backgroundImage: `url(/images/common/ic-v2-logo-${key}-fill.svg)`,
|
backgroundImage: `url(${getImageHost(`/images/common/ic-v2-logo-${key}-fill.svg`)})`,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<span class="sr-only">{{ key }}</span>
|
<span class="sr-only">{{ key }}</span>
|
||||||
@@ -87,7 +87,7 @@ const handleCopy = async () => {
|
|||||||
type="button"
|
type="button"
|
||||||
class="sns-item"
|
class="sns-item"
|
||||||
:style="{
|
:style="{
|
||||||
backgroundImage: `url(/images/common/ic-v2-community-link-line.svg)`,
|
backgroundImage: `url(${getImageHost('/images/common/ic-v2-community-link-line.svg')})`,
|
||||||
}"
|
}"
|
||||||
@click="handleCopy"
|
@click="handleCopy"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,38 +1,45 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getResolvedHost } from '#layers/utils/styleUtil'
|
import { getResolvedHost } from '#layers/utils/styleUtil'
|
||||||
import type { PageDataResourceGroup } from '#layers/types/api/pageData'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
resourcesData?: PageDataResourceGroup
|
src: {
|
||||||
objectFit?: 'contain' | 'cover'
|
pc?: string
|
||||||
|
mo?: string
|
||||||
|
}
|
||||||
alt?: string
|
alt?: string
|
||||||
|
objectFit?: 'contain' | 'cover'
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
objectFit: 'contain',
|
|
||||||
alt: 'image',
|
alt: 'image',
|
||||||
|
objectFit: 'contain',
|
||||||
})
|
})
|
||||||
|
|
||||||
const imagePaths = computed(() => {
|
const isDev = process.env.NODE_ENV === 'development'
|
||||||
if (!props.resourcesData?.res_path) return null
|
const rootPath = isDev ? '' : '/templates/brand'
|
||||||
|
|
||||||
const pc =
|
const imagePaths = computed(() => {
|
||||||
props.resourcesData.res_path.path_pc ?? props.resourcesData.res_path.path_mo
|
|
||||||
const mo =
|
|
||||||
props.resourcesData.res_path.path_mo ?? props.resourcesData.res_path.path_pc
|
|
||||||
return {
|
return {
|
||||||
pc: pc ? getResolvedHost(pc) : '',
|
pc: props.src.pc ? getResolvedHost(`${rootPath}${props.src.pc}`) : '',
|
||||||
mo: mo ? getResolvedHost(mo) : '',
|
mo: props.src.mo ? getResolvedHost(`${rootPath}${props.src.mo}`) : '',
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<picture v-if="imagePaths" ref="pictureRef">
|
<picture v-if="imagePaths" ref="pictureRef">
|
||||||
<source media="(min-width: 1024px)" :srcset="imagePaths.pc" />
|
<source
|
||||||
<source media="(max-width: 1023px)" :srcset="imagePaths.mo" />
|
v-if="imagePaths.pc"
|
||||||
|
media="(min-width: 1024px)"
|
||||||
|
:srcset="imagePaths.pc"
|
||||||
|
/>
|
||||||
|
<source
|
||||||
|
v-if="imagePaths.mo"
|
||||||
|
media="(max-width: 1023px)"
|
||||||
|
:srcset="imagePaths.mo"
|
||||||
|
/>
|
||||||
<img
|
<img
|
||||||
:src="imagePaths.pc"
|
:src="imagePaths.pc || imagePaths.mo"
|
||||||
:alt="alt"
|
:alt="alt"
|
||||||
:class="`w-full h-full object-${objectFit}`"
|
:class="`w-full h-full object-${objectFit}`"
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
|
|||||||
41
layers/components/atoms/ResourcesImg.vue
Normal file
41
layers/components/atoms/ResourcesImg.vue
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { getResolvedHost } from '#layers/utils/styleUtil'
|
||||||
|
import type { PageDataResourceGroup } from '#layers/types/api/pageData'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
resourcesData?: PageDataResourceGroup
|
||||||
|
objectFit?: 'contain' | 'cover'
|
||||||
|
alt?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
objectFit: 'contain',
|
||||||
|
alt: 'image',
|
||||||
|
})
|
||||||
|
|
||||||
|
const imagePaths = computed(() => {
|
||||||
|
if (!props.resourcesData?.res_path) return null
|
||||||
|
|
||||||
|
const pc =
|
||||||
|
props.resourcesData.res_path.path_pc ?? props.resourcesData.res_path.path_mo
|
||||||
|
const mo =
|
||||||
|
props.resourcesData.res_path.path_mo ?? props.resourcesData.res_path.path_pc
|
||||||
|
return {
|
||||||
|
pc: pc ? getResolvedHost(pc) : '',
|
||||||
|
mo: mo ? getResolvedHost(mo) : '',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<picture v-if="imagePaths" ref="pictureRef">
|
||||||
|
<source media="(min-width: 1024px)" :srcset="imagePaths.pc" />
|
||||||
|
<source media="(max-width: 1023px)" :srcset="imagePaths.mo" />
|
||||||
|
<img
|
||||||
|
:src="imagePaths.pc"
|
||||||
|
:alt="alt"
|
||||||
|
:class="`w-full h-full object-${objectFit}`"
|
||||||
|
loading="lazy"
|
||||||
|
/>
|
||||||
|
</picture>
|
||||||
|
</template>
|
||||||
@@ -45,7 +45,7 @@ const buttonListData = computed(() => {
|
|||||||
/>
|
/>
|
||||||
<div v-if="imgListData" class="img-container">
|
<div v-if="imgListData" class="img-container">
|
||||||
<div v-for="(item, index) in imgListData" :key="index" class="img-item">
|
<div v-for="(item, index) in imgListData" :key="index" class="img-item">
|
||||||
<AtomsImg
|
<AtomsResourcesImg
|
||||||
:resources-data="item"
|
:resources-data="item"
|
||||||
object-fit="contain"
|
object-fit="contain"
|
||||||
:alt="item?.group_label"
|
:alt="item?.group_label"
|
||||||
|
|||||||
@@ -8,6 +8,23 @@ import type {
|
|||||||
PageDataResourceGroupResPath,
|
PageDataResourceGroupResPath,
|
||||||
} from '#layers/types/api/pageData'
|
} from '#layers/types/api/pageData'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 이미지 경로를 완전한 호스트 URL로 변환합니다.
|
||||||
|
* @param path 이미지 경로
|
||||||
|
* @returns 완전한 이미지 URL
|
||||||
|
*/
|
||||||
|
export const getImageHost = (path: string): string => {
|
||||||
|
// path가 없으면 빈 문자열 반환
|
||||||
|
if (!path || typeof path !== 'string') return ''
|
||||||
|
|
||||||
|
const config = useRuntimeConfig()
|
||||||
|
|
||||||
|
const isDev = process.env.NODE_ENV === 'development'
|
||||||
|
const rootPath = isDev ? '' : `${config.public.staticUrl}`
|
||||||
|
|
||||||
|
return `${rootPath}${path}`
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [TODO] 수정 필요
|
* [TODO] 수정 필요
|
||||||
* 이미지 경로를 완전한 호스트 URL로 변환합니다.
|
* 이미지 경로를 완전한 호스트 URL로 변환합니다.
|
||||||
@@ -27,9 +44,6 @@ export const getResolvedHost = (path: string): string => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const config = useRuntimeConfig()
|
const config = useRuntimeConfig()
|
||||||
// const isDev = process.env.NODE_ENV === "development";
|
|
||||||
// const rootPath = isDev ? "/images" : `${config.public.staticUrl}`;
|
|
||||||
|
|
||||||
const rootPath = config.public.staticUrl
|
const rootPath = config.public.staticUrl
|
||||||
|
|
||||||
return `${rootPath}${path}`
|
return `${rootPath}${path}`
|
||||||
|
|||||||
Reference in New Issue
Block a user