<script setup lang="ts">
import type { ExperimentVideoType } from '../types'
import VideoItem from './VideoItem.vue'
import { getExperimentVideoList } from '../api'

interface Props {
  experiment_id?: string
}
const props = defineProps<Props>()

let list = $ref<ExperimentVideoType[]>([])
function fetchInfo() {
  if (!props.experiment_id) return
  getExperimentVideoList({ experiment_id: props.experiment_id }).then(res => {
    list = res.data.list
  })
}
watchEffect(() => {
  fetchInfo()
})

const isEmpty = $computed(() => {
  return !props.experiment_id || !list.length
})
</script>

<template>
  <el-empty description="暂无数据" v-if="isEmpty" />
  <template v-else>
    <VideoItem v-for="item in list" :key="item.id" :data="item"></VideoItem>
  </template>
</template>

<style lang="scss" scoped></style>
