mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
refactor(projects): 去除vicons,统一使用iconify图标
This commit is contained in:
@ -1,12 +1,19 @@
|
||||
import { h } from 'vue';
|
||||
import type { Component } from 'vue';
|
||||
import { NIcon } from 'naive-ui';
|
||||
import { Icon } from '@iconify/vue';
|
||||
|
||||
/** 动态渲染vicon */
|
||||
export function dynamicIconRender(icon: Component) {
|
||||
return () => {
|
||||
return h(NIcon, null, {
|
||||
default: () => h(icon)
|
||||
});
|
||||
};
|
||||
/**
|
||||
* 动态渲染iconify
|
||||
* @param icon - 图标名称
|
||||
* @param color - 图标颜色
|
||||
* @param size - 图标大小
|
||||
*/
|
||||
export function iconifyRender(icon: string, color?: string, size?: number) {
|
||||
const style: { color?: string; size?: string } = {};
|
||||
if (color) {
|
||||
style.color = color;
|
||||
}
|
||||
if (size) {
|
||||
style.size = `${size}px`;
|
||||
}
|
||||
return () => h(Icon, { icon, style });
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import type { Component } from 'vue';
|
||||
import type { CustomRoute, GlobalMenuOption } from '@/interface';
|
||||
import { dynamicIconRender } from '@/utils';
|
||||
import { iconifyRender } from '@/utils';
|
||||
|
||||
/** 判断路由是否作为菜单 */
|
||||
function asMenu(route: CustomRoute) {
|
||||
@ -8,10 +7,10 @@ function asMenu(route: CustomRoute) {
|
||||
}
|
||||
|
||||
/** 给菜单添加可选属性 */
|
||||
function addPartialProps(menuItem: GlobalMenuOption, icon?: Component, children?: GlobalMenuOption[]) {
|
||||
function addPartialProps(menuItem: GlobalMenuOption, icon?: string, children?: GlobalMenuOption[]) {
|
||||
const item = { ...menuItem };
|
||||
if (icon) {
|
||||
Object.assign(item, { icon: dynamicIconRender(icon) });
|
||||
Object.assign(item, { icon: iconifyRender(icon) });
|
||||
}
|
||||
if (children) {
|
||||
Object.assign(item, { children });
|
||||
|
Reference in New Issue
Block a user