<!--
 * @Date: 2023-05-08 21:49:41
 * @LastEditors: 陈禹琨 chenyukun@prolog-int.com
 * @LastEditTime: 2023-07-06 18:20:10
 * @FilePath: /upcloud-wms-henanyiyao-web/src/layouts/RouteView.vue
 * @Description: cyk
-->
<script>
export default {
  name: "RouteView",

  props: {
    keepAlive: {
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {
      iframeMap: {},
    };
  },
  render(h) {
    const {
      $route: { meta },
      $store: { getters },
    } = this;

    // if (meta.iframe) {
    //   return
    // }

    const inKeep = (
      <keep-alive>
        <router-view />
      </keep-alive>
    );
    const notKeep = <router-view />;

    // 这里增加了 meta.target 的判断，当target为 iframe时 用 iframe 标签渲染
    // 若页面缓存状态不需要跟多页签关联，可改为 return meta.keepAlive ? inKeep : notKeep

    // 1.当开启了 multiTab 时，并且设置了页面缓存时才会缓存当前页（跟父级keepAlive无关）
    // 2.当没开启 multiTab 时，设置当前页始终不会缓存
    // 当开启了多页签并且设置了页面缓存时才会缓存
    if (getters.multiTab && meta.keepAlive) {
      return inKeep;
    }

    return notKeep;
  },
};
</script>
