From 29ee2dc144627a9cfba3becda958578c5aec1a5d Mon Sep 17 00:00:00 2001 From: "Henry.Huang" Date: Wed, 12 Oct 2022 14:18:43 +0800 Subject: [PATCH] fix: i18n --- .editorconfig | 2 +- mock/model/route.ts | 8 ++++---- .../common/GlobalTab/components/TabDetail/index.vue | 3 ++- src/locales/i18n.ts | 2 +- src/router/guard/index.ts | 3 ++- src/utils/router/menu.ts | 3 ++- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.editorconfig b/.editorconfig index 02bb57fb..0552777e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,7 +4,7 @@ root = true [*] charset = utf-8 -indent_style = tab +indent_style = space indent_size = 2 end_of_line = lf trim_trailing_whitespace = true diff --git a/mock/model/route.ts b/mock/model/route.ts index d87de653..d5f31e81 100644 --- a/mock/model/route.ts +++ b/mock/model/route.ts @@ -10,7 +10,7 @@ export const routeModel: Record = { path: '/dashboard/analysis', component: 'self', meta: { - title: '分析页', + title: 'message.routes.dashboard.analysis', requiresAuth: true, icon: 'icon-park-outline:analysis' } @@ -20,14 +20,14 @@ export const routeModel: Record = { path: '/dashboard/workbench', component: 'self', meta: { - title: '工作台', + title: 'message.routes.dashboard.workbench', requiresAuth: true, icon: 'icon-park-outline:workbench' } } ], meta: { - title: '仪表盘', + title: 'message.routes.dashboard.dashboard', icon: 'mdi:monitor-dashboard', order: 1 } @@ -502,7 +502,7 @@ export const routeModel: Record = { path: '/about', component: 'self', meta: { - title: '关于', + title: 'message.routes.about.about', requiresAuth: true, singleLayout: 'basic', icon: 'fluent:book-information-24-regular', diff --git a/src/layouts/common/GlobalTab/components/TabDetail/index.vue b/src/layouts/common/GlobalTab/components/TabDetail/index.vue index de50973a..ec852e6d 100644 --- a/src/layouts/common/GlobalTab/components/TabDetail/index.vue +++ b/src/layouts/common/GlobalTab/components/TabDetail/index.vue @@ -18,7 +18,7 @@ :local-icon="item.meta.localIcon" class="inline-block align-text-bottom mr-4px text-16px" /> - {{ item.meta.title }} + {{ t(item.meta.title) }} { // 设置document title - useTitle(to.meta.title); + useTitle(t(to.meta.title)); // 结束 loadingBar window.$loadingBar?.finish(); }); diff --git a/src/utils/router/menu.ts b/src/utils/router/menu.ts index de7db1ee..2a2a58e9 100644 --- a/src/utils/router/menu.ts +++ b/src/utils/router/menu.ts @@ -1,4 +1,5 @@ import { useIconRender } from '@/composables'; +import { t } from '@/locales'; /** 路由不转换菜单 */ function hideInMenu(route: AuthRoute.Route) { @@ -48,7 +49,7 @@ export function transformAuthRouteToMenu(routes: AuthRoute.Route[]): GlobalMenuO const menuItem: GlobalMenuOption = addPartialProps({ menu: { key: routeName, - label: meta.title, + label: t(meta.title), routeName, routePath: path },