<script lang="ts" setup>
import { watch } from "vue"
import { useRoute } from "vue-router"
import { useTagsViewStore } from "@/store/modules/tags-view"

const route = useRoute()
const tagsViewStore = useTagsViewStore()

watch(
  () => route.path,
  () => {
    tagsViewStore.addCachedView(route)
  },
  { immediate: true }
)
</script>

<template>
  <section class="app-main">
    <router-view v-slot="{ Component }">
      <keep-alive :include="tagsViewStore.cachedViews">
        <component :is="Component" />
      </keep-alive>
    </router-view>
  </section>
</template>

<style lang="scss" scoped>
.app-main {
  min-height: calc(100vh - var(--v3-global-header-height));
  width: 100%;
  position: relative;
  overflow: hidden;
  padding: 16px;
  background-color: var(--v3-body-bg-color);
}
</style>
