<template>
  <iframe class="iframe" :src="url" />
</template>

<script setup lang="ts">
import { getKKFileViewURLFromMinioApi } from '@/api/data/data';
import { ref } from 'vue';

interface Props {
  fileId: any;
}
const props = withDefaults(defineProps<Props>(), {
  fileId: 0,
});
const env = import.meta.env;
const url = ref('');

const getKkFileUrlFun = () => {
  const params = {
    fileId: props.fileId,
  };
  getKKFileViewURLFromMinioApi(params).then((res: any) => {
    if (res.code === 200) {
      url.value = `${env.VITE_API_FILE_PREVIEW_URL}?${res.data.encodeKKFileViewURL}`;
    }
  });
};
getKkFileUrlFun();
</script>
<style scoped lang="scss">
.iframe {
  width: 100%;
  height: 100%;
}
</style>
