<!--
 * @Author: 曹捷
 * @Date: 2022-07-22 18:17:12
 * @LastEditors: cjSound 876304802@qq.com
 * @LastEditTime: 2022-07-22 19:29:39
 * @Description: 嵌套iframe基础页面
-->
<template>
  <div id="obit-frame">
    <iframe v-if="baseUrl" :src="baseUrl" frameborder="0"></iframe>
  </div>
</template>

<script>
import { computed, watch, reactive, toRefs } from 'vue'
import { useStore } from 'vuex'
import { getToken } from './../utils/auth'
import { useRoute } from 'vue-router'
import util from './../utils/utils'
export default {
  setup () {
    let route = useRoute()
    let _data = reactive({
      baseUrl: '',
    })

    let store = useStore()
    let _computed = {
      frameUrl: computed(() => {
        return store.state.app.frameUrl
      })
    }
    let methods={
      initUrl(){
        _data.baseUrl = util.util.parseParam({ token: getToken().replace(/\"/g, "") }, route.query.url)
      }
    }
    watch(() =>route.query.url, (value) => {
      methods.initUrl()
    })
      methods.initUrl()
    return {
      ..._computed,
      ...toRefs(_data)
    }
  }
}
</script>

<style lang="less" scope>
#obit-frame {
  width: 100%;
  height: 100%;
  overflow: hidden;
  iframe {
    height: 100%;
    width: 100%;
  }
}
</style>