<!-- 直播 -->
<script setup lang="ts">
import type { CourseResourceType } from '../types'
import CourseViewMaterialListItem from './CourseViewMaterialListItem.vue'

import { getCourseMaterialList } from '../api'
const { query } = useRoute()
const courseId = $ref(query.course_id as string)
const semesterId = $ref(query.semester_id as string)
let list = $ref<CourseResourceType[]>([])
function fetchList() {
  getCourseMaterialList({ course_id: courseId, semester_id: semesterId }).then(res => {
    list = res.data.items.map((item: CourseResourceType) => {
      return { ...item, resource_type: 4 }
    })
  })
}
onMounted(() => {
  fetchList()
})
</script>
<template>
  <div class="course-live">
    <template v-if="list.length">
      <CourseViewMaterialListItem v-for="item in list" :data="item" :key="item.id"></CourseViewMaterialListItem>
    </template>
    <el-empty description="暂无数据" v-else />
  </div>
</template>
