feat(i18n): 引入 routeI18nInstance 以支持路由菜单标题的多语言处理
All checks were successful
CI/CD Pipeline / playwright (push) Successful in 5m9s
CI/CD Pipeline / build-and-deploy (push) Successful in 2m48s

This commit is contained in:
严浩
2025-11-03 15:03:22 +08:00
parent b4fcde324d
commit f9f82e4d29
6 changed files with 49 additions and 25 deletions

View File

@@ -8,27 +8,7 @@ import IconMenuRounded from '~icons/material-symbols/menu-rounded';
export function useMetaLayoutsNMenuOptions({ menuInstRef }: { menuInstRef: Ref<MenuInst | null> }) {
const router = useRouter();
const { t, te, locale } = useI18n({
inheritLocale: true,
useScope: 'local',
missing: (locale, key) => {
consola.warn(`菜单翻译缺失: locale=${locale}, key=${key}`);
return key;
},
fallbackRoot: true,
messages: i18nRouteMessages,
});
// FIXME: 这个逻辑放在这里不太合适。
watch(
() => [router.currentRoute.value, locale.value] as const,
([currentRoute]) => {
const routeName = currentRoute.name;
const text = te(routeName) ? t(routeName) : routeName;
currentRoute.meta!.title = text;
},
{ immediate: true },
);
const { t, te } = routeI18nInstance.global;
// 获取路由表但是不包含布局路由
const routes = createGetRoutes(router)();