fix. utils 함수 리팩토링
This commit is contained in:
@@ -18,15 +18,11 @@ const { getCurrentSrc } = useResponsiveSrc()
|
||||
|
||||
const videoRef = ref<HTMLVideoElement | null>(null)
|
||||
|
||||
const resPath = computed(() => props.resourcesData?.res_path)
|
||||
const imageSrc = computed(() => {
|
||||
return getCurrentSrc(resPath.value)
|
||||
})
|
||||
const videoSrc = computed(() => {
|
||||
return getCurrentSrc(resPath.value, { resourcesType: 'video' })
|
||||
const resourcesSrc = computed(() => {
|
||||
return getCurrentSrc(props.resourcesData)
|
||||
})
|
||||
const posterSrc = computed(() => {
|
||||
return getCurrentSrc(resPath.value)
|
||||
return getCurrentSrc(props.resourcesData, { resourcesType: 'IMG' })
|
||||
})
|
||||
const imageClasses = computed(() => [
|
||||
`w-full h-full bg-center bg-no-repeat`,
|
||||
@@ -48,7 +44,7 @@ const restartVideo = () => {
|
||||
}
|
||||
|
||||
// src 변경 시 비디오 다시 로드
|
||||
watch(videoSrc, () => {
|
||||
watch(resourcesSrc, () => {
|
||||
if (!videoRef.value) return
|
||||
|
||||
videoRef.value.currentTime = 0
|
||||
@@ -61,17 +57,20 @@ defineExpose({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="resPath" class="overflow-hidden absolute inset-0 w-full h-full">
|
||||
<div
|
||||
v-if="resourcesSrc"
|
||||
class="overflow-hidden absolute inset-0 w-full h-full"
|
||||
>
|
||||
<!-- 이미지 타입 -->
|
||||
<div
|
||||
v-if="isTypeImage(resourcesData?.resource_type) && imageSrc"
|
||||
v-if="isTypeImage(resourcesData?.resource_type)"
|
||||
:class="imageClasses"
|
||||
:style="{ backgroundImage: `url(${imageSrc})` }"
|
||||
:style="{ backgroundImage: `url(${resourcesSrc})` }"
|
||||
/>
|
||||
|
||||
<!-- 비디오 타입 -->
|
||||
<video
|
||||
v-else-if="isTypeVideo(resourcesData?.resource_type) && videoSrc"
|
||||
v-else-if="isTypeVideo(resourcesData?.resource_type)"
|
||||
ref="videoRef"
|
||||
class="w-full h-full object-cover"
|
||||
:poster="posterSrc"
|
||||
@@ -80,7 +79,7 @@ defineExpose({
|
||||
loop
|
||||
playsinline
|
||||
>
|
||||
<source :src="videoSrc" type="video/mp4" />
|
||||
<source :src="resourcesSrc" type="video/mp4" />
|
||||
</video>
|
||||
|
||||
<i v-if="dimmed" class="absolute inset-0 bg-black/50" />
|
||||
|
||||
Reference in New Issue
Block a user