feat: 多语言将中文设置为默认的语言

This commit is contained in:
2026-04-18 02:15:22 +08:00
parent a94ad59605
commit 47476d408b
8 changed files with 28 additions and 55 deletions
+8 -2
View File
@@ -26,6 +26,12 @@ export function isLang(value: string | undefined): value is Lang {
export type RouteKey = '' | 'teaching-philosophy' | 'curriculum' | 'faculty' | 'about';
export function hrefFor(lang: Lang, segment: RouteKey): string {
if (!segment) return `/${lang}`;
return `/${lang}/${segment}`;
const prefix = lang === DEFAULT_LANG ? '' : `/${lang}`;
if (!segment) return prefix || '/';
return `${prefix}/${segment}`;
}
/** 从 [...lang] rest 参数解析语言,undefined 时返回默认语言 */
export function resolveLang(param: string | undefined): Lang {
return isLang(param) ? param : DEFAULT_LANG;
}