类型优化

This commit is contained in:
Gary Fu
2024-01-07 13:05:05 +08:00
parent b4cf4963b8
commit 8999253e3f
15 changed files with 311 additions and 117 deletions

View File

@@ -54,3 +54,22 @@ export const filterMenus = menus => menus.filter(menu => !menu.disabled)
}
return menu
})
/**
* 如果有replaceTabHistory获取上级菜单
* @function useParentRoute
* @param route {RouteRecordMultipleViewsWithChildren} 路由信息
*/
export const useParentRoute = function (route) {
const parentName = route.meta?.replaceTabHistory
if (parentName) {
const routes = route.matched || []
for (let i = routes.length - 1; i > 0; i--) {
const r = routes[i]
if ((!r.meta || !r.meta.replaceTabHistory) && r.path !== '/') {
return r
}
}
}
return route
}