front/src/layout/default-layout.vue
2025-12-03 19:26:02 +08:00

72 lines
1.8 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<a-layout class="layout">
<!-- 顶部导航(类似 nanafa 样式) -->
<TopNav />
<!-- 内容区域 -->
<a-layout :style="contentStyle" class="layout-content">
<a-layout-content>
<PageLayout />
</a-layout-content>
<Footer v-if="footer" />
</a-layout>
</a-layout>
</template>
<script lang="ts" setup>
import { computed, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useAppStore } from '@/store';
import TopNav from '@/components/top-nav/index.vue';
import Footer from '@/components/footer/index.vue';
import usePermission from '@/hooks/permission';
import useResponsive from '@/hooks/responsive';
import PageLayout from './page-layout.vue';
const appStore = useAppStore();
const router = useRouter();
const route = useRoute();
const permission = usePermission();
useResponsive(true);
const footer = computed(() => appStore.footer);
// 内容区域样式:顶部留出导航栏空间
const contentStyle = computed(() => {
const headerHeight = 50; // 顶部导航高度
const tabNavHeight = appStore.tabBar ? 36 : 0; // Tab导航高度
const paddingTop = headerHeight + tabNavHeight;
return { paddingTop: `${paddingTop}px` };
});
watch(
() => route.path,
() => {
// 路由变化时的处理
}
);
</script>
<style lang="less" scoped>
[class$='-container'] {
padding: 16px;
width: 100%;
height: 100%;
}
.layout {
width: 100%;
height: 100vh;
display: flex;
flex-direction: column;
}
.layout-content {
flex: 1;
overflow-y: auto;
background-color: #f0f3f4; // 匹配 nanafa 的主背景色
transition: padding 0.2s cubic-bezier(0.34, 0.69, 0.1, 1);
margin-top: 0; // 顶部导航是 fixed,不需要 margin
}
</style>