Skip to content

Commit

Permalink
Merge pull request #1460 from easyops-cn/steve/menu-title-expr
Browse files Browse the repository at this point in the history
fix(): evaluate simple placeholders as menu title
  • Loading branch information
weareoutman authored Dec 27, 2024
2 parents 24971fc + 022c1e1 commit 3ac341f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions bricks/nav/src/data-providers/get-menu-config-options.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ describe("getMenuConfigOptions", () => {
app: [{ appId: "app-a" }],
instanceId: "i-a",
},
{
menuId: "menu-g",
title: "${APP.localeName}",
type: "main",
app: [{ appId: "app-a" }],
instanceId: "i-a",
overrideApp: {
name: "App A",
} as MicroApp,
},
];
expect(await getMenuConfigOptions(menuList)).toEqual([
{
Expand All @@ -87,6 +97,10 @@ describe("getMenuConfigOptions", () => {
label: "<% `${CTX.name} - ${I18n('')}` %> (menu-f)",
value: "menu-f",
},
{
label: "App A (menu-g)",
value: "menu-g",
},
]);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ export function smartDisplayForMenuTitle(
}
}
}
} else if (overrideApp) {
// 处理简单的占位符替换: ${APP.name} 和 ${APP.localeName}
return title.replace(
/\$\{\s*APP\s*\.\s*(?:name|localeName)\s*\}/g,
() => overrideApp.name
);
}
return title;
}
Expand Down

0 comments on commit 3ac341f

Please sign in to comment.