feat(identity): 改用创意组合名字替代序号命名

将用户名格式从"榴莲皇后x号"改为"榴莲皇后xxx",
其中xxx是2-4字的创意组合,包含前缀、核心词和后缀。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-24 00:25:03 -08:00
parent f0f4aa474a
commit bf64391c0c
1 changed files with 68 additions and 9 deletions

View File

@ -2,15 +2,74 @@
*
*/
// 生成用户名: 榴莲皇后x号
// accountSequence 格式: D + YYMMDD + 5位序号 (如 D24121400001)
// 提取后5位序号去掉前导零
export function generateUsername(accountSequence: string): string {
// 提取后5位序号
const serialPart = accountSequence.slice(-5);
// 去掉前导零,转为数字再转回字符串
const serialNumber = parseInt(serialPart, 10).toString();
return `榴莲皇后${serialNumber}`;
// 创意名字词库 - 用于生成2-4字的创意组合
const NAME_PARTS = {
// 形容词/前缀 (可选)
prefixes: [
'小', '大', '超', '萌', '酷', '甜', '软', '懒', '野', '飞',
'闪', '梦', '星', '云', '月', '花', '雪', '风', '雨', '阳',
],
// 核心词 (必选)
cores: [
'猫', '狗', '兔', '熊', '鹿', '狐', '龙', '凤', '虎', '狼',
'鲸', '豚', '雀', '燕', '鹤', '蝶', '蜂', '萤', '鱼', '龟',
'桃', '梅', '竹', '松', '荷', '莲', '樱', '枫', '柳', '藤',
'糖', '蜜', '果', '瓜', '豆', '芽', '苗', '叶', '花', '草',
'星', '月', '云', '雾', '霞', '虹', '露', '霜', '雪', '雨',
],
// 后缀 (可选)
suffixes: [
'仔', '崽', '宝', '喵', '汪', '咪', '噗', '呜', '嘟', '哒',
'子', '儿', '丸', '团', '球', '饼', '糕', '冻', '泥', '酱',
],
};
/**
* 2-4
* :
* - 2字: 核心词 + (: 猫仔)
* - 3字: 前缀 + + (: 小猫仔) + (: 星月兔)
* - 4字: 前缀 + + (: 小星月兔) + + +
*/
function generateCreativeName(): string {
const { prefixes, cores, suffixes } = NAME_PARTS;
const randomFrom = <T>(arr: T[]): T =>
arr[Math.floor(Math.random() * arr.length)];
// 随机决定名字长度 (2-4字)
const length = Math.floor(Math.random() * 3) + 2; // 2, 3, 或 4
switch (length) {
case 2:
// 50% 概率: 核心词 + 后缀, 50% 概率: 前缀 + 核心词
return Math.random() > 0.5
? randomFrom(cores) + randomFrom(suffixes)
: randomFrom(prefixes) + randomFrom(cores);
case 3:
// 50% 概率: 前缀 + 核心词 + 后缀, 50% 概率: 核心词 + 核心词 + 后缀
return Math.random() > 0.5
? randomFrom(prefixes) + randomFrom(cores) + randomFrom(suffixes)
: randomFrom(cores) + randomFrom(cores) + randomFrom(suffixes);
case 4:
// 前缀 + 核心词 + 核心词 + 后缀
return (
randomFrom(prefixes) +
randomFrom(cores) +
randomFrom(cores) +
randomFrom(suffixes)
);
default:
return randomFrom(cores) + randomFrom(suffixes);
}
}
// 生成用户名: 榴莲皇后 + 创意名字
export function generateUsername(_accountSequence: string): string {
return `榴莲皇后${generateCreativeName()}`;
}
// 预定义的柔和配色方案