fix. GR_VISUAL_01 템플릿 수정
This commit is contained in:
@@ -120,7 +120,7 @@ if (serverGameData) {
|
||||
<!-- 공통 모달 컴포넌트 -->
|
||||
<BlocksModalYouTube
|
||||
:is-open="youtube.storeIsOpen"
|
||||
:youtube-id="youtube.storeYoutubeId"
|
||||
:youtube-url="youtube.storeYoutubeUrl"
|
||||
:class-name="youtube.storeClassName"
|
||||
@close-button-event="handleResetYoutube"
|
||||
/>
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
<!-- 유튜브 영상 컨테이너 -->
|
||||
<div class="relative w-full h-full">
|
||||
<iframe
|
||||
v-if="youtubeId"
|
||||
:src="`https://www.youtube.com/embed/${youtubeId}?autoplay=1&rel=0`"
|
||||
v-if="embedUrl"
|
||||
:src="embedUrl"
|
||||
class="absolute top-0 left-0 w-full h-full"
|
||||
frameborder="0"
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
||||
@@ -52,7 +52,7 @@
|
||||
<script setup lang="ts">
|
||||
interface Props {
|
||||
isOpen: boolean
|
||||
youtubeId: string
|
||||
youtubeUrl: string
|
||||
title?: string
|
||||
description?: string
|
||||
closeOnBackdrop?: boolean
|
||||
@@ -64,7 +64,7 @@ interface Emits {
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
isOpen: false,
|
||||
youtubeId: '',
|
||||
youtubeUrl: '',
|
||||
title: '',
|
||||
description: '',
|
||||
closeOnBackdrop: true,
|
||||
@@ -72,6 +72,30 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
|
||||
const emit = defineEmits<Emits>()
|
||||
|
||||
// YouTube URL을 임베드 가능한 형태로 변환
|
||||
const embedUrl = computed(() => {
|
||||
if (!props.youtubeUrl) return ''
|
||||
|
||||
// YouTube Shorts URL 처리
|
||||
if (props.youtubeUrl.includes('/shorts/')) {
|
||||
const videoId = props.youtubeUrl.split('/shorts/')[1]?.split('?')[0]
|
||||
return `https://www.youtube.com/embed/${videoId}`
|
||||
}
|
||||
|
||||
// 일반 YouTube URL 처리
|
||||
if (props.youtubeUrl.includes('youtube.com/watch?v=')) {
|
||||
const videoId = props.youtubeUrl.split('v=')[1]?.split('&')[0]
|
||||
return `https://www.youtube.com/embed/${videoId}`
|
||||
}
|
||||
|
||||
// 이미 임베드 URL인 경우
|
||||
if (props.youtubeUrl.includes('youtube.com/embed/')) {
|
||||
return props.youtubeUrl
|
||||
}
|
||||
|
||||
return props.youtubeUrl
|
||||
})
|
||||
|
||||
// ESC 키로 모달 닫기
|
||||
const handleKeydown = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Escape' && props.isOpen) {
|
||||
|
||||
@@ -13,8 +13,8 @@ const modalStore = useModalStore()
|
||||
|
||||
// 비디오 플레이 버튼 클릭 핸들러
|
||||
const handleVideoPlayClick = () => {
|
||||
const youtubeId = props.resourcesData?.display?.text ?? ''
|
||||
modalStore.handleOpenYoutube({ youtubeId })
|
||||
const youtubeUrl = props.resourcesData?.display?.text ?? ''
|
||||
modalStore.handleOpenYoutube({ youtubeUrl })
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,20 +1,8 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
interface DialogParams {
|
||||
isShowDimmed?: boolean
|
||||
className?: string
|
||||
isOutsideClose?: boolean
|
||||
contentText: string
|
||||
confirmButtonText?: string
|
||||
cancelButtonText?: string
|
||||
confirmButtonEvent?: () => void
|
||||
cancelButtonEvent?: () => void
|
||||
closeButtonEvent?: () => void
|
||||
}
|
||||
interface YoutubeParams {
|
||||
youtubeId: string
|
||||
className?: string
|
||||
}
|
||||
import type {
|
||||
DialogParams,
|
||||
YoutubeParams,
|
||||
} from '#layers/types/components/modal'
|
||||
|
||||
const createModalState = () => ({
|
||||
storeIsOpen: ref(false),
|
||||
@@ -110,20 +98,20 @@ export const useModalStore = defineStore('modalStore', () => {
|
||||
// youtube ------------------
|
||||
const youtube = {
|
||||
storeIsOpen: ref(false),
|
||||
storeYoutubeId: ref(''),
|
||||
storeYoutubeUrl: ref(''),
|
||||
storeClassName: ref(''),
|
||||
}
|
||||
|
||||
const handleOpenYoutube = ({ youtubeId, className = '' }: YoutubeParams) => {
|
||||
const handleOpenYoutube = ({ youtubeUrl, className = '' }: YoutubeParams) => {
|
||||
youtube.storeIsOpen.value = true
|
||||
youtube.storeYoutubeId.value = youtubeId
|
||||
youtube.storeYoutubeUrl.value = youtubeUrl
|
||||
youtube.storeClassName.value = className
|
||||
scrollStore.controlScrollLock(true)
|
||||
}
|
||||
|
||||
const handleResetYoutube = () => {
|
||||
youtube.storeIsOpen.value = false
|
||||
youtube.storeYoutubeId.value = ''
|
||||
youtube.storeYoutubeUrl.value = ''
|
||||
youtube.storeClassName.value = ''
|
||||
scrollStore.controlScrollLock(false)
|
||||
}
|
||||
|
||||
@@ -74,6 +74,13 @@ export interface PageDataResourceGroup {
|
||||
}
|
||||
display?: {
|
||||
text: string
|
||||
txt: string
|
||||
color_code_btn?: string
|
||||
color_name_btn?: string
|
||||
color_code_txt?: string
|
||||
color_name_txt?: string
|
||||
color_code?: string
|
||||
color_name?: string
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
16
layers/types/components/modal.ts
Normal file
16
layers/types/components/modal.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export interface DialogParams {
|
||||
isShowDimmed?: boolean
|
||||
className?: string
|
||||
isOutsideClose?: boolean
|
||||
contentText: string
|
||||
confirmButtonText?: string
|
||||
cancelButtonText?: string
|
||||
confirmButtonEvent?: () => void
|
||||
cancelButtonEvent?: () => void
|
||||
closeButtonEvent?: () => void
|
||||
}
|
||||
|
||||
export interface YoutubeParams {
|
||||
youtubeUrl: string
|
||||
className?: string
|
||||
}
|
||||
Reference in New Issue
Block a user