✨ feat(token): auto-generate default token names when user input is empty
When creating tokens, if the user doesn't provide a token name (empty or whitespace-only), the system will now automatically generate a name using the format "default-xxxxxx" where "xxxxxx" is a 6-character random alphanumeric string. This enhancement ensures that all created tokens have meaningful names and improves the user experience by removing the requirement to manually input token names for quick token creation scenarios. Changes: - Modified token creation logic to detect empty token names - Added automatic fallback to "default" base name when user input is missing - Maintained existing behavior for multiple token creation with random suffixes - Ensured consistent naming pattern across single and batch token creation
This commit is contained in:
@@ -219,9 +219,15 @@ const EditToken = (props) => {
|
||||
let successCount = 0; // 记录成功创建的令牌数量
|
||||
for (let i = 0; i < tokenCount; i++) {
|
||||
let localInputs = { ...inputs };
|
||||
if (i !== 0) {
|
||||
// 如果用户想要创建多个令牌,则给每个令牌一个序号后缀
|
||||
localInputs.name = `${inputs.name}-${generateRandomSuffix()}`;
|
||||
|
||||
// 检查用户是否填写了令牌名称
|
||||
const baseName = inputs.name.trim() === '' ? 'default' : inputs.name;
|
||||
|
||||
if (i !== 0 || inputs.name.trim() === '') {
|
||||
// 如果创建多个令牌(i !== 0)或者用户没有填写名称,则添加随机后缀
|
||||
localInputs.name = `${baseName}-${generateRandomSuffix()}`;
|
||||
} else {
|
||||
localInputs.name = baseName;
|
||||
}
|
||||
localInputs.remain_quota = parseInt(localInputs.remain_quota);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user