Skip to content

Commit

Permalink
[webapp] bugfix can not auto change i18n data (#946)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsun28 authored May 12, 2023
1 parent 7383c6d commit 041da08
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 52 deletions.
4 changes: 2 additions & 2 deletions web-app/src/app/core/i18n/i18n.service.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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: {
Expand Down
3 changes: 0 additions & 3 deletions web-app/src/app/core/i18n/i18n.service.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -107,8 +106,6 @@ export class I18NService extends AlainI18nBaseService {
}

use(lang: string, data: Record<string, unknown>): void {
if (this._currentLang === lang) return;

this._data = this.flatData(data, []);

const item = LANGS[lang];
Expand Down
47 changes: 0 additions & 47 deletions web-app/src/app/core/startup/startup.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,54 +82,7 @@ export class StartupService {
);
}

private viaMock(): Observable<void> {
// 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: '[email protected]',
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<void> {
// 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();
}
}

0 comments on commit 041da08

Please sign in to comment.