fix:修复切换路由动画导致白屏的问题

This commit is contained in:
fangyunong 2025-07-08 22:12:14 +08:00
parent 38b3dbe5ce
commit 82e9624179
3 changed files with 22 additions and 42 deletions

View File

@ -7,10 +7,9 @@ import Layout from "@/views/layout/index.vue"; //首页布局
import CallBack from "@/views/login/OauthCallBack.vue"; //反馈页面
import Home from "@/views/home/index.vue"; //家
import Auth from "@/views/role/pages/Auth.vue"; //权限管理
import Menu from '@/views/system/menu/index.vue'; //动态权限菜单
import Register from '@/views/login/Register.vue'; //用户注册
import Dict from '@/views/system/dict/index.vue'; //用户字典
import GlobalSys from '@/views/system/globalSys/index.vue'; //全局参数
import Menu from "@/views/system/menu/index.vue"; //动态权限菜单
import Dict from "@/views/system/dict/index.vue"; //用户字典
import GlobalSys from "@/views/system/globalSys/index.vue"; //全局参数
import { getToken } from "@/utils/auth";
const whiteList = ["/callback"];
@ -26,24 +25,18 @@ const routes: Array<RouteRecordRaw> = [
name: "CallBack",
component: CallBack,
},
{
path:'/register',
name:'register',
component:Register
},
{
path: "/layout",
name: "Layout",
component: Layout,
children: [
{
path: "",
path: "", // 匹配 /layout
name: "home",
component: Home,
},
// 后续用动态菜单
{
path: "role",
path: "role", // 匹配 /layout/role
name: "roleAuth",
component: Auth,
},
@ -53,15 +46,15 @@ const routes: Array<RouteRecordRaw> = [
component: Menu,
},
{
path:'dict',
name:'dict',
component:Dict
path: "dict",
name: "dict",
component: Dict,
},
{
path:'globalSys',
name:'globalSys',
component:GlobalSys
}
path: "globalSys",
name: "globalSys",
component: GlobalSys,
},
],
},
];

View File

@ -39,10 +39,7 @@ const menuOptions: MenuOption[] = [
RouterLink,
{
to: {
name: 'home',
params: {
lang: 'zh-CN'
}
name: 'home'
}
},
{ default: () => '概览' }
@ -60,10 +57,7 @@ const menuOptions: MenuOption[] = [
RouterLink,
{
to: {
name: 'roleAuth',
params: {
lang: 'zh-CN'
}
name: 'roleAuth'
}
},
{ default: () => '权限分配' }
@ -83,10 +77,7 @@ const menuOptions: MenuOption[] = [
RouterLink,
{
to: {
name: 'menu',
params: {
lang: 'zh-CN'
}
name: 'menu'
}
},
{ default: () => '菜单管理' }
@ -99,10 +90,7 @@ const menuOptions: MenuOption[] = [
RouterLink,
{
to: {
name: 'dict',
params: {
lang: 'zh-CN'
}
name: 'dict'
}
},
{ default: () => '字典配置' }
@ -115,10 +103,7 @@ const menuOptions: MenuOption[] = [
RouterLink,
{
to: {
name: 'globalSys',
params: {
lang: 'zh-CN'
}
name: 'globalSys'
}
},
{ default: () => '全局参数' }

View File

@ -6,7 +6,9 @@
<n-layout-content content-style="padding: 16px; height: calc(100vh - 60px);" :native-scrollbar="false">
<router-view v-slot="{ Component }">
<transition name="slide-fade" mode="out-in">
<component :is="Component" />
<div style="height: 100%;width: 100%;" :key="$route.fullPath">
<component :is="Component" />
</div>
</transition>
</router-view>
</n-layout-content>
@ -29,11 +31,11 @@ import LayoutNav from './components/LayoutNav.vue';
}
.slide-fade-enter-active {
transition: all 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
transition: all 0.47s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}
.slide-fade-leave-active {
transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
transition: all 0.47s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}
.slide-fade-enter-from {