feat: 添加页面切换动画,优化路由视图体验

This commit is contained in:
SunWuyuan 2025-10-08 12:47:38 +08:00
parent 3f02c06ddb
commit 29daa623cc
No known key found for this signature in database
GPG Key ID: A6A54CF66F56BB64
2 changed files with 21 additions and 1 deletions

View File

@ -5,6 +5,10 @@ import 'vue-sonner/style.css'
</script> </script>
<template> <template>
<RouterView /> <RouterView v-slot="{ Component, route }">
<Transition name="page" mode="out-in">
<component :is="Component" :key="route.fullPath" />
</Transition>
</RouterView>
<Toaster class="pointer-events-auto" /> <Toaster class="pointer-events-auto" />
</template> </template>

View File

@ -122,3 +122,19 @@
@apply bg-background text-foreground; @apply bg-background text-foreground;
} }
} }
/* Page transition animations */
.page-enter-active,
.page-leave-active {
transition: opacity 200ms ease, transform 200ms ease;
}
.page-enter-from,
.page-leave-to {
opacity: 0;
transform: translateY(8px);
}
.page-enter-to,
.page-leave-from {
opacity: 1;
transform: translateY(0);
}