<template>
  <section
    class="app-main"
    :style="{
      top: matchTop,
    }"
    :class="matchHeight"
  >
    <transition name="fade-transform" mode="out-in">
      <keep-alive :include="cachedData">
        <!-- <keep-alive :include="cachedViews"> -->
        <router-view v-if="!$route.meta.link" style="height: 100%" />
      </keep-alive>
    </transition>
    <iframe-toggle />
  </section>
</template>

<script>
import iframeToggle from "./IframeToggle/index";
import { mapGetters } from "vuex";
export default {
  name: "AppMain",
  components: { iframeToggle },
  data() {
    return {
      cachedData: ["ApiAdmin", "scenneAdmin", "listOfApps"],
    };
  },
  computed: {
    ...mapGetters(["sidebar"]),
    cachedViews() {
      return this.$store.state.tagsView.cachedViews;
    },
    // 是否为开启tag
    showTagsView() {
      return this.$store.state.settings.showTagsView;
    },
    key() {
      return this.$route.path;
    },
    matchTop() {
      let top = "";
      if (!this.showTagsView) {
        top = "5px";
      } else {
        top = "63px";
      }
      return top;
    },
    matchHeight() {
      let height = "";
      if (!this.showTagsView) {
        height = "h-10";
      } else {
        height = "h-65";
      }
      return height;
    },
  },
};
</script>

<style lang="scss" scoped>
.openSider {
  width: calc(100% - 136px);
  margin-left: 136px;
}
.app-main {
  border-radius: 8px;
  /* 50= navbar  50  */
  // padding-top: 104px;
  // min-height: calc(100vh - 50px);
  height: calc(100vh - 88px);
  // overflow: auto;
  // width: calc(100% - 20px);
  // margin:0 10px;
  position: relative;
  top: 80px;
  margin-left: 10px;
}
.h-10{
  height: calc(100vh - 10px);
}
.h-65{
  height: calc(100vh - 73px);
}

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

.hasTagsView {
  .app-main {
    /* 84 = navbar + tags-view = 50 + 34 */
    min-height: calc(100vh - 88px);
    background-color: #fbfbfb;
  }

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

// .el-dialog__wrapper{
//     position: absolute !important;
//   }
// .v-modal{
//     position: absolute !important;
//   }
</style>

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