fix(tinode/errors): 处理429账号锁定错误的提示信息

清理429错误消息末尾的状态码后缀,直接使用服务器返回的中文提示,无匹配时使用备用文案
This commit is contained in:
Austin
2026-09-20 17:08:59 +08:00
parent 1952f0ebcd
commit 4dadb1bd5a
2 changed files with 1974 additions and 0 deletions
+1965
View File
File diff suppressed because it is too large Load Diff
+9
View File
@@ -60,6 +60,15 @@ export function loginErrorMessage(err: unknown): string {
const known = translateCtrlError(err); const known = translateCtrlError(err);
if (known) return known; if (known) return known;
const code = (err as { code?: number })?.code; const code = (err as { code?: number })?.code;
// 429 account locked: im_server's ErrAuthLocked puts the user-facing Chinese message (including
// the remaining-minutes wording, e.g. "登录错误次数过多,账号已锁定,请 15 分钟后再试") into ctrl.text,
// so the raw SDK message is that text with a status-code suffix baked in. Strip the suffix and show
// the server copy as-is; the static fallback only fires if the server somehow sent no text. Kept as
// a hardcoded zh string (no i18n key) to match every other entry in this file.
if (code === 429) {
const cleaned = (err as Error)?.message?.replace(/\s*\(\d+\)\s*$/, '').trim();
return cleaned || '登录错误次数过多,请稍后再试';
}
if (code === 401 || code === 403) return '账号或密码错误'; if (code === 401 || code === 403) return '账号或密码错误';
return (err as Error)?.message || '登录失败,请重试'; return (err as Error)?.message || '登录失败,请重试';
} }