Files
MyAiDesk/GovAI/apps/web/src/lib/app-icon.tsx
T
freedak f7a720204a Update: 将子项目从 submodule 转为完整内容
- 移除 GovAI, nomifun-tauri, 算力盒子 的 submodule 引用
- 添加所有子项目的完整源代码
- 保留原始 .git 为 .git.bak 备份
2026-07-04 19:20:46 +08:00

130 lines
2.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import {
Scale,
MessageSquareText,
FileSearch,
FilePenLine,
FilePlus,
ScanText,
ShieldAlert,
ClipboardCheck,
ShieldCheck,
BrainCircuit,
FileCheck,
ClipboardList,
BarChart3,
Building2,
Bot,
Cpu,
Layers,
Star,
BookOpen,
FileText,
Mic,
Image,
Database,
Search,
BarChart2,
PieChart,
TrendingUp,
Globe,
Mail,
Phone,
Users,
Map,
Calendar,
Clock,
AlertCircle,
CheckCircle,
XCircle,
Info,
Settings,
Home,
FolderOpen,
Download,
Upload,
Share2,
Edit,
Trash,
Plus,
Minus,
} from "lucide-react";
import type { LucideIcon } from "lucide-react";
const ICON_MAP: Record<string, LucideIcon> = {
scale: Scale,
"message-square-text": MessageSquareText,
"file-search": FileSearch,
"file-pen-line": FilePenLine,
"file-plus": FilePlus,
"scan-text": ScanText,
"shield-alert": ShieldAlert,
"clipboard-check": ClipboardCheck,
"shield-check": ShieldCheck,
"brain-circuit": BrainCircuit,
"file-check": FileCheck,
"clipboard-list": ClipboardList,
"bar-chart-3": BarChart3,
"bar-chart-2": BarChart2,
"building-2": Building2,
bot: Bot,
cpu: Cpu,
layers: Layers,
star: Star,
"book-open": BookOpen,
"file-text": FileText,
mic: Mic,
image: Image,
database: Database,
search: Search,
"pie-chart": PieChart,
"trending-up": TrendingUp,
globe: Globe,
mail: Mail,
phone: Phone,
users: Users,
map: Map,
calendar: Calendar,
clock: Clock,
"alert-circle": AlertCircle,
"check-circle": CheckCircle,
"x-circle": XCircle,
info: Info,
settings: Settings,
home: Home,
"folder-open": FolderOpen,
download: Download,
upload: Upload,
"share-2": Share2,
edit: Edit,
trash: Trash,
plus: Plus,
minus: Minus,
};
/** 检测字符串是否包含 emoji(非 ASCII*/
function isEmoji(str: string): boolean {
return /[^\x00-\x7F]/.test(str);
}
interface AppIconProps {
iconUrl?: string;
size?: number;
className?: string;
}
/** 统一渲染 app 图标:emoji 直接显示,Lucide 图标名转组件,未知名用 Bot 兜底 */
export function AppIcon({ iconUrl, size = 20, className = "" }: AppIconProps) {
if (!iconUrl) {
return <Bot style={{ width: size, height: size }} className={className} />;
}
if (isEmoji(iconUrl)) {
return (
<span style={{ fontSize: size }} className={className}>
{iconUrl}
</span>
);
}
const Icon = ICON_MAP[iconUrl.toLowerCase()] ?? Bot;
return <Icon style={{ width: size, height: size }} className={className} />;
}