AppMain.vue 833 Bytes
<script setup lang="ts">
import { useTagsViewStore } from '@/store'

/**
 * 内容区
 *
 * keep-alive 的 include 用 tagsView store 的 cachedViews(页面要缓存需满足:
 * 路由有 name,且 meta.noCache 不为 true)。
 */
const tagsViewStore = useTagsViewStore()
const cachedViews = computed(() => tagsViewStore.cachedViews)
</script>

<template>
  <section class="app-main">
    <router-view v-slot="{ Component, route }">
      <transition name="fade-transform" mode="out-in">
        <keep-alive :include="cachedViews">
          <component :is="Component" :key="route.path" />
        </keep-alive>
      </transition>
    </router-view>
  </section>
</template>

<style scoped lang="scss">
.app-main {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background-color: $bg-page;
  position: relative;
}
</style>