mirror of
https://github.com/vbenjs/vben-admin-thin-next.git
synced 2025-02-03 02:18:40 +08:00
fix: fix homePage affix error
修复当没有通过接口为用户指定首页时,如果默认的首页是一个带有重定向的路由,则可能出现双首页Tab的问题
This commit is contained in:
parent
db7254a5e0
commit
c1178027f0
@ -22,7 +22,7 @@ const dashboard: AppRouteModule = {
|
|||||||
meta: {
|
meta: {
|
||||||
title: t('routes.dashboard.about'),
|
title: t('routes.dashboard.about'),
|
||||||
icon: 'simple-icons:about-dot-me',
|
icon: 'simple-icons:about-dot-me',
|
||||||
// hideMenu: true,
|
hideMenu: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -123,16 +123,20 @@ export const usePermissionStore = defineStore({
|
|||||||
* */
|
* */
|
||||||
const patchHomeAffix = (routes: AppRouteRecordRaw[]) => {
|
const patchHomeAffix = (routes: AppRouteRecordRaw[]) => {
|
||||||
if (!routes || routes.length === 0) return;
|
if (!routes || routes.length === 0) return;
|
||||||
const homePath = userStore.getUserInfo.homePath || PageEnum.BASE_HOME;
|
let homePath: string = userStore.getUserInfo.homePath || PageEnum.BASE_HOME;
|
||||||
function patcher(routes: AppRouteRecordRaw[], parentPath = '') {
|
function patcher(routes: AppRouteRecordRaw[], parentPath = '') {
|
||||||
if (parentPath) parentPath = parentPath + '/';
|
if (parentPath) parentPath = parentPath + '/';
|
||||||
routes.forEach((route: AppRouteRecordRaw) => {
|
routes.forEach((route: AppRouteRecordRaw) => {
|
||||||
const { path, children } = route;
|
const { path, children, redirect } = route;
|
||||||
const currentPath = path.startsWith('/') ? path : parentPath + path;
|
const currentPath = path.startsWith('/') ? path : parentPath + path;
|
||||||
if (currentPath === homePath) {
|
if (currentPath === homePath) {
|
||||||
|
if (redirect) {
|
||||||
|
homePath = route.redirect! as string;
|
||||||
|
} else {
|
||||||
route.meta = Object.assign({}, route.meta, { affix: true });
|
route.meta = Object.assign({}, route.meta, { affix: true });
|
||||||
throw new Error('end');
|
throw new Error('end');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
children && children.length > 0 && patcher(children, currentPath);
|
children && children.length > 0 && patcher(children, currentPath);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user