Files
dpb/frontend/web/src/utils/i18n/auth.ts
T
34047007@qq.com b95053c52c init: 初始化 dpb 桃育种系统代码库
前后端 + 后端 FastAPI 全量源码、部署脚本与文档。
2026-08-06 00:17:49 +08:00

21 lines
953 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { $t } from "@/locales";
/** 后端登录失败细分文案 → i18n 键(zh 值 = 后端现有文案,en 值见 locales */
const AUTH_MSG_KEYS: Record<string, string> = {
"账号或密码错误": "login.auth.invalidCredentials",
"用户不存在": "login.auth.userNotFound",
"用户已被停用": "login.auth.userDisabled",
"验证码不能为空": "login.auth.captchaEmpty",
"验证码标识不能为空": "login.auth.captchaIdEmpty",
"验证码已过期,请刷新": "login.auth.captchaExpired",
"验证码已使用": "login.auth.captchaUsed",
"请先完成滑块验证": "login.auth.sliderRequired",
"登录类型不能为空": "login.auth.loginTypeEmpty",
};
/** 已知后端登录失败文案 → 翻译;未命中返回 null(调用方用通用 fallback */
export function translateAuthError(msg?: string): string | null {
const key = msg ? AUTH_MSG_KEYS[msg] : undefined;
return key ? $t(key) : null;
}