AppView.vue 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <script lang="ts" setup>
  2. import { useTagsViewStore } from '@/store/modules/tagsView'
  3. import { useAppStore } from '@/store/modules/app'
  4. import { Footer } from '@/layout/components/Footer'
  5. defineOptions({ name: 'AppView' })
  6. const appStore = useAppStore()
  7. const layout = computed(() => appStore.getLayout)
  8. const fixedHeader = computed(() => appStore.getFixedHeader)
  9. const footer = computed(() => appStore.getFooter)
  10. const tagsViewStore = useTagsViewStore()
  11. const getCaches = computed(() : string[] => {
  12. return tagsViewStore.getCachedViews
  13. })
  14. const tagsView = computed(() => appStore.getTagsView)
  15. //region 无感刷新
  16. const routerAlive = ref(true)
  17. // 无感刷新,防止出现页面闪烁白屏
  18. const reload = () => {
  19. routerAlive.value = false
  20. nextTick(() => (routerAlive.value = true))
  21. }
  22. // 为组件后代提供刷新方法
  23. provide('reload', reload)
  24. //endregion
  25. </script>
  26. <template>
  27. <section :class="[
  28. 'p-[var(--app-content-padding)] w-[calc(100%-var(--app-content-padding)-var(--app-content-padding))] bg-[var(--app-content-bg-color)] dark:bg-[var(--el-bg-color)]',
  29. {
  30. '!min-h-[calc(100%-var(--app-content-padding)-var(--app-content-padding)-var(--app-footer-height))]':
  31. (fixedHeader &&
  32. (layout === 'classic' || layout === 'topLeft' || layout === 'top') &&
  33. footer) ||
  34. (!tagsView && layout === 'top' && footer),
  35. '!min-h-[calc(100%-var(--app-content-padding)-var(--app-content-padding)-var(--app-footer-height)-var(--tags-view-height))]':
  36. tagsView && layout === 'top' && footer,
  37. '!min-h-[calc(100%-var(--tags-view-height)-var(--app-content-padding)-var(--app-content-padding)-var(--top-tool-height)-var(--app-footer-height))]':
  38. !fixedHeader && layout === 'classic' && footer,
  39. '!min-h-[calc(100%-var(--tags-view-height)-var(--app-content-padding)-var(--app-content-padding)-var(--app-footer-height))]':
  40. !fixedHeader && layout === 'topLeft' && footer,
  41. '!min-h-[calc(100%-var(--top-tool-height)-var(--app-content-padding)-var(--app-content-padding))]':
  42. fixedHeader && layout === 'cutMenu' && footer,
  43. '!min-h-[calc(100%-var(--top-tool-height)-var(--app-content-padding)-var(--app-content-padding)-var(--tags-view-height))]':
  44. !fixedHeader && layout === 'cutMenu' && footer
  45. }
  46. ]">
  47. <router-view v-if="routerAlive">
  48. <template #default="{ Component, route }">
  49. <keep-alive :include="getCaches">
  50. <component :is="Component" :key="route.fullPath" />
  51. </keep-alive>
  52. </template>
  53. </router-view>
  54. </section>
  55. <Footer v-if="footer" />
  56. </template>