This commit is contained in:
wuzilong committed 2026-10-05 12:57:51 +08:00
1 parent 59fafb92d5
commit 6abfb6e251
1512 files changed
+1565614 -275592

No files matched your search

+36
View File
@@ -18,6 +18,14 @@ import { AppRouteRecord } from '@/types/router'
import { router } from '@/router'
import { isNavigableMenuItem } from './route'
import { useSettingStore } from '@/store/modules/setting'
import { useMenuStore } from '@/store/modules/menu'
import {
classifyMenuNode,
enterGroupTargetPath,
firstEnterableGroupNode,
findMenuNodeByPath,
leafGroupFromNode
} from '@/utils/router/leaf-group'
// 打开外部链接
export const openExternalLink = (link: string) => {
@@ -71,3 +79,31 @@ export const handleMenuJump = (item: AppRouteRecord, jumpToFirst: boolean = fals
// 跳转到子菜单路径
router.push(firstChild.path)
}
/**
* 进入叶子分组:解析菜单节点对应的末级/混合分组,并跳转到组内目标页。
* 已在组内时不跳转(由 enterGroupTargetPath 判定)。
*/
export const enterLeafGroup = (item: AppRouteRecord) => {
const { link, isIframe } = item.meta
if (link && !isIframe) {
return openExternalLink(link)
}
const full =
findMenuNodeByPath(useMenuStore().menuList, String(item.path || '')) || item
const kind = classifyMenuNode(full)
const groupNode =
kind === 'last-non-leaf' || kind === 'mixed' ? full : firstEnterableGroupNode(full)
const group = groupNode ? leafGroupFromNode(groupNode) : null
if (!group) {
return handleMenuJump(full, false)
}
const current = router.currentRoute.value
const target = enterGroupTargetPath(
group,
String(current.path || ''),
current.meta?.activePath as string | undefined
)
if (!target) return
return router.push(target)
}