Files
mayfly-go/frontend/src/layout/component/main.vue

43 lines
1.3 KiB
Vue
Raw Normal View History

<template>
<el-main class="layout-main !h-full">
<el-scrollbar ref="layoutScrollbarRef" view-class="!h-full">
<LayoutParentView />
</el-scrollbar>
2025-08-04 21:02:27 +08:00
<el-backtop target=".layout-backtop .el-main .el-scrollbar__wrap"></el-backtop>
</el-main>
2023-12-15 17:33:22 +08:00
<el-footer v-if="themeConfig.isFooter">
<Footer />
</el-footer>
</template>
2023-03-15 11:41:03 +08:00
<script setup lang="ts" name="layoutMain">
import { getCurrentInstance, watch, defineAsyncComponent } from 'vue';
import { useRoute } from 'vue-router';
2023-03-15 11:41:03 +08:00
import { storeToRefs } from 'pinia';
import { useThemeConfig } from '@/store/themeConfig';
const LayoutParentView = defineAsyncComponent(() => import('@/layout/routerView/parent.vue'));
const Footer = defineAsyncComponent(() => import('@/layout/footer/index.vue'));
2023-03-15 11:41:03 +08:00
const { proxy } = getCurrentInstance() as any;
const { themeConfig } = storeToRefs(useThemeConfig());
const route = useRoute();
// 监听 themeConfig 配置文件的变化,更新菜单 el-scrollbar 的高度
watch(themeConfig.value, (val) => {
if (val.isFixedHeaderChange !== val.isFixedHeader) {
if (!proxy.$refs.layoutScrollbarRef) return false;
proxy.$refs.layoutScrollbarRef.update();
}
});
2023-03-15 11:41:03 +08:00
// 监听路由的变化
watch(
() => route.path,
() => {
proxy.$refs.layoutScrollbarRef.wrapRef.scrollTop = 0;
}
);
</script>