<!-- src/App.vue -->
<template>
  <RouterView v-slot="{ Component, route }">
    <!-- 让 KeepAlive 始终存在；只在里面切换需要缓存的组件 -->
    <KeepAlive>
      <component v-if="route.meta?.keepAlive" :is="Component" :key="route.name" />
    </KeepAlive>

    <!-- 不需要缓存的页面：单独渲染一份，不经过 KeepAlive -->
    <component v-if="!route.meta?.keepAlive" :is="Component" :key="route.fullPath" />
  </RouterView>
</template>
