From f0a5f02588eac18225e7c8ccb353e75344db8611 Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Tue, 16 Nov 2021 13:16:04 +0800 Subject: [PATCH 1/4] fix: i18n --- src/utils/storage/responsive.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/storage/responsive.ts b/src/utils/storage/responsive.ts index af71dc3e3..6288b47b5 100644 --- a/src/utils/storage/responsive.ts +++ b/src/utils/storage/responsive.ts @@ -13,6 +13,7 @@ export const injectResponsiveStorage = (app: App, config: ServerConfigs) => { parentPath: "/", meta: { title: "message.hshome", + i18n: true, icon: "el-icon-s-home", showLink: true } From 35f2f9e93f4651164ab894f75aad86935ff64f1f Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Tue, 16 Nov 2021 13:49:24 +0800 Subject: [PATCH 2/4] fix: i18n --- src/router/index.ts | 15 ++++++++------- src/utils/i18n.ts | 3 ++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/router/index.ts b/src/router/index.ts index 5ed644572..8980e85b4 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -208,14 +208,15 @@ router.beforeEach((to, _from, next) => { const name = storageSession.getItem("info"); NProgress.start(); const externalLink = to?.redirectedFrom?.fullPath; - // @ts-ignore - // const { t } = i18n.global; - // @ts-ignore if (!externalLink) - to.meta.title - ? // @ts-ignore - (document.title = transformI18n(to.meta.title, to.meta.i18n)) - : ""; + to.matched.some(item => { + item.meta.title + ? (document.title = transformI18n( + item.meta.title as string, + item.meta?.i18n as boolean + )) + : ""; + }); if (name) { if (_from?.name) { // 如果路由包含http 则是超链接 反之是普通路由 diff --git a/src/utils/i18n.ts b/src/utils/i18n.ts index 22153e93a..62b9e0a2b 100644 --- a/src/utils/i18n.ts +++ b/src/utils/i18n.ts @@ -1,11 +1,12 @@ import { i18n } from "../plugins/i18n"; + /** * 消息转换 * @param message message * @param isI18n 如果true,获取对应的消息,否则返回this * @returns message */ -export function transformI18n(message = "", isI18n: Boolean = false) { +export function transformI18n(message = "", isI18n = false) { if (!message) { return ""; } From 7aa895a2b72d558af72f74a9ce1c698a562d89b8 Mon Sep 17 00:00:00 2001 From: paobai <37954147+paobai@users.noreply.github.com> Date: Tue, 16 Nov 2021 15:52:58 +0800 Subject: [PATCH 3/4] perf: storage hooks --- src/utils/storage/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/storage/index.ts b/src/utils/storage/index.ts index 12a5df502..f4580f616 100644 --- a/src/utils/storage/index.ts +++ b/src/utils/storage/index.ts @@ -20,7 +20,7 @@ class sessionStorageProxy implements ProxyStorage { // 取 public getItem(key: string): any { - return JSON.parse(this.storage.getItem(key)) || null; + return JSON.parse(this.storage.getItem(key)); } // 删 From 6b064bdef9500d61299022a79512ac45a9c7d01a Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Tue, 16 Nov 2021 22:21:05 +0800 Subject: [PATCH 4/4] fix: icon --- src/utils/storage/responsive.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/storage/responsive.ts b/src/utils/storage/responsive.ts index 6288b47b5..4df889f00 100644 --- a/src/utils/storage/responsive.ts +++ b/src/utils/storage/responsive.ts @@ -14,7 +14,7 @@ export const injectResponsiveStorage = (app: App, config: ServerConfigs) => { meta: { title: "message.hshome", i18n: true, - icon: "el-icon-s-home", + icon: "HomeFilled", showLink: true } }