import React, { useMemo } from 'react'; import { View, Text } from '@tarojs/components'; import './index.scss'; type AvatarColor = 'pri' | 'acc' | 'wrn' | 'dan'; interface AvatarCircleProps { name: string; size?: number; color?: AvatarColor; className?: string; } const COLOR_MAP: Record = { pri: { bg: '#D4E5F0', fg: '#3A6B8C' }, acc: { bg: '#E8F0E8', fg: '#5B7A5E' }, wrn: { bg: '#FFF3E0', fg: '#C4873A' }, dan: { bg: '#FDEAEA', fg: '#B54A4A' }, }; const AvatarCircle: React.FC = ({ name, size = 44, color = 'pri', className = '', }) => { const initial = useMemo(() => name?.charAt(0) || '?', [name]); const colorStyle = COLOR_MAP[color]; const cls = ['avatar-circle', className].filter(Boolean).join(' '); return ( {initial} ); }; export default React.memo(AvatarCircle);