perf: reduce the number of icon component instances

This commit is contained in:
vben
2024-07-06 21:53:02 +08:00
parent f7a93a9bb3
commit 3571511394
10 changed files with 19 additions and 24 deletions

View File

@@ -0,0 +1,9 @@
import { h } from 'vue';
import { Icon } from '@iconify/vue';
function createIcon(icon: string) {
return h(Icon, { icon });
}
export { createIcon };

View File

@@ -1,14 +0,0 @@
import { defineComponent, h } from 'vue';
import { Icon } from '@iconify/vue';
function createIcon(name: string) {
return defineComponent({
name: `SvgIcon-${name}`,
setup(props, { attrs }) {
return () => h(Icon, { icon: name, ...props, ...attrs });
},
});
}
export { createIcon };

View File

@@ -1,4 +1,4 @@
export * from './factory';
export * from './create-icon';
export * from './material';
export * from './mdi';

View File

@@ -1,4 +1,4 @@
import { createIcon } from './factory';
import { createIcon } from './create-icon';
export const IconDefault = createIcon('ic:round-auto-awesome');

View File

@@ -1,4 +1,4 @@
import { createIcon } from './factory';
import { createIcon } from './create-icon';
export const MdiKeyboardEsc = createIcon('mdi:keyboard-esc');