From cdd0ce0638a4c67a3b9249525e1a88dd88ef6ebf Mon Sep 17 00:00:00 2001 From: tomsun28 Date: Fri, 12 May 2023 11:46:11 +0800 Subject: [PATCH] [webapp] bugfix can not auto change i18n data (#946) --- .../src/app/core/i18n/i18n.service.spec.ts | 4 +- web-app/src/app/core/i18n/i18n.service.ts | 3 -- .../src/app/core/startup/startup.service.ts | 47 ------------------- 3 files changed, 2 insertions(+), 52 deletions(-) diff --git a/web-app/src/app/core/i18n/i18n.service.spec.ts b/web-app/src/app/core/i18n/i18n.service.spec.ts index 8f1243c6039..989c1332de9 100644 --- a/web-app/src/app/core/i18n/i18n.service.spec.ts +++ b/web-app/src/app/core/i18n/i18n.service.spec.ts @@ -1,5 +1,5 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { TestBed, TestBedStatic } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { DelonLocaleService, SettingsService } from '@delon/theme'; import { NzSafeAny } from 'ng-zorro-antd/core/types'; import { NzI18nService } from 'ng-zorro-antd/i18n'; @@ -8,7 +8,7 @@ import { of } from 'rxjs'; import { I18NService } from './i18n.service'; describe('Service: I18n', () => { - let injector: TestBedStatic; + let injector: TestBed; let srv: I18NService; const MockSettingsService: NzSafeAny = { layout: { diff --git a/web-app/src/app/core/i18n/i18n.service.ts b/web-app/src/app/core/i18n/i18n.service.ts index 5a9e0af7e2f..91d2f20f9d8 100644 --- a/web-app/src/app/core/i18n/i18n.service.ts +++ b/web-app/src/app/core/i18n/i18n.service.ts @@ -1,4 +1,3 @@ -// 请参考:https://ng-alain.com/docs/i18n import { Platform } from '@angular/cdk/platform'; import { registerLocaleData } from '@angular/common'; import ngEn from '@angular/common/locales/en'; @@ -107,8 +106,6 @@ export class I18NService extends AlainI18nBaseService { } use(lang: string, data: Record): void { - if (this._currentLang === lang) return; - this._data = this.flatData(data, []); const item = LANGS[lang]; diff --git a/web-app/src/app/core/startup/startup.service.ts b/web-app/src/app/core/startup/startup.service.ts index 6e7f821c715..72c8adc5447 100644 --- a/web-app/src/app/core/startup/startup.service.ts +++ b/web-app/src/app/core/startup/startup.service.ts @@ -82,54 +82,7 @@ export class StartupService { ); } - private viaMock(): Observable { - // const tokenData = this.tokenService.get(); - // if (!tokenData.token) { - // this.router.navigateByUrl(this.tokenService.login_url!); - // return; - // } - // mock - const app: any = { - name: `HertzBeat`, - description: `面向开发者,易用友好的高性能监控云服务` - }; - const user: any = { - name: 'Admin', - avatar: './assets/tmp/img/avatar.svg', - email: 'tomsun28@outlook.com', - token: '123456789' - }; - // Application information: including site name, description, year - this.settingService.setApp(app); - // User information: including name, avatar, email address - this.settingService.setUser(user); - // ACL: Set the permissions to full, https://ng-alain.com/acl/getting-started - this.aclService.setFull(true); - // Menu data, https://ng-alain.com/theme/menu - this.menuService.add([ - { - text: 'Main', - group: true, - children: [ - { - text: 'Dashboard', - link: '/dashboard', - icon: { type: 'icon', value: 'appstore' } - } - ] - } - ]); - // Can be set page suffix title, https://ng-alain.com/theme/title - this.titleService.suffix = app.name; - - return of(); - } - load(): Observable { - // http return this.loadConfigResourceViaHttp(); - // mock: Don’t use it in a production environment. ViaMock is just to simulate some data to make the scaffolding work normally - // mock:请勿在生产环境中这么使用,viaMock 单纯只是为了模拟一些数据使脚手架一开始能正常运行 - // return this.viaMockI18n(); } }