fix: 🐛 修复顶部模式多级菜单注销后登陆后重定向未激活顶部菜单

This commit is contained in:
ray
2024-07-17 22:08:27 +08:00
parent 6dc27ebb21
commit b81a1d4e85

View File

@@ -19,7 +19,7 @@
v-if="route.meta && route.meta.icon" v-if="route.meta && route.meta.icon"
:icon-class="route.meta.icon" :icon-class="route.meta.icon"
/> />
<span v-if="route.path === '/'"> 首页 </span> <span v-if="route.path === '/'">首页</span>
<template v-else> <template v-else>
<span v-if="route.meta && route.meta.title" class="ml-1"> <span v-if="route.meta && route.meta.title" class="ml-1">
{{ translateRouteTitle(route.meta.title) }} {{ translateRouteTitle(route.meta.title) }}
@@ -41,8 +41,10 @@ const appStore = useAppStore();
const permissionStore = usePermissionStore(); const permissionStore = usePermissionStore();
const router = useRouter(); const router = useRouter();
console.log("当前路由", useRoute().path);
// 避免 activeTopMenuPath 缓存被清理从当前路由路径获取顶部菜单路径eg. /system/user → /system // 避免 activeTopMenuPath 缓存被清理从当前路由路径获取顶部菜单路径eg. /system/user → /system
const activeTopMenuPath = useRoute().path.replace(/\/[^\/]+$/, "") || "/"; const activeTopMenuPath = useRoute().path.match(/^\/[^\/]+/)?.[0] || "/";
appStore.activeTopMenu(activeTopMenuPath); appStore.activeTopMenu(activeTopMenuPath);
// 激活的顶部菜单路径 // 激活的顶部菜单路径