2022-04-22 12:47:04 +08:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed } from "vue"
|
|
|
|
import { useRoute } from "vue-router"
|
2023-02-22 15:53:04 +08:00
|
|
|
import { useTagsViewStore } from "@/store/modules/tags-view"
|
2022-04-22 12:47:04 +08:00
|
|
|
|
|
|
|
const route = useRoute()
|
2023-02-22 15:53:04 +08:00
|
|
|
const tagsViewStore = useTagsViewStore()
|
|
|
|
|
2022-04-22 12:47:04 +08:00
|
|
|
const key = computed(() => {
|
2023-06-13 13:01:13 +08:00
|
|
|
// 返回 route.path 和 route.fullPath 有着不同的效果,大多数时候 path 更通用
|
2022-04-22 12:47:04 +08:00
|
|
|
return route.path
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
2022-04-21 18:20:39 +08:00
|
|
|
<template>
|
|
|
|
<section class="app-main">
|
2023-06-05 11:19:27 +08:00
|
|
|
<div class="app-scrollbar">
|
|
|
|
<router-view v-slot="{ Component }">
|
|
|
|
<transition name="el-fade-in" mode="out-in">
|
|
|
|
<keep-alive :include="tagsViewStore.cachedViews">
|
|
|
|
<component :is="Component" :key="key" />
|
|
|
|
</keep-alive>
|
|
|
|
</transition>
|
|
|
|
</router-view>
|
|
|
|
</div>
|
2022-04-21 18:20:39 +08:00
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2023-06-05 11:19:27 +08:00
|
|
|
@import "@/styles/mixins.scss";
|
|
|
|
|
2022-04-21 18:20:39 +08:00
|
|
|
.app-main {
|
|
|
|
width: 100%;
|
2022-11-12 13:53:32 +08:00
|
|
|
background-color: var(--v3-body-bg-color);
|
2022-04-21 18:20:39 +08:00
|
|
|
}
|
|
|
|
|
2023-06-05 11:19:27 +08:00
|
|
|
.app-scrollbar {
|
|
|
|
height: 100%;
|
|
|
|
overflow: auto;
|
|
|
|
@include scrollbar;
|
|
|
|
}
|
2022-04-21 18:20:39 +08:00
|
|
|
</style>
|