fix:修复第一个菜单为 Iframe 时不能自动跳转的 BUG

This commit is contained in:
2368302435@qq.com 2024-04-17 03:11:13 +08:00
parent 50cd5d4e81
commit 63a79c6240

View File

@ -43,7 +43,7 @@ export const routePush = async (to: RouteLocationRaw) => {
/** /**
* *
*/ */
export const getFirstRoute = (routes: RouteRecordRaw[], menuType = 'tab'): false | RouteRecordRaw => { export const getFirstRoute = (routes: RouteRecordRaw[]): false | RouteRecordRaw => {
const routerPaths: string[] = [] const routerPaths: string[] = []
const routers = router.getRoutes() const routers = router.getRoutes()
routers.forEach((item) => { routers.forEach((item) => {
@ -51,7 +51,7 @@ export const getFirstRoute = (routes: RouteRecordRaw[], menuType = 'tab'): false
}) })
let find: boolean | RouteRecordRaw = false let find: boolean | RouteRecordRaw = false
for (const key in routes) { for (const key in routes) {
if (routes[key].meta?.type == 'menu' && routes[key].meta?.menu_type == menuType && routerPaths.indexOf(routes[key].path) !== -1) { if (routes[key].meta?.type == 'menu' && routerPaths.indexOf(routes[key].path) !== -1) {
return routes[key] return routes[key]
} else if (routes[key].children && routes[key].children?.length) { } else if (routes[key].children && routes[key].children?.length) {
find = getFirstRoute(routes[key].children!) find = getFirstRoute(routes[key].children!)