修复(半自动履约): 稳定任务排序并拆分虎牙角色UID

This commit is contained in:
yml
2026-11-20 15:44:59 +08:00
parent 3b7d133dc9
commit e17d1ac8ab
23 changed files with 643 additions and 239 deletions
@@ -737,9 +737,6 @@ function resolveEventSummary(event: SemiAutoTaskHistoryEvent) {
if (text(detail.pendingGameRole)) {
parts.push(`待确认角色:${text(detail.pendingGameRole)}`)
}
if (text(detail.gameRoleToken) || text(detail.pendingGameRoleToken)) {
parts.push('虎牙平台已返回加密角色标识')
}
if (detail.rebindUnchanged === true) parts.push('平台仍返回原绑定角色')
const message = text(detail.message) || text(detail.rebindConfirmMessage)
if (message) parts.push(message)
@@ -48,6 +48,7 @@ import type { SemiAutoTask } from '@/types/admin/semi-auto'
import type { UploadedFile } from '@/types/worker-platform'
import { formatAdminDateTime } from '@/utils/admin-time'
import { buildCustomerFulfillmentPath } from '@/utils/customer-fulfillment-link'
import { formatHuyaBindingDecisionMessage } from '@/utils/semi-auto-binding-decision'
import { resolvePostInjectionUrl } from '@/utils/semi-auto-injection'
import { canCompleteSemiAutoTask, canInjectSemiAutoBrowser } from '@/utils/semi-auto-task-readiness'
@@ -513,12 +514,8 @@ export default function AdminSemiAutoTasksPage() {
task.bindingStatus
}`}
</Text>
{task.bindGameRole || task.bindGameRoleToken ? (
<Text type="secondary">
{`当前角色:${task.bindGameRole || '-'}${
task.bindGameRoleToken ? '(平台加密标识已识别)' : ''
}`}
</Text>
{task.bindGameRole ? (
<Text type="secondary">{`当前角色:${task.bindGameRole}`}</Text>
) : null}
{task.pendingBindGameRole ? (
<Text type="secondary">{`待确认角色:${task.pendingBindGameRole}`}</Text>
@@ -813,13 +810,16 @@ export default function AdminSemiAutoTasksPage() {
<Descriptions.Item label="待确认角色">
{detail.task.pendingBindGameRole || '-'}
</Descriptions.Item>
<Descriptions.Item label="平台角色标识">
{detail.task.platformGameRoleUid
? `游戏角色 UID ${detail.task.platformGameRoleUid}`
: detail.task.bindGameRoleToken || detail.task.pendingBindGameRoleToken
? '已识别的虎牙加密角色标识'
: '-'}
</Descriptions.Item>
{detail.task.platformGameRoleUid ? (
<Descriptions.Item label="平台角色 UID">
{detail.task.platformGameRoleUid}
</Descriptions.Item>
) : null}
{detail.task.pendingPlatformGameRoleUid ? (
<Descriptions.Item label="待确认角色 UID">
{detail.task.pendingPlatformGameRoleUid}
</Descriptions.Item>
) : null}
<Descriptions.Item label="平台绑定渠道">
{[
detail.task.bindGameChannel,
@@ -862,7 +862,9 @@ export default function AdminSemiAutoTasksPage() {
<Descriptions.Item label="绑定判定" span={2}>
<Space direction="vertical" size={2}>
<Text strong>{BINDING_FLOW_LABELS[detail.task.bindingFlowState] || '-'}</Text>
<Text type="secondary">{detail.task.bindingDecision?.message || '-'}</Text>
<Text type="secondary">
{formatHuyaBindingDecisionMessage(detail.task.bindingDecision) || '-'}
</Text>
{detail.task.bindingDecision?.rebindBlockScope ? (
<Text type="warning">
阻塞作用域:
@@ -42,6 +42,7 @@ import {
resolveCustomerPlatformRedirect,
type CustomerFulfillmentPlatform,
} from '@/utils/customer-fulfillment-link'
import { formatHuyaBindingDecisionMessage } from '@/utils/semi-auto-binding-decision'
import { runWeiboYidunChallenge } from '@/utils/weibo-yidun'
import HuyaChallengeModal from './HuyaChallengeModal'
@@ -115,7 +116,7 @@ export default function CustomerFulfillmentPage({
),
)
const isWeibo = selectedTask?.platform === 'weibo'
// 虎牙流程:登录 → 填写资料(区服/游戏角色 UID/角色名)→ 绑定角色。
// 虎牙流程:填写资料(区服/游戏角色 UID/角色名)→ 登录 → 绑定角色。
// 资料齐全前不生成绑定二维码,避免客户在资料缺失时先绑错角色。
const profileComplete = Boolean(
String(selectedTask?.customerServerZone || '').trim() &&
@@ -884,8 +885,8 @@ export default function CustomerFulfillmentPage({
}
/**
* 返回第二步修改资料:
* 立即切回资料表单(步骤条高亮第 2 步、隐藏绑定/换绑结果),同时调后端清空虎牙
* 返回第一步修改资料:
* 立即切回资料表单(步骤条高亮第 1 步、隐藏绑定/换绑结果),同时调后端清空虎牙
* 绑定与换绑失败状态;登录状态和已填资料保留,客户提交资料后重新走绑定流程。
*/
async function openProfileEditor() {
@@ -893,7 +894,7 @@ export default function CustomerFulfillmentPage({
if (resettingBindingRef.current) return
setBindingConfirmOpen(false)
setProfileEditing(true)
// 资料步骤会隐藏绑定二维码与比对区,等 React 完成切换后再回到第二步顶部。
// 资料步骤会隐藏绑定二维码与比对区,等 React 完成切换后再回到第一步顶部。
window.setTimeout(() => {
document
.getElementById('customer-binding-stage')
@@ -953,7 +954,11 @@ export default function CustomerFulfillmentPage({
current.map((task) => (task.id === response.data.task.id ? response.data.task : task)),
)
setProfileEditing(false)
message.success('资料已保存,正在重新核对平台角色')
message.success(
selectedTask.loginStatus === 'authenticated'
? '资料已保存,正在重新核对平台角色'
: '资料已保存,请继续登录虎牙账号',
)
} catch (error) {
message.error(error instanceof Error ? error.message : '保存角色资料失败')
} finally {
@@ -993,13 +998,19 @@ export default function CustomerFulfillmentPage({
const displayTitle = isWeibo ? '登录并绑定微博游戏角色' : '绑定游戏角色'
const loginQrVisible =
Boolean(selectedTask) && ['qr_pending', 'scanned'].includes(selectedTask.loginStatus)
const showBindingStage = Boolean(
const huyaFlowActive = Boolean(
selectedTask &&
selectedTask.platform === 'huya' &&
selectedTask.loginStatus === 'authenticated' &&
selectedTask.executionStatus !== 'completed' &&
selectedTask.executionStatus !== 'cancelled',
)
const showHuyaProfileStage = Boolean(huyaFlowActive && (profileEditing || !profileComplete))
const showBindingStage = Boolean(
huyaFlowActive &&
selectedTask.loginStatus === 'authenticated' &&
profileComplete &&
!profileEditing,
)
const showWeiboBindingStage = Boolean(
selectedTask &&
selectedTask.platform === 'weibo' &&
@@ -1042,17 +1053,20 @@ export default function CustomerFulfillmentPage({
const currentRoleName = bindingInfo?.bindGameRole || selectedTask?.bindGameRole || ''
const pendingRoleName =
bindingInfo?.pendingBindGameRole || selectedTask?.pendingBindGameRole || ''
const pendingRoleToken =
bindingInfo?.pendingBindGameRoleToken || selectedTask?.pendingBindGameRoleToken || ''
const bindingRoleName = pendingRoleName || currentRoleName
const accountUid = String(selectedTask?.huyaUid || '').trim()
const boundRoleIdKind = bindingComparison?.boundRoleIdKind || 'missing'
const boundRoleReference =
boundRoleIdKind === 'game_role_uid'
? `游戏角色 UID ${bindingComparison?.boundRoleId || '未知'}`
: boundRoleIdKind === 'huya_role_token'
? '平台已返回加密角色标识(不与游戏角色 UID 混用)'
: '平台未返回可核对角色标识'
const platformRoleUid = String(
bindingInfo?.platformGameRoleUid || selectedTask?.platformGameRoleUid || '',
).trim()
const pendingPlatformRoleUid = String(
bindingInfo?.pendingPlatformGameRoleUid || selectedTask?.pendingPlatformGameRoleUid || '',
).trim()
const targetRoleUid = String(
bindingComparison?.customerRoleId || selectedTask?.customerGameRoleId || '',
).trim()
const platformRoleUidReference = platformRoleUid
? `平台角色 UID ${platformRoleUid}`
: '平台未返回绑定角色 UID,当前仅按角色名与区服核验'
const rebindUnchanged = bindingInfo?.rebindUnchanged === true
// 换绑被虎牙拒绝或未生效时展示失败原因;若客户已把资料改成与平台当前角色一致,
// 比对为 match,则回到正常提交流程,不再显示换绑失败。
@@ -1078,10 +1092,10 @@ export default function CustomerFulfillmentPage({
if (bindingSessionExpired) return null
if (bindingDecision) {
if (bindingDecision.flowState === 'rebind_blocked_account') {
return { tone: 'is-warning', text: bindingDecision.message }
return { tone: 'is-warning', text: formatHuyaBindingDecisionMessage(bindingDecision) }
}
if (bindingDecision.flowState === 'rebind_blocked_target_role') {
return { tone: 'is-warning', text: bindingDecision.message }
return { tone: 'is-warning', text: formatHuyaBindingDecisionMessage(bindingDecision) }
}
if (bindingDecision.flowState === 'rebind_effect_pending') {
return { tone: 'is-info', text: bindingDecision.message }
@@ -1134,9 +1148,6 @@ export default function CustomerFulfillmentPage({
const nextRebindText = bindingInfo?.nextRebindAt
? formatAdminDateTime(bindingInfo.nextRebindAt)
: ''
// 登录后资料不全时自动展开资料表单;资料齐全后才展示绑定二维码。
const showProfileForm = showBindingStage && (profileEditing || !profileComplete)
const renderLoginForm = (options: {
platformLabel: string
mobilePlaceholder: string
@@ -1205,6 +1216,68 @@ export default function CustomerFulfillmentPage({
codePlaceholder: '6 位验证码',
submitText: '登录',
})
const huyaProfileForm = showHuyaProfileStage ? (
<div className="customer-auth-profile" id="customer-profile-form">
<p>
{profileComplete
? '修改目标角色资料后会重新核对虎牙账号当前绑定角色;角色名与区服一致后才能确认绑定。'
: '第一步:请填写区服、游戏角色 UID 和角色名。游戏角色 UID 与稍后登录的虎牙账号 UID 不是同一个编号。'}
</p>
<div className="customer-profile-form">
<label className="customer-collect-label">
区服 <span>*</span>
</label>
<Select
className="customer-collect-select"
classNames={SERVER_ZONE_SELECT_CLASS_NAMES}
value={profileServerZone || undefined}
onChange={(value) => setProfileServerZone(String(value))}
placeholder="请选择区服"
options={SERVER_ZONE_OPTIONS.map((value) => ({ value, label: value }))}
/>
<label className="customer-collect-label">
游戏角色 UID <span>*</span>
</label>
<Input
className="customer-collect-input"
value={profileRoleId}
onChange={(event) => setProfileRoleId(event.target.value)}
placeholder="请输入游戏角色 UID"
maxLength={64}
inputMode="numeric"
/>
<label className="customer-collect-label">
角色名 <span>*</span>
</label>
<Input
className="customer-collect-input"
value={profileRoleName}
onChange={(event) => setProfileRoleName(event.target.value)}
placeholder="请输入角色名"
maxLength={100}
/>
<Button
block
size="large"
className="customer-collect-submit"
loading={profileSaving}
onClick={() => void handleSaveProfile()}
>
保存资料并继续登录
</Button>
{profileComplete && selectedTask?.loginStatus === 'authenticated' ? (
<Button
block
size="large"
className="customer-login-alt"
onClick={() => setProfileEditing(false)}
>
返回绑定角色
</Button>
) : null}
</div>
</div>
) : null
if (loading) {
return (
@@ -1282,9 +1355,9 @@ export default function CustomerFulfillmentPage({
{selectedTask?.platform === 'huya' ? (
<CustomerHuyaSteps
current={
selectedTask.loginStatus !== 'authenticated'
profileEditing || !profileComplete
? 1
: profileEditing || !profileComplete
: selectedTask.loginStatus !== 'authenticated'
? 2
: huyaBindingConfirmed
? 4
@@ -1293,10 +1366,15 @@ export default function CustomerFulfillmentPage({
/>
) : null}
{selectedTask?.loginStatus === 'waiting_login' ||
selectedTask?.loginStatus === 'failed' ||
selectedTask?.loginStatus === 'expired' ||
(loginQrVisible && loginMode === 'sms') ? (
{huyaProfileForm ? (
<section className="customer-auth-section">{huyaProfileForm}</section>
) : null}
{(isWeibo || profileComplete) &&
(selectedTask?.loginStatus === 'waiting_login' ||
selectedTask?.loginStatus === 'failed' ||
selectedTask?.loginStatus === 'expired' ||
(loginQrVisible && loginMode === 'sms')) ? (
<section className="customer-auth-section">
{isWeibo
? renderLoginForm({
@@ -1319,7 +1397,7 @@ export default function CustomerFulfillmentPage({
</section>
) : null}
{loginQrVisible && loginMode === 'qr' ? (
{(isWeibo || profileComplete) && loginQrVisible && loginMode === 'qr' ? (
<section className="customer-auth-section">
<div className="customer-auth-section-heading">
<span className="customer-auth-section-icon">
@@ -1511,13 +1589,20 @@ export default function CustomerFulfillmentPage({
<span>当前绑定角色</span>
<strong>{currentRoleName || '未识别到角色'}</strong>
</div>
<div>
<span>目标角色 UID</span>
<strong>{targetRoleUid || '未填写'}</strong>
</div>
{pendingRoleName ? (
<div>
<span>本次待确认角色</span>
<strong>
{pendingRoleName}
{pendingRoleToken ? '(平台加密标识已识别)' : ''}
</strong>
<strong>{pendingRoleName}</strong>
</div>
) : null}
{pendingPlatformRoleUid ? (
<div>
<span>待确认角色 UID</span>
<strong>{pendingPlatformRoleUid}</strong>
</div>
) : null}
</div>
@@ -1549,69 +1634,6 @@ export default function CustomerFulfillmentPage({
</div>
) : null}
{showProfileForm && !bindingSessionExpired ? (
<div className="customer-auth-profile" id="customer-profile-form">
<p>
{profileComplete
? '第二步:修改资料后会用最新资料重新核对平台角色;角色名与区服一致后才能确认绑定。'
: '第二步:请填写区服、游戏角色 UID 和角色名。游戏角色 UID 与上方虎牙登录账号 UID 不是同一个编号。'}
</p>
<div className="customer-profile-form">
<label className="customer-collect-label">
区服 <span>*</span>
</label>
<Select
className="customer-collect-select"
classNames={SERVER_ZONE_SELECT_CLASS_NAMES}
value={profileServerZone || undefined}
onChange={(value) => setProfileServerZone(String(value))}
placeholder="请选择区服"
options={SERVER_ZONE_OPTIONS.map((value) => ({ value, label: value }))}
/>
<label className="customer-collect-label">
游戏角色 UID <span>*</span>
</label>
<Input
className="customer-collect-input"
value={profileRoleId}
onChange={(event) => setProfileRoleId(event.target.value)}
placeholder="请输入游戏角色 UID"
maxLength={64}
inputMode="numeric"
/>
<label className="customer-collect-label">
角色名 <span>*</span>
</label>
<Input
className="customer-collect-input"
value={profileRoleName}
onChange={(event) => setProfileRoleName(event.target.value)}
placeholder="请输入角色名"
maxLength={100}
/>
<Button
block
size="large"
className="customer-collect-submit"
loading={profileSaving}
onClick={() => void handleSaveProfile()}
>
提交资料
</Button>
{profileComplete ? (
<Button
block
size="large"
className="customer-login-alt"
onClick={() => setProfileEditing(false)}
>
返回绑定角色
</Button>
) : null}
</div>
</div>
) : null}
{bindingQrVisible && !bindingSessionExpired && !profileEditing ? (
<div className="customer-binding-qr-card">
<h3>游戏角色绑定二维码</h3>
@@ -1791,12 +1813,16 @@ export default function CustomerFulfillmentPage({
<Space direction="vertical" size={2}>
<span>
平台角色:{bindingComparison.boundZone || '区服未知'} ·{' '}
{bindingComparison.boundRoleName || '角色未知'} · {boundRoleReference}
{bindingComparison.boundRoleName || '角色未知'}
</span>
{platformRoleUid ? <span>平台角色 UID:{platformRoleUid}</span> : null}
{pendingPlatformRoleUid ? (
<span>待确认角色 UID:{pendingPlatformRoleUid}</span>
) : null}
<span>
已填资料:{bindingComparison.customerZone || '区服未填'} ·{' '}
{bindingComparison.customerRoleName || '角色未填'}(ID{' '}
{bindingComparison.customerRoleId || '未填'})
{bindingComparison.customerRoleName || '角色未填'}(UID{' '}
{targetRoleUid || '未填'})
</span>
<span>
角色名称与区服一致后才能确认绑定;请重新扫码换绑,或上一步修改资料。
@@ -1818,7 +1844,11 @@ export default function CustomerFulfillmentPage({
type="success"
showIcon
message={bindingRoleName ? `已识别角色:${bindingRoleName}` : '已识别绑定角色'}
description={[bindingInfo?.bindGameAccount, bindingInfo?.bindGameChannel]
description={[
bindingInfo?.bindGameAccount,
bindingInfo?.bindGameChannel,
targetRoleUid ? `目标角色 UID ${targetRoleUid}` : '',
]
.filter(Boolean)
.join(' · ')}
/>
@@ -2004,7 +2034,7 @@ export default function CustomerFulfillmentPage({
</Button>
</div>
<strong>{bindingComparison?.boundRoleName || '未识别到角色'}</strong>
<em>{boundRoleReference}</em>
<em>{platformRoleUidReference}</em>
</div>
</div>
</Space>
@@ -2103,9 +2133,9 @@ function CustomerOrderCard({ task }: { task: CustomerSemiAutoTask }) {
)
}
const HUYA_FLOW_STEPS = ['登录虎牙账号', '填写游戏资料', '绑定游戏角色']
const HUYA_FLOW_STEPS = ['填写游戏资料', '登录虎牙账号', '绑定游戏角色']
/** 虎牙三步进度:登录 → 填写资料 → 绑定角色。current=4 表示三步都已走完。 */
/** 虎牙三步进度:填写资料 → 登录 → 绑定角色。current=4 表示三步都已走完。 */
function CustomerHuyaSteps({ current }: { current: number }) {
return (
<ol className="customer-huya-steps" aria-label="虎牙履约步骤">
@@ -59,6 +59,7 @@ export type SemiAutoTask = {
pendingBindGameAccount: string
pendingBindGameRole: string
pendingBindGameRoleToken: string
pendingPlatformGameRoleUid: string
pendingBindGameChannel: string
roleIdentitySource: string
verificationBasis: string
@@ -49,6 +49,7 @@ export type CustomerSemiAutoTask = {
pendingBindGameAccount: string
pendingBindGameRole: string
pendingBindGameRoleToken: string
pendingPlatformGameRoleUid: string
pendingBindGameChannel: string
roleIdentitySource: string
verificationBasis: string
@@ -88,6 +89,8 @@ export type CustomerBindingInfo = {
pendingBindGameRole?: string
pendingBindGameRoleToken?: string
pendingBindGameChannel?: string
platformGameRoleUid?: string
pendingPlatformGameRoleUid?: string
pendingChangeBindTime?: number
pendingChangeBindDay?: number
roleIdentitySource?: 'huya_outer_current' | 'huya_inner_pending' | ''
@@ -0,0 +1,28 @@
import type { HuyaBindingDecision } from '../types/semi-auto-binding'
function formatDecisionTime(value: string) {
const date = new Date(value)
if (Number.isNaN(date.getTime())) return value
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0')
const seconds = String(date.getSeconds()).padStart(2, '0')
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
}
export function formatHuyaBindingDecisionMessage(decision: HuyaBindingDecision | null | undefined) {
const message = String(decision?.message || '').trim()
if (!decision || !message) return message
const availableAt =
decision.rebindBlockScope === 'account'
? decision.accountRebindAvailableAt
: decision.rebindBlockScope === 'target_role'
? decision.targetRoleRebindAvailableAt
: ''
if (!availableAt) return message
return `${message};预计 ${formatDecisionTime(availableAt)} 后可换绑`
}
@@ -35,10 +35,21 @@ test('保存资料后只由单一自动绑定流程推进,不再并发轮询',
assert.ok(saveStart > 0)
const saveBody = source.slice(saveStart, saveStart + 1800)
assert.ok(!saveBody.includes('pollCustomerBinding('))
assert.ok(source.includes("message.success('资料已保存,正在重新核对平台角色')"))
assert.ok(source.includes("'资料已保存,正在重新核对平台角色'"))
assert.ok(source.includes("'资料已保存,请继续登录虎牙账号'"))
assert.ok(source.includes("!['query_binding', 'start_first_binding'].includes"))
})
test('虎牙客户页固定先填写资料,再登录并绑定角色', () => {
const stepsStart = source.indexOf('const HUYA_FLOW_STEPS')
const stepsSource = source.slice(stepsStart, stepsStart + 260)
assert.ok(stepsSource.includes("'填写游戏资料'"))
assert.ok(stepsSource.includes("'登录虎牙账号'"))
assert.ok(stepsSource.includes("'绑定游戏角色'"))
assert.ok(source.includes('showHuyaProfileStage'))
assert.ok(source.includes('(isWeibo || profileComplete) &&'))
})
test('登录和绑定专用同步阶段暂停整单轮询', () => {
assert.ok(source.includes('const dedicatedLoginPoll ='))
assert.ok(source.includes('const dedicatedBindingPoll ='))
@@ -66,9 +77,11 @@ test('角色名和区服一致才出现确认绑定,不一致时展示原因',
test('二维码区明确区分虎牙账号 UID 与游戏角色 UID', () => {
assert.ok(source.includes('扫码后系统会核对待确认角色的名称与区服'))
assert.ok(source.includes('不会用虎牙账号 UID'))
assert.ok(source.includes('游戏角色 UID 与上方虎牙登录账号 UID 不是同一个编号'))
assert.ok(source.includes('游戏角色 UID 与稍后登录的虎牙账号 UID 不是同一个编号'))
assert.ok(source.includes('本次待确认角色'))
assert.ok(source.includes('虎牙账号 UID'))
assert.ok(!source.includes('平台已返回加密角色标识'))
assert.ok(!source.includes('平台加密标识已识别'))
assert.ok(!source.includes('const bindingPendingUid'))
assert.ok(!source.includes('const huyaUid = String(selectedTask?.huyaUid'))
})
@@ -36,10 +36,10 @@ test('取消直接使用原角色的快捷确认路径', () => {
assert.ok(!source.includes('modal.confirm'))
})
test('点击上一步修改资料会回到第二步并隐藏绑定区', () => {
// 步骤条把编辑资料视为第二步,即使资料原本已完整。
assert.ok(source.includes(': profileEditing || !profileComplete'))
assert.ok(source.includes("'第二步:请填写区服、游戏角色 UID 和角色名"))
test('点击上一步修改资料会回到第一步并隐藏绑定区', () => {
// 步骤条把编辑资料视为第一步,即使资料原本已完整。
assert.ok(source.includes('profileEditing || !profileComplete'))
assert.ok(source.includes("'第一步:请填写区服、游戏角色 UID 和角色名"))
assert.ok(source.includes('返回绑定角色'))
// 资料步骤隐藏二维码、失败提示和比对操作,避免与第二步混在一起。
assert.ok(source.includes('!profileEditing'))
@@ -0,0 +1,75 @@
import assert from 'node:assert/strict'
import test from 'node:test'
import type { HuyaBindingDecision } from '../src/types/semi-auto-binding.ts'
import { formatHuyaBindingDecisionMessage } from '../src/utils/semi-auto-binding-decision.ts'
function decision(input: Partial<HuyaBindingDecision>): HuyaBindingDecision {
return {
accountRoleState: 'bound',
targetRoleMatch: 'mismatch',
flowState: 'rebind_blocked_account',
primaryAction: 'wait_account_rebind',
allowedActions: [],
rebindBlockScope: 'account',
accountRebindAvailableAt: '',
targetRoleRebindAvailableAt: '',
canGenerateBindingQr: false,
canConfirmBinding: false,
canCompleteTask: false,
requiresCustomerConfirmation: false,
requiresSupport: false,
comparison: {
verdict: 'mismatch',
customerRoleName: '',
customerRoleId: '',
customerZone: '',
boundRoleName: '',
boundRoleId: '',
boundRoleIdKind: 'missing',
boundZone: '',
verificationBasis: 'role_name_zone',
message: '',
missing: [],
mismatched: [],
},
currentRoleComparison: null,
pendingRoleComparison: null,
message: '',
...input,
}
}
test('虎牙账号换绑冷却提示使用页面格式化时间,不直接显示 ISO', () => {
const input = decision({
message: '当前虎牙登录账号仍在换绑冷却期,暂不可换绑',
accountRebindAvailableAt: '2026-11-21T16:00:00.000Z',
})
const text = formatHuyaBindingDecisionMessage(input)
assert.match(text, /当前虎牙登录账号仍在换绑冷却期/)
assert.match(text, /预计 \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} 后可换绑/)
assert.doesNotMatch(text, /2026-11-21T16:00:00\.000Z/)
})
test('目标角色冷却提示只读取目标角色可换绑时间', () => {
const input = decision({
flowState: 'rebind_blocked_target_role',
rebindBlockScope: 'target_role',
message: '目标游戏角色仍在换绑冷却期,暂不可换绑',
accountRebindAvailableAt: '2026-11-20T16:00:00.000Z',
targetRoleRebindAvailableAt: '2026-11-23T16:00:00.000Z',
})
const text = formatHuyaBindingDecisionMessage(input)
assert.match(text, /目标游戏角色仍在换绑冷却期/)
assert.match(text, /预计 \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} 后可换绑/)
assert.doesNotMatch(text, /2026-11-20/)
})
test('没有明确冷却时间时不补造时间', () => {
const text = formatHuyaBindingDecisionMessage(
decision({ message: '当前虎牙登录账号仍在换绑冷却期,暂不可换绑' }),
)
assert.equal(text, '当前虎牙登录账号仍在换绑冷却期,暂不可换绑')
})
@@ -65,3 +65,8 @@ test('虎牙默认只声明角色名与区服一致,不把客户角色 UID 冒
assert.ok(adminPage.includes('角色名与区服一致,可提交平台绑定'))
assert.ok(adminPage.includes('角色名、区服和平台角色 UID 一致,可提交平台绑定'))
})
test('后台不再展示虎牙加密角色标识', () => {
assert.ok(!adminPage.includes('平台加密标识已识别'))
assert.ok(!adminPage.includes('已识别的虎牙加密角色标识'))
})