init: 初始化 dpb 桃育种系统代码库
前后端 + 后端 FastAPI 全量源码、部署脚本与文档。
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import i18n from "@/locales";
|
||||
|
||||
export function translateRouteTitle(title: unknown): string {
|
||||
if (typeof title !== "string") return String(title);
|
||||
|
||||
const key = `route.${title}`;
|
||||
if (i18n.global.te(key)) {
|
||||
const t = i18n.global.t as (key: string) => string;
|
||||
return t(key);
|
||||
}
|
||||
return title;
|
||||
}
|
||||
Reference in New Issue
Block a user