<template>
  <section class="app-main">
    <el-scrollbar ref="scrollTop" class="custom-el-scrollbar__height" wrap-class="custom-scrollbar-wrapper">
      <transition name="fade-transform" mode="out-in">
        <keep-alive :include="cachedViews">
          <router-view v-if="!$route.meta.link" :key="key"/>
        </keep-alive>
      </transition>
    </el-scrollbar>

    <iframe-toggle/>
  </section>
</template>

<script>
import iframeToggle from "./IframeToggle/index"

export default {
  name: 'AppMain',
  components: { iframeToggle },
  computed: {
    cachedViews() {
      return this.$store.state.tagsView.cachedViews
    },
    key() {
      return this.$route.path
    }
  }
}
</script>

<style lang="scss" scoped>
.app-main {
  /* 50 + 36= navbar  50 + footer 36*/
  min-height: calc(100vh - 50px - 36px);
  width: 100%;
  position: relative;
  overflow: hidden;
  padding-bottom: 36px;
}

.fixed-header + .app-main {
  padding-top: 50px;
}

.hasTagsView {
  .app-main {
    /* 84 + 36 = navbar + tags-view + footer = 50 + 34 + 36*/
    min-height: calc(100vh - 84px - 36px);
  }

  .fixed-header + .app-main {
    padding-top: 84px;
  }
}
</style>

<style lang="scss">
// fix css style bug in open el-dialog
.el-popup-parent--hidden {
  .fixed-header {
    padding-right: 17px;
  }
}

.custom-el-scrollbar__height {
  height: calc(100vh - 84px - 36px);
}

.custom-scrollbar-wrapper {
  overflow-x: hidden !important;
  height: calc(100vh - 84px - 36px);
  //padding-top: 84px;
  //padding-bottom: 36px;
}
</style>
