fix(projects): 修复页面切换时导致的溢出滚动条

This commit is contained in:
Soybean
2022-05-10 23:22:24 +08:00
parent a0c405dadd
commit e0233061d3
6 changed files with 104 additions and 82 deletions

View File

@ -5,7 +5,13 @@
>
<router-view v-slot="{ Component, route }">
<div class="h-full">
<transition :name="theme.page.animate ? theme.page.animateMode : undefined" mode="out-in" appear>
<transition
:name="theme.pageAnimateMode"
mode="out-in"
:appear="true"
@before-leave="handleBeforeLeave"
@after-enter="handleAfterEnter"
>
<keep-alive :include="routeStore.cacheRoutes">
<component :is="Component" v-if="app.reloadFlag" :key="route.path" />
</keep-alive>
@ -23,12 +29,26 @@ interface Props {
showPadding?: boolean;
}
interface Emits {
/** 禁止主体溢出 */
(e: 'hide-main-overflow', hidden: boolean): void;
}
withDefaults(defineProps<Props>(), {
showPadding: true
});
const emit = defineEmits<Emits>();
const app = useAppStore();
const theme = useThemeStore();
const routeStore = useRouteStore();
function handleBeforeLeave() {
emit('hide-main-overflow', true);
}
function handleAfterEnter() {
emit('hide-main-overflow', false);
}
</script>
<style scoped></style>