|
|
|
|
@ -181,8 +181,19 @@ function onCaptchaInput(event: Event) {
|
|
|
|
|
captchaFieldError.value = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function localizePortalApiMessage(message: string): string {
|
|
|
|
|
if (!isEnglishLogin.value) return message
|
|
|
|
|
if (message === '验证码无效或已过期') return t('login.invalidOrExpired')
|
|
|
|
|
if (message === '赛事不存在或未发布' || message.startsWith('赛事不存在或未发布')) {
|
|
|
|
|
return t('login.competitionMissing')
|
|
|
|
|
}
|
|
|
|
|
const frequent = message.match(/请勿频繁发送,请\s*(\d+)\s*秒后再试/)
|
|
|
|
|
if (frequent) return t('login.tooFrequent', { n: frequent[1] })
|
|
|
|
|
return message
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseJsonErrorPayload(data: unknown): string {
|
|
|
|
|
return userFacingApiMessage(data, t('login.requestFailed'))
|
|
|
|
|
return localizePortalApiMessage(userFacingApiMessage(data, t('login.requestFailed')))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let loginHtmlClassApplied = false
|
|
|
|
|
@ -264,6 +275,7 @@ async function sendCode() {
|
|
|
|
|
mobile: m,
|
|
|
|
|
portal: isAudienceLogin.value ? 'audience' : 'participant',
|
|
|
|
|
competition_slug: competitionSlug.value || undefined,
|
|
|
|
|
lang: portalLocale.value === 'en' ? 'en' : undefined,
|
|
|
|
|
}),
|
|
|
|
|
})
|
|
|
|
|
const data: unknown = await r.json().catch(() => ({}))
|
|
|
|
|
|