<template>
  <div class="pageBox">
    <HeaderMenu class="header" :style="headerStyle"/>
     <!-- @onChange="handleChange" -->
    <Adaptation class="content" :headerHeight="headerHeight">
      <Transition name="fade">
        <router-view v-if="isShowContent" />
      </Transition>
    </Adaptation>
  </div>
</template>

<script>
import HeaderMenu from "./components/HeaderMenu/index.vue";
import Adaptation from "./components/Adaptation.vue";
import getBoardBaseData from '@/common/getBoardBaseData'
import { mapGetters } from "vuex";
export default {
  name: "ji_ze_gao_su",
  components: {
    HeaderMenu,
    Adaptation,
    // ...modules
  },
  data() {
    return {
      isShowContent:false,
      headerHeight:100,
      header: {
        scale: 1,
        originW: 1920,
        originH: 100 //打开最近标签页时高100，不开启时高68
      },
    };
  },
  watch:{
    isRecentOpen:{
      handler(newV){
        if(newV){
          this.header.originH = 100;
        }else{
          this.header.originH = 68;
        }
        this.calcHeaderScale();
      },
      immediate:true
    }
  },
  computed:{
    ...mapGetters("menu",["isRecentOpen"]),
    headerStyle(){
      return {
        width : `${this.header.originW}px`,
        height : `${this.header.originH}px`,
        transform : `scale(${this.header.scale}, ${this.header.scale})`
      }
    }
  },
  mounted(){
    getBoardBaseData().then(res => {
      this.isShowContent = true;
    });
    // Promise.all()getBoardBaseData().then(()=>{
    //   this.isShowContent = true ;
    // });
    window.addEventListener(
      "resize",
      _.debounce(this.calcHeaderScale.bind(this), 360)
    );
    this.calcHeaderScale();
  },
  methods: {
    calcHeaderScale(){
      let winW = window.innerWidth;
      this.header.scale = winW / this.header.originW;
      this.headerHeight = this.header.scale * this.header.originH;
    },
    // handleChange(activeMenu) {
    //   this.$route.path != activeMenu.path && this.$router.push(activeMenu.path);
    // }
  }
};
</script>

<style lang="scss" scope src="./scss/reset.scss" />  
<style lang="scss" scope src="./scss/el-reset.scss" />
<style scoped lang="scss">
.pageBox {
  background: #13272F;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;

  .fade-enter-active,
  .fade-leave-active {
    transition: opacity .24s;
  }

  .fade-enter,
  .fade-leave-to {
    opacity: 0;
  }

  .header {
    position: fixed;
    transform-origin: left top;
    left: 0; top:0; z-index: 1000;
    overflow: hidden;
    transition: all ease-out 0.3s;
  }

  .content {
    display: flex;
    flex-direction: row;
    pointer-events: none;

    ::v-deep {
      >div {
        top: -6px;
        z-index: -1;
        pointer-events: auto;
        height: calc(100% + 6px);
      }
    }

    &>* {
      flex: 1;
      width: 100%;
      position: absolute;
    }
  }
}
</style>
