优化(斗鱼履约): 提示客户只填写游戏角色名

This commit is contained in:
yml
2026-11-20 12:39:53 +08:00
parent 3f67c2ed14
commit 8a375bac75
4 changed files with 98 additions and 0 deletions
@@ -0,0 +1,24 @@
export const DOUYU_ROLE_NAME_FORMAT_HINT =
'只填写游戏角色名,不要填写 UID、区服或微信/QQ;登录方式和设备系统请在上方选择。'
export const DOUYU_ROLE_NAME_MIXED_WARNING =
'这里只能填写游戏角色名。检测到 UID、区服或登录方式,请只保留角色名称,例如“花乔妖精”。'
const ROLE_NAME_SEPARATOR = /[\s,,、|/\\·::;;_-]+/u
const STANDALONE_UID = /^\d{6,}$/u
const LONG_NUMBER = /\d{8,}/u
const STANDALONE_LOGIN_OR_SYSTEM = /^(?:安卓区?|苹果区?|ios|android|微信|qq|q区|v区|手q)$/iu
export function getDouyuRoleNameIssue(value: string): string | null {
const roleName = String(value ?? '').trim()
if (!roleName) return null
const tokens = roleName.split(ROLE_NAME_SEPARATOR).filter(Boolean)
const hasStandaloneUid = tokens.some((token) => STANDALONE_UID.test(token))
const hasLongNumber = LONG_NUMBER.test(roleName)
const hasStandaloneLoginOrSystem = tokens.some((token) => STANDALONE_LOGIN_OR_SYSTEM.test(token))
return hasStandaloneUid || hasLongNumber || hasStandaloneLoginOrSystem
? DOUYU_ROLE_NAME_MIXED_WARNING
: null
}