fix: handle undefined children in generate-menus (#6117)

When children is undefined, use empty array as fallback to prevent potential runtime errors. This matches the behavior when hideChildrenInMenu is true.
This commit is contained in:
Jin Mao
2025-05-06 14:29:50 +08:00
committed by Netfan
parent 200859fc7e
commit 1539fc738c

View File

@@ -51,7 +51,7 @@ function generateMenus(
// 处理子菜单 // 处理子菜单
const resultChildren = hideChildrenInMenu const resultChildren = hideChildrenInMenu
? [] ? []
: (children as MenuRecordRaw[]); : ((children as MenuRecordRaw[]) ?? []);
// 设置子菜单的父子关系 // 设置子菜单的父子关系
if (resultChildren.length > 0) { if (resultChildren.length > 0) {