<!-- 预览 弹窗列表 -->
<template>
  <div class="musicPreview">
    <div class="headCon">
      <div class="headLeft">
        <div class="title">{{ musicObj.name }}</div>
      </div>
      <div class="headright">
        <img @click="emits('close')" class="closeBtn" src="../../cloudCoachElement/cloudCoachList/imgs/close.png" alt="" />
      </div>
    </div>
    <div class="content">
      <iframe v-if="props.musicObj.id" :key="props.musicObj.id" class="musicIframe" frameborder="0" :src="url"></iframe>
    </div>
  </div>
</template>

<script setup lang="ts">
import { computed } from "vue"
import { getMusicResourcesUrl } from "../index"
import { type pptContentType } from "@/views/components/element/musicResourcesElement"

const emits = defineEmits<{
  (event: "close"): void
}>()

const props = defineProps<{
  musicObj: Record<string, any>
  type: Exclude<pptContentType, "THEORY">
}>()

const url = computed(() => {
  return getMusicResourcesUrl(props.type, "modal", props.musicObj.id)
})
</script>

<style lang="scss" scoped>
.musicPreview {
  width: 100%;
  height: 100%;
  .headCon {
    width: 100%;
    height: 64px;
    border-bottom: 1px solid #eaeaea;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .headLeft {
      margin-left: 30px;
      display: flex;
      align-items: center;
      .title {
        font-weight: 600;
        font-size: 18px;
        color: #131415;
        line-height: 24px;
      }
    }
    .headright {
      margin-right: 30px;
      display: flex;
      align-items: center;
      .closeBtn {
        width: 24px;
        height: 24px;
        cursor: pointer;
        &:hover {
          opacity: 0.8;
        }
      }
    }
  }
  .content {
    width: 100%;
    height: calc(100% - 64px);
    .musicIframe {
      width: 100%;
      height: 100%;
    }
  }
}
</style>
