fix: 修复plugin-layout中body的top计算问题

This commit is contained in:
wanchun 2023-06-28 10:49:52 +08:00
parent fbcde25789
commit afdbaa81cc
2 changed files with 18 additions and 8 deletions

View File

@ -165,8 +165,8 @@
</template> </template>
<script> <script>
import { ref, computed, onMounted } from 'vue'; import { ref, computed, watch, nextTick } from 'vue';
import { useRoute } from '@@/core/coreExports'; import { useRoute, useRouter } from '@@/core/coreExports';
import { FLayout, FAside, FMain, FFooter, FHeader } from '@fesjs/fes-design'; import { FLayout, FAside, FMain, FFooter, FHeader } from '@fesjs/fes-design';
import defaultLogo from '../assets/logo.png'; import defaultLogo from '../assets/logo.png';
import Menu from './Menu.vue'; import Menu from './Menu.vue';
@ -235,6 +235,7 @@ export default {
const headerHeightRef = ref(0); const headerHeightRef = ref(0);
const collapsedRef = ref(false); const collapsedRef = ref(false);
const route = useRoute(); const route = useRoute();
const router = useRouter();
const currentNavigation = computed(() => { const currentNavigation = computed(() => {
if (route.meta.layout && route.meta.layout.navigation !== undefined) { if (route.meta.layout && route.meta.layout.navigation !== undefined) {
@ -250,11 +251,20 @@ export default {
return props.isFixedSidebar ? { left } : null; return props.isFixedSidebar ? { left } : null;
}); });
onMounted(() => { watch(
if (headerRef.value) { router.currentRoute,
headerHeightRef.value = headerRef.value.$el.offsetHeight; () => {
} nextTick(() => {
}); if (headerRef.value) {
headerHeightRef.value = headerRef.value.$el.offsetHeight;
}
});
},
{
immediate: true,
},
);
return { return {
headerRef, headerRef,
headerHeightRef, headerHeightRef,

View File

@ -35,7 +35,7 @@ export default defineBuildConfig({
title: 'Fes.js', title: 'Fes.js',
footer: 'Created by MumbleFE', footer: 'Created by MumbleFE',
multiTabs: true, multiTabs: true,
navigation: 'side', navigation: 'mixin',
theme: 'dark', theme: 'dark',
menus: [ menus: [
{ {