From c234ad52ea874b2589561371587c184d98e3ab42 Mon Sep 17 00:00:00 2001 From: alexchen Date: Tue, 23 Jul 2024 11:18:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix():=20=E5=A6=82=E6=9E=9C=E5=B0=8F?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E8=87=AA=E5=AE=9A=E4=B9=89=E4=BA=86title?= =?UTF-8?q?=E6=97=A0=E8=AE=BA=E4=BB=80=E4=B9=88=E6=83=85=E5=86=B5=E9=83=BD?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E8=87=AA=E5=AE=9A=E4=B9=89title?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/runtime/src/internal/Runtime.spec.ts | 2 +- packages/runtime/src/internal/Runtime.ts | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/runtime/src/internal/Runtime.spec.ts b/packages/runtime/src/internal/Runtime.spec.ts index 20ecc9316a..65f65978a6 100644 --- a/packages/runtime/src/internal/Runtime.spec.ts +++ b/packages/runtime/src/internal/Runtime.spec.ts @@ -1412,7 +1412,7 @@ describe("Runtime", () => { getRuntime().applyPageTitle("Hello"); expect(document.title).toBe("Hi there"); getRuntime().applyPageTitle(""); - expect(document.title).toBe("DevOps 管理专家"); + expect(document.title).toBe("Hi there"); expect(finishPageView).toBeCalledTimes(1); expect(finishPageView).toBeCalledWith({ pageTitle: "DevOps 管理专家", diff --git a/packages/runtime/src/internal/Runtime.ts b/packages/runtime/src/internal/Runtime.ts index 51df0aa987..4bb98c029d 100644 --- a/packages/runtime/src/internal/Runtime.ts +++ b/packages/runtime/src/internal/Runtime.ts @@ -287,10 +287,11 @@ export class Runtime { applyPageTitle(pageTitle: string): void { const baseTitle = this.getBrandSettings().base_title; - document.title = pageTitle - ? (router?.getRecentApps().currentApp?.localeTitle as string) || - `${pageTitle} - ${baseTitle}` - : baseTitle; + + document.title = + (router?.getRecentApps().currentApp?.localeTitle as string) || pageTitle + ? `${pageTitle} - ${baseTitle}` + : baseTitle; } getNavConfig() { From e86eba18d1ef3893d76434281f3cdd632872737c Mon Sep 17 00:00:00 2001 From: alexchen Date: Tue, 23 Jul 2024 11:40:25 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix():=20=E5=A6=82=E6=9E=9C=E5=B0=8F?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E8=87=AA=E5=AE=9A=E4=B9=89=E4=BA=86title?= =?UTF-8?q?=E6=97=A0=E8=AE=BA=E4=BB=80=E4=B9=88=E6=83=85=E5=86=B5=E9=83=BD?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E8=87=AA=E5=AE=9A=E4=B9=89title?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/runtime/src/internal/Runtime.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/runtime/src/internal/Runtime.ts b/packages/runtime/src/internal/Runtime.ts index 4bb98c029d..8320f622d6 100644 --- a/packages/runtime/src/internal/Runtime.ts +++ b/packages/runtime/src/internal/Runtime.ts @@ -289,9 +289,8 @@ export class Runtime { const baseTitle = this.getBrandSettings().base_title; document.title = - (router?.getRecentApps().currentApp?.localeTitle as string) || pageTitle - ? `${pageTitle} - ${baseTitle}` - : baseTitle; + (router?.getRecentApps().currentApp?.localeTitle as string) || + (pageTitle ? `${pageTitle} - ${baseTitle}` : baseTitle); } getNavConfig() {