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