<template>
  <div v-loading="loading">
    <iframe :src="`${host}/druid/submitLogin?loginUsername=admin&loginPassword=123456`" style="display: none" @load="loginSuccess" />
    <iframe id="frame" src="" frameborder="0" width="100%" />
  </div>
</template>

<script>
import { getRootPath } from '@/utils/utils.js'

export default {
  name: 'Druid',
  data() {
    return {
      host: process.env.ENV === 'production' ? getRootPath() : process.env.VUE_APP_BASE_API,
      loading: false,
      interval: null
    }
  },
  mounted() {
    this.loading = true
    this.interval = setInterval(() => {
      try {
        document.getElementById('frame').contentWindow.document.getElementsByClassName('footer')[0].remove()
      } catch (e) {
        // console.log(e)
      }
    }, 500)
  },
  destroyed: function() {
    clearInterval(this.interval)
  },
  methods: {
    loginSuccess() {
      document.getElementById('frame').src = `${this.host}/druid/index.html`
      this.loading = false
    }
  }
}
</script>

<style lang="scss">
#frame {
  min-height: calc(100vh - 85px);
}
</style>
