优化当前彩金池-安全线

This commit is contained in:
2026-03-17 14:40:28 +08:00
parent f6b4fb99f0
commit 5b5e923a0b
3 changed files with 11 additions and 5 deletions

View File

@@ -27,6 +27,12 @@ function getModuleKey(locale: string, path: string): string {
let lastLoadedPath: string | null = null
let lastLoadedLocale: string | null = null
/** 获取当前语言locale 可能是 string 或 Ref */
function getCurrentLocale(): string {
const loc = i18n.global.locale
return typeof loc === 'string' ? loc : (loc as { value: string }).value
}
/**
* 加载并合并页面翻译到 i18n 的 page 命名空间
*/
@@ -36,7 +42,7 @@ export async function loadPageLocale(routePath: string): Promise<void> {
clearPageLocale()
return
}
const locale = i18n.global.locale.value
const locale = getCurrentLocale()
const key = getModuleKey(locale, path)
const modules = locale === LanguageEnum.EN ? enModules : zhModules
const loader = modules[key]
@@ -64,7 +70,7 @@ export async function loadPageLocale(routePath: string): Promise<void> {
* 清除 page 命名空间(进入无页面翻译的路由时调用)
*/
export function clearPageLocale(): void {
const locale = i18n.global.locale.value
const locale = getCurrentLocale()
const messages = i18n.global.getLocaleMessage(locale) as Record<string, unknown>
if (messages && 'page' in messages) {
const next = { ...messages }