<template>
  <keep-alive :include="cacheRoutes">
    <router-view />
  </keep-alive>
</template>

<script>
export default {
  name: 'Solo',
  computed: {
    cacheRoutes () {
      return this.$route.meta?.cache || []
    }
  },
  watch: {
    '$route': {
      handler () {
        // solo无对应name
        const matched = this.$route.matched
        if (!matched[matched.length - 1].name) {
          this.$router.replace({ path: '/' })
        }
      },
      immediate: true
    }
  }
}
</script>
