<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 { getToken } from '@/utils/auth';
import { map, assign } from 'lodash-es';

export default {
  components: { InnerLink },
  computed: {
    iframeViews() {
      console.log(getToken(), 'iframe views');
      const token = getToken();

      return map(this.$store.state.tagsView.iframeViews, (item) => {
        return assign({}, item, {
          meta: assign(item.meta, {
            link:
              item.meta.link.indexOf('siblingToken') > -1
                ? item.meta.link
                : item.meta.link + `?siblingToken=${token}`
          })
        });
      });
    }
  }
};
</script>
