From cd16c58279d2c0d55bc981a5ddb276031a6f982e Mon Sep 17 00:00:00 2001 From: Netfan Date: Tue, 3 Dec 2024 14:21:36 +0800 Subject: [PATCH] fix: extra menu title follow locale change --- packages/effects/layouts/src/basic/layout.vue | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/effects/layouts/src/basic/layout.vue b/packages/effects/layouts/src/basic/layout.vue index 16c3551f203..5361177cf79 100644 --- a/packages/effects/layouts/src/basic/layout.vue +++ b/packages/effects/layouts/src/basic/layout.vue @@ -110,10 +110,19 @@ const { sidebarVisible, } = useMixedMenu(); -function wrapperMenus(menus: MenuRecordRaw[]) { - return mapTree(menus, (item) => { - return { ...cloneDeep(item), name: $t(item.name) }; - }); +/** + * 包装菜单,翻译菜单名称 + * @param menus 原始菜单数据 + * @param deep 是否深度包装。对于双列布局,只需要包装第一层,因为更深层的数据会在扩展菜单中重新包装 + */ +function wrapperMenus(menus: MenuRecordRaw[], deep: boolean = true) { + return deep + ? mapTree(menus, (item) => { + return { ...cloneDeep(item), name: $t(item.name) }; + }) + : menus.map((item) => { + return { ...cloneDeep(item), name: $t(item.name) }; + }); } function toggleSidebar() { @@ -257,7 +266,7 @@ const headerSlots = computed(() => {