<template>
  <section class="app-main">
    <router-view v-slot="{ Component, route }">
      <!-- <transition name="fade-transform" mode="out-in"> -->
      <keep-alive :include="tagsViewStore.cachedViews">
        <component v-if="!route.meta.link" :is="Component" :key="route.path" />
      </keep-alive>
      <!-- </transition> -->
    </router-view>
    <iframe-toggle />
    <!-- <iframe id="myIframe" :src="srcUrl" style="width: 100%;height: 100%;" frameborder="0"
      v-show="pathUrl == '/index' || pathUrl == '/system/energy' || pathUrl == '/system/video' || pathUrl == '/system/inspection' || pathUrl == '/system/entranceguard'"></iframe> -->
    <!-- <iframe id="myIframeil" :src="srcUrl1" style="width: 100%;height: 100%;" frameborder="0"
      v-if="pathUrl != '/index' && pathShow || pathShow && pathUrl != '/system/lighting'"></iframe> -->
  </section>
</template>

<script setup>
import iframeToggle from "./IframeToggle/index"
import useTagsViewStore from '@/store/modules/tagsView'

const route = useRoute()
const tagsViewStore = useTagsViewStore()
const pathUrl = ref('')
const pathShow = ref(false)
const srcUrl = 'https://v3d.baozhida.cn/ViewRun?T_ViewID=dzT9YREjSHPJp6LONo1mUCi4v8wMF2lK'
// const srcUrl = 'http://192.168.11.88:9191/ViewRun?T_ViewID=41rwFKnP9R7DAQXGYkz2S8Vcba3qTUd1'
const srcUrl1 = ref('')

onMounted(() => {
  nextTick(() => {
    addIframe()
  });
})
function addIframe() {
  if (route.meta.link) {
    useTagsViewStore().addIframeView(route)
  }
}
</script>

<style lang="scss" scoped>
.app-main {
  height: 100%;
  // width: 100%;
  position: relative;
  overflow: hidden;
}

#myIframe {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  user-select: none;
}

#myIframeil {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  user-select: none;
}

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

  .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: 6px;
  }
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background-color: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background-color: #c0c0c0;
  border-radius: 3px;
}
</style>
