/** * 用户名和头像生成器 */ // 生成用户名: 榴莲女皇x号 export function generateUsername(accountSequence: number): string { return `榴莲女皇${accountSequence}号`; } // 预定义的柔和配色方案 const COLOR_PALETTES = [ { bg: '#FFE4E1', primary: '#FF6B6B', secondary: '#4ECDC4' }, // 粉红+红+青 { bg: '#E8F5E9', primary: '#66BB6A', secondary: '#FFA726' }, // 浅绿+绿+橙 { bg: '#E3F2FD', primary: '#42A5F5', secondary: '#AB47BC' }, // 浅蓝+蓝+紫 { bg: '#FFF3E0', primary: '#FF7043', secondary: '#26A69A' }, // 浅橙+橙+青 { bg: '#F3E5F5', primary: '#AB47BC', secondary: '#42A5F5' }, // 浅紫+紫+蓝 { bg: '#FFFDE7', primary: '#FFCA28', secondary: '#EC407A' }, // 浅黄+黄+粉 { bg: '#E0F7FA', primary: '#26C6DA', secondary: '#7E57C2' }, // 浅青+青+紫 { bg: '#FCE4EC', primary: '#EC407A', secondary: '#66BB6A' }, // 浅粉+粉+绿 ]; // 榴莲形状变体 const DURIAN_SHAPES = [ // 经典榴莲 (color: string) => ` `, // 圆润榴莲 (color: string) => ` `, // 可爱榴莲 (color: string) => ` `, ]; // 表情变体 const FACE_EXPRESSIONS = [ // 开心 (x: number, y: number) => ` `, // 眨眼 (x: number, y: number) => ` `, // 惊讶 (x: number, y: number) => ` `, // 酷 (x: number, y: number) => ` `, // 害羞 (x: number, y: number) => ` `, ]; // 装饰元素 const DECORATIONS = [ // 星星 (color: string) => ` `, // 爱心 (color: string) => ` `, // 音符 (color: string) => ` `, // 闪光 (color: string) => ` `, // 无装饰 () => '', ]; /** * 生成随机SVG头像 (榴莲主题) */ export function generateRandomAvatarSvg(): string { // 随机选择配色 const palette = COLOR_PALETTES[Math.floor(Math.random() * COLOR_PALETTES.length)]; // 随机选择榴莲形状 const shape = DURIAN_SHAPES[Math.floor(Math.random() * DURIAN_SHAPES.length)]; // 随机选择表情 const face = FACE_EXPRESSIONS[Math.floor(Math.random() * FACE_EXPRESSIONS.length)]; // 随机选择装饰 (50%概率有装饰) const decoration = Math.random() > 0.5 ? DECORATIONS[Math.floor(Math.random() * (DECORATIONS.length - 1))] : DECORATIONS[DECORATIONS.length - 1]; return ` ${shape(palette.primary)} ${face(50, 52)} ${decoration(palette.secondary)} `; } /** * 生成用户身份 * @param accountSequence 用户序列号 */ export function generateIdentity(accountSequence: number): { username: string; avatarSvg: string } { return { username: generateUsername(accountSequence), avatarSvg: generateRandomAvatarSvg(), }; }