AppMain.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <script lang="ts" setup>
  2. import { useTagsViewStore } from "@/store/modules/tags-view"
  3. import { useSettingsStore } from "@/store/modules/settings"
  4. import Footer from "./Footer/index.vue"
  5. const tagsViewStore = useTagsViewStore()
  6. const settingsStore = useSettingsStore()
  7. </script>
  8. <template>
  9. <section class="app-main">
  10. <div class="app-scrollbar">
  11. <!-- key 采用 route.path 和 route.fullPath 有着不同的效果,大多数时候 path 更通用 -->
  12. <router-view v-slot="{ Component, route }">
  13. <transition name="el-fade-in" mode="out-in">
  14. <keep-alive :include="tagsViewStore.cachedViews">
  15. <component :is="Component" :key="route.path" class="app-container-grow" />
  16. </keep-alive>
  17. </transition>
  18. </router-view>
  19. <!-- 页脚 -->
  20. <Footer v-if="settingsStore.showFooter" />
  21. </div>
  22. <!-- 返回顶部 -->
  23. <el-backtop />
  24. <!-- 返回顶部(固定 Header 情况下) -->
  25. <el-backtop target=".app-scrollbar" />
  26. </section>
  27. </template>
  28. <style lang="scss" scoped>
  29. @import "@/styles/mixins.scss";
  30. .app-main {
  31. width: 100%;
  32. display: flex;
  33. }
  34. .app-scrollbar {
  35. flex-grow: 1;
  36. overflow: auto;
  37. @extend %scrollbar;
  38. display: flex;
  39. flex-direction: column;
  40. .app-container-grow {
  41. flex-grow: 1;
  42. }
  43. }
  44. </style>