Files
makelore/src/lib/agent-avatars.ts
2026-07-29 17:22:35 +08:00

24 lines
732 B
TypeScript

const avatarModules = import.meta.glob('../assets/agent-avatars/avatar-*.png', {
eager: true,
import: 'default',
}) as Record<string, string>;
export type AgentAvatarOption = {
id: string;
src: string;
label: string;
};
export const agentAvatarOptions: AgentAvatarOption[] = Array.from({ length: 16 }, (_, index) => {
const number = String(index + 1).padStart(2, '0');
return {
id: `avatar-${number}`,
src: avatarModules[`../assets/agent-avatars/avatar-${number}.png`],
label: `像素伙伴 ${index + 1}`,
};
});
export function getAgentAvatarSrc(avatarId: string | null | undefined): string {
return agentAvatarOptions.find((option) => option.id === avatarId)?.src ?? agentAvatarOptions[0]!.src;
}