<template>
  <transition-group name="fade-transform" mode="out-in">
    <inner-link
      v-for="(item, index) in iframeViews"
      :key="item.path"
      :iframeId="'iframe' + index"
      v-show="$route.path === item.path"
      :src="item.meta.link"
    ></inner-link>
  </transition-group>
</template>

<script>
import InnerLink from "../InnerLink/index";
import { getCompanyId, getMenuNode } from "@/utils/auth";
export default {
  components: { InnerLink },
  data(){
    return{
      iframeViews:[]
    }
  },
  watch: {
    "$store.getters.currentMenuNode": {
      deep: true,
      immediate: true,
      handler(newVal, old) {
        this.iframeViews = this.getVisitedViews();
      },
    },
  },
  methods:{
    getVisitedViews() {
      let url = getMenuNode();
      let empty = [];
      let data = this.$store.state.tagsView.iframeViews;
      if (url) {
        if (url.includes("Workbench")) {
          return data[0];
        } else if (url.includes("MasterDataCenter")) {
          return data[1];
        } else if (url.includes("IntegrationTaskCenter")) {
          return data[2];
        } else if (url.includes("businessCenter")) {
          return data[3];
        } else if (url.includes("ApplicationCenter")) {
          return data[4];
        } else {
          return empty;
        }
      } else {
        return empty;
      }
    },
  }
};
</script>
