2021-08-26 18:49:20 +08:00
|
|
|
<template>
|
2021-09-09 00:08:09 +08:00
|
|
|
<n-layout class="h-full" has-sider>
|
|
|
|
<global-sider v-if="theme.isVerticalNav" :z-index="2" />
|
|
|
|
<global-header v-if="isHorizontalMix" :z-index="2" />
|
|
|
|
<div class="flex-1-hidden flex h-full">
|
|
|
|
<global-sider v-if="isHorizontalMix" class="sider-margin" :z-index="1" />
|
2021-09-14 19:10:10 +08:00
|
|
|
<n-scrollbar ref="scrollbar" class="h-full" :x-scrollable="true" :content-class="fullPage ? 'h-full' : ''">
|
2021-09-09 18:40:38 +08:00
|
|
|
<div
|
|
|
|
class="inline-flex-col-stretch w-full"
|
|
|
|
:class="[{ 'content-padding': isHorizontalMix }, fullPage ? 'h-full' : 'min-h-100vh']"
|
|
|
|
>
|
2021-09-09 00:08:09 +08:00
|
|
|
<global-header v-if="!isHorizontalMix" :z-index="1" />
|
2021-09-17 08:31:49 +08:00
|
|
|
<global-tab :z-index="1" />
|
2021-09-09 00:08:09 +08:00
|
|
|
<n-layout-content class="flex-auto" :class="{ 'bg-[#f5f7f9]': !theme.darkMode }">
|
2021-09-17 08:31:49 +08:00
|
|
|
<router-view v-slot="{ Component }">
|
|
|
|
<keep-alive v-if="keepAlive">
|
|
|
|
<component :is="Component" />
|
|
|
|
</keep-alive>
|
|
|
|
<component :is="Component" v-else />
|
|
|
|
</router-view>
|
2021-09-09 00:08:09 +08:00
|
|
|
</n-layout-content>
|
|
|
|
<global-footer />
|
|
|
|
</div>
|
|
|
|
</n-scrollbar>
|
|
|
|
</div>
|
2021-09-01 17:43:25 +08:00
|
|
|
<setting-drawer />
|
2021-08-26 18:49:20 +08:00
|
|
|
</n-layout>
|
|
|
|
</template>
|
|
|
|
|
2021-09-01 17:43:25 +08:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed } from 'vue';
|
2021-09-09 18:40:38 +08:00
|
|
|
import { useRoute } from 'vue-router';
|
2021-09-09 00:08:09 +08:00
|
|
|
import { NLayout, NScrollbar, NLayoutContent } from 'naive-ui';
|
|
|
|
import { useThemeStore } from '@/store';
|
2021-09-14 19:10:10 +08:00
|
|
|
import { useScrollBehavior } from '@/hooks';
|
2021-09-17 08:31:49 +08:00
|
|
|
import { GlobalSider, GlobalHeader, GlobalTab, GlobalFooter, SettingDrawer } from './components';
|
2021-09-01 17:43:25 +08:00
|
|
|
|
2021-09-09 18:40:38 +08:00
|
|
|
const route = useRoute();
|
2021-09-07 17:03:59 +08:00
|
|
|
const theme = useThemeStore();
|
2021-09-14 19:10:10 +08:00
|
|
|
const { scrollbar, resetScrollWatcher } = useScrollBehavior();
|
2021-09-09 18:40:38 +08:00
|
|
|
|
2021-09-09 00:08:09 +08:00
|
|
|
const isHorizontalMix = computed(() => theme.navStyle.mode === 'horizontal-mix');
|
2021-09-17 08:31:49 +08:00
|
|
|
const headerAndMultiTabHeight = computed(() => {
|
|
|
|
const {
|
|
|
|
headerStyle: { height: hHeight },
|
|
|
|
multiTabStyle: { height: mHeight }
|
|
|
|
} = theme;
|
|
|
|
return `${hHeight + mHeight}px`;
|
2021-09-01 17:43:25 +08:00
|
|
|
});
|
2021-09-17 08:31:49 +08:00
|
|
|
|
|
|
|
/** 缓存页面 */
|
|
|
|
const keepAlive = computed(() => Boolean(route.meta?.keepAlive));
|
|
|
|
|
2021-09-09 18:40:38 +08:00
|
|
|
/** 100%视高 */
|
|
|
|
const fullPage = computed(() => Boolean(route.meta?.fullPage));
|
2021-09-14 19:10:10 +08:00
|
|
|
|
|
|
|
// 路由切换,重置滚动行为
|
|
|
|
resetScrollWatcher();
|
2021-09-01 17:43:25 +08:00
|
|
|
</script>
|
|
|
|
<style scoped>
|
2021-09-09 00:08:09 +08:00
|
|
|
:deep(.n-scrollbar-rail) {
|
|
|
|
z-index: 11;
|
2021-09-01 17:43:25 +08:00
|
|
|
}
|
2021-09-09 00:08:09 +08:00
|
|
|
.sider-margin {
|
2021-09-17 08:31:49 +08:00
|
|
|
margin-top: v-bind(headerAndMultiTabHeight);
|
2021-09-01 17:43:25 +08:00
|
|
|
}
|
2021-09-09 00:08:09 +08:00
|
|
|
.content-padding {
|
2021-09-17 08:31:49 +08:00
|
|
|
padding-top: v-bind(headerAndMultiTabHeight);
|
2021-09-01 17:43:25 +08:00
|
|
|
}
|
|
|
|
</style>
|