LCOV - code coverage report
Current view: top level - src/renderer/extensions/linearMode - MediaOutputPreview.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 100.0 % 8 8
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : <script setup lang="ts">
       2              : import { computed, defineAsyncComponent, useAttrs } from 'vue'
       3              : 
       4              : import { useTextFileContent } from '@/composables/useTextFileContent'
       5              : import ImagePreview from '@/renderer/extensions/linearMode/ImagePreview.vue'
       6              : import VideoPreview from '@comfyorg/design-system/media/VideoPreview'
       7              : import { getMediaType } from '@/renderer/extensions/linearMode/mediaTypes'
       8              : import type { AugmentedResultItem } from '@/utils/resultItem'
       9              : import { resultItemUrl } from '@/utils/resultItemUrl'
      10              : import { cn } from '@comfyorg/tailwind-utils'
      11              : 
      12         2355 : const Preview3d = defineAsyncComponent(
      13              :   () => import('@/renderer/extensions/linearMode/Preview3d.vue')
      14              : )
      15              : 
      16              : defineOptions({ inheritAttrs: false })
      17              : 
      18              : const { output } = defineProps<{
      19              :   output: AugmentedResultItem
      20              :   mobile?: boolean
      21              : }>()
      22              : 
      23           11 : const attrs = useAttrs()
      24           11 : const mediaType = computed(() => getMediaType(output))
      25           11 : const outputLabel = computed(
      26              :   () => output.display_name?.trim() || output.filename
      27              : )
      28           11 : const { textContent } = useTextFileContent(() =>
      29              :   mediaType.value === 'text'
      30              :     ? { content: output.content, url: resultItemUrl(output) }
      31              :     : undefined
      32              : )
      33           11 : const src = computed(() => resultItemUrl(output))
      34           11 : </script>
      35              : <template>
      36           15 :   <template v-if="mediaType === 'images' || mediaType === 'video'">
      37              :     <ImagePreview
      38              :       v-if="mediaType === 'images'"
      39              :       :class="attrs.class as string"
      40              :       :mobile
      41              :       :src
      42              :       :label="outputLabel"
      43              :     />
      44              :     <VideoPreview
      45              :       v-else
      46              :       :src
      47              :       :label="outputLabel"
      48              :       :class="
      49              :         cn(
      50              :           'flex-1 object-contain md:p-3 md:contain-size',
      51              :           attrs.class as string
      52              :         )
      53              :       "
      54              :     />
      55              :   </template>
      56              :   <template v-else>
      57              :     <audio
      58              :       v-if="mediaType === 'audio'"
      59              :       :class="cn('m-auto w-full', attrs.class as string)"
      60              :       controls
      61              :       :src
      62              :     />
      63              :     <article
      64              :       v-else-if="mediaType === 'text'"
      65              :       :class="
      66              :         cn(
      67              :           'm-auto my-12 size-full max-w-2xl scroll-shadows-secondary overflow-y-auto rounded-lg bg-secondary p-4 whitespace-pre-wrap',
      68              :           attrs.class as string
      69              :         )
      70              :       "
      71              :       v-text="textContent"
      72              :     />
      73              :     <Preview3d
      74              :       v-else-if="mediaType === '3d'"
      75              :       :class="attrs.class as string"
      76              :       :model-url="src"
      77              :     />
      78              :     <span v-if="outputLabel" class="self-center text-sm">
      79              :       {{ outputLabel }}
      80              :     </span>
      81              :   </template>
      82              : </template>
        

Generated by: LCOV version 2.0-1