fix(useMetaLayoutsMenuOptions): 调整路由标题设置逻辑以支持多语言
All checks were successful
CI/CD Pipeline / playwright (push) Successful in 4m17s
CI/CD Pipeline / build-and-deploy (push) Successful in 4m27s

This commit is contained in:
严浩
2025-11-02 22:32:58 +08:00
parent ac544a8ff5
commit 838d5cfb6e
2 changed files with 13 additions and 3 deletions

View File

@@ -19,6 +19,17 @@ export function useMetaLayoutsNMenuOptions({ menuInstRef }: { menuInstRef: Ref<M
messages: i18nRouteMessages,
});
// FIXME: 这个逻辑放在这里不太合适。
watch(
() => router.currentRoute.value,
(currentRoute) => {
const routeName = currentRoute.name;
const text = te(routeName) ? t(routeName) : routeName;
currentRoute.meta!.title = text;
},
{ immediate: true },
);
// 获取路由表但是不包含布局路由
const routes = createGetRoutes(router)();
@@ -113,7 +124,7 @@ export function useMetaLayoutsNMenuOptions({ menuInstRef }: { menuInstRef: Ref<M
const pathSegments = route.path.split('/').filter(Boolean);
const routeName = route.name as string;
let text = te(routeName) ? t(routeName) : route.meta?.title || routeName;
let text = te(routeName) ? t(routeName) : routeName;
if (import.meta.env.VITE_APP_MENU_SHOW_ORDER === 'true' && route.meta?.order) {
const order = String(route.meta.order).padStart(orderMaxLength, '0');
text = `${order}. ${text}`;

View File

@@ -45,8 +45,7 @@ declare module 'vue-router' {
hideInMenu?: boolean;
/**
* @description 菜单标题
* @deprecated //!⚠️请通过多语言标题方案(搜`PageTitleLocalizations`)维护标题
* @description 菜单标题 //!⚠️通过多语言标题方案(搜`PageTitleLocalizations`)维护标题
*/
title?: string;