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');

View File

@ -46,6 +46,6 @@ const slots = useSlots();
<slot name="tip"></slot>
</VbenTooltip>
</span>
<Input v-model="inputValue" class="h-8 w-[160px]" />
<Input v-model="inputValue" class="h-8 w-[165px]" />
</div>
</template>

View File

@ -54,7 +54,7 @@ const slots = useSlots();
</VbenTooltip>
</span>
<NumberField v-model="inputValue" v-bind="$attrs" class="w-[160px]">
<NumberField v-model="inputValue" v-bind="$attrs" class="w-[165px]">
<NumberFieldContent>
<NumberFieldDecrement />
<NumberFieldInput />

View File

@ -54,7 +54,7 @@ const slots = useSlots();
</VbenTooltip>
</span>
<Select v-model="selectValue">
<SelectTrigger class="h-8 w-[160px]">
<SelectTrigger class="h-8 w-[165px]">
<SelectValue :placeholder="placeholder" />
</SelectTrigger>
<SelectContent>

View File

@ -26,7 +26,7 @@ page:
embedded: embedded Page
external-link: External Link
fallback:
title: Exception Page
title: Fallback Page
essentials:
login: Login
register: Register
@ -152,7 +152,7 @@ preferences:
two-column-tip: Vertical Two Column Menu Mode
mixed-menu: Mixed Menu
split-menu: Split Menu
mixed-menu-tip: Vertical Menu Co-exists
mixed-menu-tip: Vertical & Horizontal Menu Co-exists
full-content: Full Content
full-content-tip: Display only the main content, no menus
weak-mode: Color Weak Mode

View File

@ -26,7 +26,7 @@ page:
embedded: 内嵌
external-link: 外链
fallback:
title: 异常页面
title: 缺省页
essentials:
login: 登陆
register: 注册
@ -152,7 +152,7 @@ preferences:
two-column: 双列菜单
two-column-tip: 垂直双列菜单模式
mixed-menu: 混合菜单
mixed-menu-tip: 垂直菜单共存
mixed-menu-tip: 垂直水平菜单共存
split-menu: 切割菜单
full-content: 内容全屏
full-content-tip: 不显示任何菜单,只显示内容主体