Merge pull request #87 from Tencent/feat/support-href-link

feat: 路由支持配置跳转外链
This commit is contained in:
PY 2022-03-08 22:38:45 +08:00 committed by GitHub
commit 1b983a3203
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,6 +37,19 @@ const renderIcon = (item) => {
const useRenderNav = (list: Array<MenuRoute>) => {
return list.map((item) => {
if (!item.children || !item.children.length || item.meta?.single) {
const href = item.path.match(/(http|https):\/\/([\w.]+\/?)\S*/);
if (href) {
return (
<t-menu-item
href={href?.[0]}
name={item.path}
value={item.meta?.single ? item.redirect : item.path}
icon={renderIcon(item)}
>
{item.title}
</t-menu-item>
);
}
return (
<t-menu-item
name={item.path}