fix: 修复新增空目录菜单时 component 为 null 导致路由生成报错

This commit is contained in:
YunaiV
2026-02-07 18:30:03 +08:00
parent 448f073143
commit 5b7e7c4d56

View File

@@ -170,6 +170,10 @@ function convertServerMenuToRouteRecordStringComponent(
// add by 芋艿:处理 menu.component 中的 query 参数 // add by 芋艿:处理 menu.component 中的 query 参数
// https://doc.vben.pro/guide/essentials/route.html#query // https://doc.vben.pro/guide/essentials/route.html#query
let query: Record<string, string> | undefined; let query: Record<string, string> | undefined;
// add by 芋艿:防止 component 为 null 时,调用 indexOf 报错;关联
if (!menu.component) {
menu.component = '';
}
const queryIndex = menu.component.indexOf('?'); const queryIndex = menu.component.indexOf('?');
if (queryIndex !== -1) { if (queryIndex !== -1) {
// 提取 query 字符串并解析为对象 // 提取 query 字符串并解析为对象