fix(useMetaLayoutsNMenuOptions): 优化路由标题设置逻辑
This commit is contained in:
@@ -8,7 +8,7 @@ import IconMenuRounded from '~icons/material-symbols/menu-rounded';
|
|||||||
export function useMetaLayoutsNMenuOptions({ menuInstRef }: { menuInstRef: Ref<MenuInst | null> }) {
|
export function useMetaLayoutsNMenuOptions({ menuInstRef }: { menuInstRef: Ref<MenuInst | null> }) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const { t, te } = useI18n({
|
const { t, te, locale } = useI18n({
|
||||||
inheritLocale: true,
|
inheritLocale: true,
|
||||||
useScope: 'local',
|
useScope: 'local',
|
||||||
missing: (locale, key) => {
|
missing: (locale, key) => {
|
||||||
@@ -21,8 +21,8 @@ export function useMetaLayoutsNMenuOptions({ menuInstRef }: { menuInstRef: Ref<M
|
|||||||
|
|
||||||
// FIXME: 这个逻辑放在这里不太合适。
|
// FIXME: 这个逻辑放在这里不太合适。
|
||||||
watch(
|
watch(
|
||||||
() => router.currentRoute.value,
|
() => [router.currentRoute.value, locale.value] as const,
|
||||||
(currentRoute) => {
|
([currentRoute]) => {
|
||||||
const routeName = currentRoute.name;
|
const routeName = currentRoute.name;
|
||||||
const text = te(routeName) ? t(routeName) : routeName;
|
const text = te(routeName) ? t(routeName) : routeName;
|
||||||
currentRoute.meta!.title = text;
|
currentRoute.meta!.title = text;
|
||||||
|
|||||||
Reference in New Issue
Block a user