From 110c44acbef03884b482c3668626bd4161276406 Mon Sep 17 00:00:00 2001 From: devcui Date: Thu, 14 Mar 2024 10:11:19 +0800 Subject: [PATCH] fix(abc:reuse-tab): fix can't cache when component is not used --- packages/abc/reuse-tab/reuse-tab.service.ts | 6 +++--- packages/theme/src/services/i18n/yunzai-i18n.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/abc/reuse-tab/reuse-tab.service.ts b/packages/abc/reuse-tab/reuse-tab.service.ts index 8dcaf387..84114cce 100644 --- a/packages/abc/reuse-tab/reuse-tab.service.ts +++ b/packages/abc/reuse-tab/reuse-tab.service.ts @@ -475,8 +475,6 @@ export class ReuseTabService implements OnDestroy { */ store(_snapshot: ActivatedRouteSnapshot, _handle: NzSafeAny): void { const url = this.getUrl(_snapshot); - const idx = this.index(url); - if (idx === -1) return; if (_handle != null) { this.saveCache(_snapshot, _handle); @@ -492,9 +490,11 @@ export class ReuseTabService implements OnDestroy { _snapshot, _handle }; + + const idx = this.index(url); // Current handler is null when activate routes // For better reliability, we need to wait for the component to be attached before call _onReuseInit - const cahcedComponentRef = list[idx]._handle?.componentRef; + const cahcedComponentRef = list[idx]?._handle?.componentRef; if (_handle == null && cahcedComponentRef != null) { timer(100) .pipe(take(1)) diff --git a/packages/theme/src/services/i18n/yunzai-i18n.ts b/packages/theme/src/services/i18n/yunzai-i18n.ts index 3a94b254..a35442a6 100644 --- a/packages/theme/src/services/i18n/yunzai-i18n.ts +++ b/packages/theme/src/services/i18n/yunzai-i18n.ts @@ -68,11 +68,11 @@ export class YunzaiHttpI18NService extends YunzaiI18nBaseService implements OnDe loadLangData(lang: string): Observable { if (ngDevMode) { - return this.http.get(`assets/tmp/i18n/${lang}.json`); + return this.http.get(`./assets/tmp/i18n/${lang}.json`); } else { return this.http .get(`/i18n/api/v2/language/${lang}`) - .pipe(catchError(() => this.http.get(`assets/tmp/i18n/${lang}.json`))); + .pipe(catchError(() => this.http.get(`./assets/tmp/i18n/${lang}.json`))); } }