<template>
  <router-view v-slot="{ Component }">
    <keep-alive :include="cachedViews">
      <component :is="Component"></component>
    </keep-alive>
  </router-view>
  <back-to-up></back-to-up>
</template>

<script setup>
import useSettingsStore from '@/store/modules/settings'
import { handleThemeStyle } from '@/utils/theme'
import { constantRoutes } from '@/router'
onMounted(() => {
  nextTick(() => {
    // 初始化主题样式
    handleThemeStyle(useSettingsStore().theme)
  })
})
const cachedViews = ref([])
constantRoutes.forEach(o => {
  // 暂时只缓存第一层
  if (o.meta?.keepAlive) {
    cachedViews.value.push(o.name)
  }
})

</script>
