index.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <section class="app-main">
  3. {{ cachedViews }}
  4. <div class="main-container">
  5. <router-view v-slot="{ Component, route }">
  6. <keep-alive :include="[cachedViews]">
  7. <component :is="Component" :key="route.name" />
  8. </keep-alive>
  9. </router-view>
  10. </div>
  11. </section>
  12. </template>
  13. <script setup lang="ts">
  14. import { useTagsViewStore } from "@/store";
  15. const cachedViews = computed(() =>
  16. useTagsViewStore().cachedViews.concat(["CommonLayout"])
  17. ); // 缓存页面集合
  18. </script>
  19. <style lang="scss" scoped>
  20. .app-main {
  21. position: relative;
  22. width: 100%;
  23. min-height: calc(100vh - $navbar-height);
  24. overflow: hidden;
  25. // background-color: var(--el-bg-color-page);
  26. background-color: #f5f9ff;
  27. }
  28. .hasTagsView .app-main {
  29. min-height: calc(100vh - $navbar-height - $tags-view-height);
  30. }
  31. .fixed-header + .app-main {
  32. min-height: 100vh;
  33. padding-top: $navbar-height;
  34. }
  35. .hasTagsView .fixed-header + .app-main {
  36. min-height: 100vh;
  37. padding-top: $navbar-height + $tags-view-height;
  38. }
  39. .layout-mix,
  40. .layout-top {
  41. .fixed-header + .app-main {
  42. padding-top: 0;
  43. }
  44. }
  45. .layout-mix {
  46. .app-main {
  47. height: calc(100vh - $navbar-height);
  48. padding-top: 0;
  49. overflow-y: auto;
  50. }
  51. .hasTagsView .app-main {
  52. height: calc(100vh - $navbar-height - $tags-view-height);
  53. min-height: calc(100vh - $navbar-height - $tags-view-height);
  54. }
  55. .fixed-header + .app-main {
  56. min-height: calc(100vh - $navbar-height);
  57. }
  58. .hasTagsView .fixed-header + .app-main {
  59. height: calc(100vh - $navbar-height);
  60. min-height: calc(100vh - $navbar-height);
  61. padding-top: $tags-view-height;
  62. }
  63. }
  64. .layout-top {
  65. .hasTagsView .fixed-header + .app-main {
  66. padding-top: $tags-view-height;
  67. }
  68. }
  69. .main-container {
  70. padding: 10px;
  71. height: calc(100vh - 86px);
  72. overflow: auto;
  73. }
  74. </style>