Skip to content

Commit

Permalink
fix(abc:reuse-tab): fix can't cache when component is not used
Browse files Browse the repository at this point in the history
  • Loading branch information
devcui committed Mar 14, 2024
1 parent e672ea7 commit 110c44a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/abc/reuse-tab/reuse-tab.service.ts
Expand Up @@ -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);
Expand All @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions packages/theme/src/services/i18n/yunzai-i18n.ts
Expand Up @@ -68,11 +68,11 @@ export class YunzaiHttpI18NService extends YunzaiI18nBaseService implements OnDe

loadLangData(lang: string): Observable<NzSafeAny> {
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`)));
}
}

Expand Down

0 comments on commit 110c44a

Please sign in to comment.