fix(useMetaLayoutsMenuOptions): 调整路由标题设置逻辑以支持多语言
This commit is contained in:
@@ -19,6 +19,17 @@ export function useMetaLayoutsNMenuOptions({ menuInstRef }: { menuInstRef: Ref<M
|
|||||||
messages: i18nRouteMessages,
|
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)();
|
const routes = createGetRoutes(router)();
|
||||||
|
|
||||||
@@ -113,7 +124,7 @@ export function useMetaLayoutsNMenuOptions({ menuInstRef }: { menuInstRef: Ref<M
|
|||||||
const pathSegments = route.path.split('/').filter(Boolean);
|
const pathSegments = route.path.split('/').filter(Boolean);
|
||||||
const routeName = route.name as string;
|
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) {
|
if (import.meta.env.VITE_APP_MENU_SHOW_ORDER === 'true' && route.meta?.order) {
|
||||||
const order = String(route.meta.order).padStart(orderMaxLength, '0');
|
const order = String(route.meta.order).padStart(orderMaxLength, '0');
|
||||||
text = `${order}. ${text}`;
|
text = `${order}. ${text}`;
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ declare module 'vue-router' {
|
|||||||
hideInMenu?: boolean;
|
hideInMenu?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 菜单标题
|
* @description 菜单标题 //!⚠️通过多语言标题方案(搜`PageTitleLocalizations`)维护标题
|
||||||
* @deprecated //!⚠️请通过多语言标题方案(搜`PageTitleLocalizations`)维护标题
|
|
||||||
*/
|
*/
|
||||||
title?: string;
|
title?: string;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user