Skip to content

Commit

Permalink
bugfix return old cache json file when upgrade version (#1137)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsun28 authored Jul 27, 2023
1 parent a791f45 commit ac08d04
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion web-app/src/app/core/i18n/i18n.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Platform } from '@angular/cdk/platform';
import { registerLocaleData } from '@angular/common';
import { HttpHeaders } from '@angular/common/http';
import ngEn from '@angular/common/locales/en';
import ngZh from '@angular/common/locales/zh';
import ngZhTw from '@angular/common/locales/zh-Hant';
Expand Down Expand Up @@ -94,7 +95,8 @@ export class I18NService extends AlainI18nBaseService {
}

loadLangData(lang: string): Observable<NzSafeAny> {
return zip(this.http.get(`./assets/i18n/${lang}.json`), this.http.get(`/i18n/${lang}`)).pipe(
const headers = new HttpHeaders({ 'Cache-Control': 'no-cache' });
return zip(this.http.get(`./assets/i18n/${lang}.json`, null, { headers: headers }), this.http.get(`/i18n/${lang}`)).pipe(
map(([langLocalData, langRemoteData]: [Record<string, string>, Message<any>]) => {
let remote: Record<string, string> = langRemoteData.data;
Object.keys(remote).forEach(key => {
Expand Down
9 changes: 5 additions & 4 deletions web-app/src/app/core/startup/startup.service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { HttpClient } from '@angular/common/http';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable, Inject } from '@angular/core';
import { Router } from '@angular/router';
import { ACLService } from '@delon/acl';
import { DA_SERVICE_TOKEN, ITokenService } from '@delon/auth';
import { ALAIN_I18N_TOKEN, Menu, MenuService, SettingsService, TitleService } from '@delon/theme';
import type { NzSafeAny } from 'ng-zorro-antd/core/types';
import { NzIconService } from 'ng-zorro-antd/icon';
import { Observable, zip, of } from 'rxjs';
import { Observable, zip } from 'rxjs';
import { catchError, map } from 'rxjs/operators';

import { ICONS } from '../../../style-icons';
Expand Down Expand Up @@ -39,9 +39,10 @@ export class StartupService {

public loadConfigResourceViaHttp(): Observable<void> {
const defaultLang = this.i18n.defaultLang;
const headers = new HttpHeaders({ 'Cache-Control': 'no-cache' });
return zip(
this.i18n.loadLangData(defaultLang),
this.httpClient.get('./assets/app-data.json'),
this.httpClient.get('./assets/app-data.json', { headers: headers }),
this.httpClient.get('/apps/hierarchy')
).pipe(
catchError((res: NzSafeAny) => {
Expand Down Expand Up @@ -74,7 +75,7 @@ export class StartupService {
});
}
});
// 刷新菜单
// flush menu
this.menuService.resume();
// Can be set page suffix title, https://ng-alain.com/theme/title
this.titleService.suffix = appData.app.name;
Expand Down

0 comments on commit ac08d04

Please sign in to comment.