update 优化 增加icon空的情况

This commit is contained in:
疯狂的狮子Li 2026-06-08 18:47:20 +08:00
parent eafce61dac
commit 565564a8a3
5 changed files with 10 additions and 9 deletions

View File

@ -15,7 +15,7 @@ export interface MenuForm {
menuType?: 'M' | 'C' | 'F' | string;
visible?: string;
status?: string;
icon?: string;
icon?: string | null;
activeMenu?: string;
ext?: string;
remark?: string;
@ -56,7 +56,7 @@ export interface MenuVO extends BaseEntity {
menuType: 'M' | 'C' | 'F' | string;
visible?: string;
status?: string;
icon?: string;
icon?: string | null;
activeMenu?: string;
ext?: string;
perms?: string;

View File

@ -63,7 +63,7 @@ export interface VerifyCodeResult {
export interface RouteMeta {
title?: string;
icon?: string;
icon?: string | null;
noCache?: boolean;
link?: string;
hidden?: boolean;

View File

@ -17,7 +17,7 @@ import { flattenBackendRoutes, routeIcon } from '@/utils/menu';
interface RouteMetaLite {
title?: string;
icon?: string;
icon?: string | null;
affix?: boolean;
}

View File

@ -6,7 +6,7 @@ export interface TagViewItem {
path: string;
fullPath: string;
title: string;
icon?: string;
icon?: string | null;
affix?: boolean;
}

View File

@ -121,9 +121,10 @@ const iconMap: Record<string, React.ReactNode> = {
fileDone: <FileDoneOutlined />
};
export function routeIcon(icon?: string) {
if (!icon) return <AppstoreOutlined />;
const normalizedIcon = icon.replace(/^i-/, '');
export function routeIcon(icon?: string | null) {
const iconValue = typeof icon === 'string' ? icon.trim() : '';
if (!iconValue) return <AppstoreOutlined />;
const normalizedIcon = iconValue.replace(/^i-/, '');
if (normalizedIcon.includes(':')) return <Icon icon={normalizedIcon} />;
const svgIcon = svgIconMap[normalizedIcon] || svgIconMap[normalizedIcon.toLowerCase()];
if (svgIcon) {
@ -134,7 +135,7 @@ export function routeIcon(icon?: string) {
/>
);
}
return iconMap[icon] || iconMap[normalizedIcon] || iconMap[normalizedIcon.toLowerCase()] || <AppstoreOutlined />;
return iconMap[iconValue] || iconMap[normalizedIcon] || iconMap[normalizedIcon.toLowerCase()] || <AppstoreOutlined />;
}
function joinPath(parentPath: string, childPath: string) {