perf: menu svg图标替换

This commit is contained in:
rd
2025-07-07 15:02:04 +08:00
parent 0766c7c1ad
commit 2882d1cae5
7 changed files with 47 additions and 7 deletions

View File

@ -87,7 +87,31 @@ export default defineComponent({
// 跳过没有 name 的菜单项,防止 key 报错
if (!element?.name) return;
const icon = element?.meta?.icon ? () => h(element?.meta?.icon as object) : null;
console.log({ icon: element?.meta?.icon });
// const icon element?.meta?.icon
const icon = element?.meta?.icon
? (() => {
if (typeof element.meta.icon === 'string') {
return h(
'svg',
{
style: {
width: '16px',
height: '16px',
},
},
[
h('use', {
'xlink:href': element.meta.icon,
}),
],
);
} else {
// 如果是对象,按原来的方式渲染
return h(element.meta.icon as object);
}
})()
: null;
if (element.children && element.children.length > 0) {
nodes.push(
<a-sub-menu