<template >
  <div ref="page" class="page-background">
    <div class="panel-bg">
      <div class="left-bg"></div>
      <div class="right-bg"></div>
    </div>
    <div ref="content" class="content">
      <slot />
    </div>
  </div>
</template>

<script>

export default {
  name: 'PageBackground',
  data() {
    return {}
  },
  created() {
    window.addEventListener('resize', this.onReloadPageSize)
  },
  mounted() {
    this.$nextTick(this.onReloadPageSize)
  },
  methods: {
    onReloadPageSize () {
      const contentDom = this.$refs.content
      const pageDom = this.$refs.page
      pageDom.style.height = `${contentDom.clientHeight + 1}px`
      pageDom.style.width = `100vw`
    }
  },
  destroyed() {
    window.removeEventListener('resize', this.onReloadPageSize)
  }
}
</script>

<style scoped lang='less'>
.page-background {
  background: #011142;
  position: relative;
  width: 100vw;

  .panel-bg {

    display: flex;
    justify-content: space-between;
    .left-bg {
      width: 612px;
      height: 727px;
      background: url('@/assets/images/main-left-bg.png') no-repeat;
      background-size: 100% 100%;
    }

    .right-bg {
      width: 572px;
      height: 727px;
      background: url('@/assets/images/main-right-bg.png') no-repeat;
      background-size: 100% 100%;
    }
  }
  

  .content {
    position: absolute;
    top: 0px;
  }
}
</style>
