ThumbnailElement.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <div
  3. class="base-element"
  4. :class="`base-element-${elementInfo.id}`"
  5. :style="{
  6. zIndex: elementIndex
  7. }"
  8. >
  9. <component :is="currentElementComponent" :elementInfo="elementInfo" target="thumbnail" />
  10. </div>
  11. </template>
  12. <script lang="ts" setup>
  13. import { computed } from "vue"
  14. import { ElementTypes, ElementSubtypeTypes, type PPTElement } from "@/types/slides"
  15. import BaseImageElement from "@/views/components/element/ImageElement/BaseImageElement.vue"
  16. import BaseTextElement from "@/views/components/element/TextElement/BaseTextElement.vue"
  17. import BaseShapeElement from "@/views/components/element/ShapeElement/BaseShapeElement.vue"
  18. import BaseLineElement from "@/views/components/element/LineElement/BaseLineElement.vue"
  19. import BaseChartElement from "@/views/components/element/ChartElement/BaseChartElement.vue"
  20. import BaseTableElement from "@/views/components/element/TableElement/BaseTableElement.vue"
  21. import BaseLatexElement from "@/views/components/element/LatexElement/BaseLatexElement.vue"
  22. import BaseVideoElement from "@/views/components/element/VideoElement/BaseVideoElement.vue"
  23. import BaseAudioElement from "@/views/components/element/AudioElement/BaseAudioElement.vue"
  24. import BaseCloudCoachElement from "@/views/components/element/cloudCoachElement/BaseCloudCoachElement.vue"
  25. import BaseEnjoyElement from "@/views/components/element/enjoyElement/BaseEnjoyElement.vue"
  26. const props = defineProps<{
  27. elementInfo: PPTElement
  28. elementIndex: number
  29. }>()
  30. const currentElementComponent = computed<unknown>(() => {
  31. const elementTypeMap = {
  32. [ElementTypes.IMAGE]: BaseImageElement,
  33. [ElementTypes.TEXT]: BaseTextElement,
  34. [ElementTypes.SHAPE]: BaseShapeElement,
  35. [ElementTypes.LINE]: BaseLineElement,
  36. [ElementTypes.CHART]: BaseChartElement,
  37. [ElementTypes.TABLE]: BaseTableElement,
  38. [ElementTypes.LATEX]: BaseLatexElement,
  39. [ElementTypes.ELF]: null
  40. }
  41. const elementSubtypeMap = {
  42. [ElementSubtypeTypes.AUDIO]: BaseAudioElement,
  43. [ElementSubtypeTypes.VIDEO]: BaseVideoElement,
  44. [ElementSubtypeTypes.SING_PLAY]: BaseCloudCoachElement,
  45. [ElementSubtypeTypes.ENJOY]: BaseEnjoyElement
  46. }
  47. return elementTypeMap[props.elementInfo.type] || elementSubtypeMap[props.elementInfo.subtype] || null
  48. })
  49. </script>