| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <template>
- <!-- {
- width: viewportSize + 'px',
- height: viewportSize * viewportRatio + 'px',
- transform: `scale(${iframeScale})`,
- } -->
- <div
- class="screen-slide"
- :style="iframeScale"
- >
- <div class="background" :style="{ ...backgroundStyle }"></div>
- <ScreenElement
- v-for="(element, index) in slide.elements"
- :key="element.id"
- :elementInfo="element"
- :elementIndex="index + 1"
- :animationIndex="animationIndex"
- :turnSlideToId="turnSlideToId"
- :manualExitFullscreen="manualExitFullscreen"
- :is-visible="isVisible"
- />
- </div>
- </template>
- <script lang="ts" setup>
- import { computed, provide } from 'vue'
- import { storeToRefs } from 'pinia'
- import { useSlidesStore } from '@/store'
- import { ElementTypes, type Slide } from '@/types/slides'
- import { injectKeySlideId } from '@/types/injectKey'
- import useSlideBackgroundStyle from '@/hooks/useSlideBackgroundStyle'
- import ScreenElement from './ScreenElement.vue'
- const props = defineProps<{
- slide: Slide
- scale: number
- animationIndex: number
- turnSlideToId: (id: string) => void
- manualExitFullscreen: () => void
- isVisible: boolean
- }>()
- const { viewportRatio, viewportSize } = storeToRefs(useSlidesStore())
- const background = computed(() => props.slide.background)
- const { backgroundStyle } = useSlideBackgroundStyle(background)
- const slideId = computed(() => props.slide.id)
- provide(injectKeySlideId, slideId)
- // 判断是否包含指定类型的iframe界面
- const hasIframe = computed(() => {
- return props.slide.elements.some(element =>
- element.type === ElementTypes.FRAME &&
- [72, 73, 75, 76].includes(element.toolType as number)
- )
- })
- // 计算scale:如果是iframe界面且scale大于1就按1,否则按原scale
- const iframeScale = computed(() => {
- if (hasIframe.value) {
- // return Math.min(props.scale, 1)
- //return props.scale;
- return {
- width: '100%',
- height: '100%',
- transform: `scale(1)`,
- }
- }
- return {
- width: viewportSize + 'px',
- height: viewportSize * viewportRatio + 'px',
- transform: `scale(${props.scale})`,
- }
- })
- </script>
- <style lang="scss" scoped>
- .screen-slide {
- position: absolute;
- top: 0;
- left: 0;
- transform-origin: 0 0;
- overflow: hidden;
- }
- .background {
- width: 100%;
- height: 100%;
- background-position: center;
- position: absolute;
- }
- </style>
|