<template>
  <iframe :src="openUrl"
    frameborder="0"></iframe>
</template>

<script setup>
import { getToken } from '@/utils/auth'
const reportBaseDomain = import.meta.env.VITE_APP_REPORT_URL // 基础域名
const reportViewURL = import.meta.env.VITE_APP_REPORT_PREVIEW_URL // 预览
const reportEditURL = import.meta.env.VITE_APP_REPORT_EDIT_URL // 新增/编辑
const route = useRoute()
const subUrl = route.fullPath.split('?')[1]
let openUrl = reportBaseDomain
// 判断路由上是否包含新建/编辑/预览积木的地址，需要携带 token
if (route.fullPath.includes(reportViewURL.substring(1)) || route.fullPath.includes(reportEditURL.substring(1))) {
  openUrl += `?token=${getToken()}&${subUrl}`
} else {
  openUrl += `${reportViewURL}?${subUrl}`
}
console.log(openUrl)
</script>

<style scoped
  lang="scss">
  iframe {
    width: 100%;
    height: 100%;
  }
</style>