优化(斗鱼履约): 提示客户只填写游戏角色名
This commit is contained in:
@@ -22,6 +22,7 @@ import type {
|
||||
DouyuCustomerSystem,
|
||||
} from '@/types/douyu-fulfillment'
|
||||
import { formatAdminDateTime } from '@/utils/admin-time'
|
||||
import { DOUYU_ROLE_NAME_FORMAT_HINT, getDouyuRoleNameIssue } from '@/utils/douyu-role-name'
|
||||
import { useRealtimeEvents } from '@/hooks/useRealtimeEvents'
|
||||
|
||||
const BINDING_FAILURE_ISSUES = new Set([
|
||||
@@ -80,6 +81,7 @@ export default function DouyuFulfillmentPage() {
|
||||
const [nowMs, setNowMs] = useState(() => Date.now())
|
||||
const autoStartRef = useRef('')
|
||||
const customerRoleRef = useRef('')
|
||||
const roleNameIssue = useMemo(() => getDouyuRoleNameIssue(roleName), [roleName])
|
||||
|
||||
const applyData = useCallback((next: DouyuCustomerFulfillment) => {
|
||||
const previousRole = customerRoleRef.current
|
||||
@@ -257,6 +259,10 @@ export default function DouyuFulfillmentPage() {
|
||||
message.warning('请输入游戏角色名')
|
||||
return
|
||||
}
|
||||
if (roleNameIssue) {
|
||||
message.warning(roleNameIssue)
|
||||
return
|
||||
}
|
||||
setSaving(true)
|
||||
try {
|
||||
const response = await saveDouyuProfile(orderNo, {
|
||||
@@ -405,7 +411,17 @@ export default function DouyuFulfillmentPage() {
|
||||
onChange={(event) => setRoleName(event.target.value)}
|
||||
placeholder="请输入和平精英角色名"
|
||||
maxLength={100}
|
||||
status={roleNameIssue ? 'warning' : undefined}
|
||||
aria-describedby="douyu-role-name-help"
|
||||
/>
|
||||
<p
|
||||
id="douyu-role-name-help"
|
||||
className={`customer-douyu-role-name-help${roleNameIssue ? ' is-warning' : ''}`}
|
||||
aria-live="polite"
|
||||
>
|
||||
{roleNameIssue ? <ExclamationCircleOutlined aria-hidden="true" /> : null}
|
||||
<span>{roleNameIssue || DOUYU_ROLE_NAME_FORMAT_HINT}</span>
|
||||
</p>
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
|
||||
@@ -555,6 +555,25 @@
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.customer-auth-page.is-douyu .customer-douyu-role-name-help {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 6px;
|
||||
margin: -4px 2px 0;
|
||||
color: #94a3b8;
|
||||
font-size: 12px;
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.customer-auth-page.is-douyu .customer-douyu-role-name-help .anticon {
|
||||
flex: 0 0 auto;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.customer-auth-page.is-douyu .customer-douyu-role-name-help.is-warning {
|
||||
color: #fbbf24;
|
||||
}
|
||||
|
||||
.customer-auth-page.is-douyu .customer-collect-submit.ant-btn:hover,
|
||||
.customer-auth-page.is-douyu .customer-collect-submit.ant-btn:focus-visible {
|
||||
color: #fff !important;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user