fix: 正确显示当前版本

不再判断 title,而是增加一个专门的 mode 字段
This commit is contained in:
Zhicheng WANG 2020-06-13 09:30:57 +08:00
parent 412360f845
commit d9c3682df3
2 changed files with 5 additions and 4 deletions

View File

@ -160,8 +160,8 @@ export class AppComponent implements OnInit {
]).subscribe(([versionInfo, versions]) => { ]).subscribe(([versionInfo, versions]) => {
// TODO(pbd): consider whether we can lookup the stable and next versions from the internet // TODO(pbd): consider whether we can lookup the stable and next versions from the internet
const computedVersions: NavigationNode[] = [ const computedVersions: NavigationNode[] = [
{ title: 'next 版', url: 'https://next.angular.io/' }, { mode: 'next', title: 'next 版', url: 'https://next.angular.io/' },
{ title: '同步翻译版', url: 'https://angular.cn/' }, { mode: 'stable', title: '同步翻译版', url: 'https://angular.cn/' },
]; ];
if (this.deployment.mode === 'archive') { if (this.deployment.mode === 'archive') {
computedVersions.push({ title: `v${versionInfo.major}` }); computedVersions.push({ title: `v${versionInfo.major}` });
@ -171,7 +171,7 @@ export class AppComponent implements OnInit {
// Find the current version - eithers title matches the current deployment mode // Find the current version - eithers title matches the current deployment mode
// or its title matches the major version of the current version info // or its title matches the major version of the current version info
this.currentDocVersion = this.docVersions.find(version => this.currentDocVersion = this.docVersions.find(version =>
version.title === this.deployment.mode || version.title === `v${versionInfo.major}`)!; version.mode === this.deployment.mode || version.title === `v${versionInfo.major}`)!;
this.currentDocVersion.title += ` (v${versionInfo.raw})`; this.currentDocVersion.title += ` (v${versionInfo.raw})`;
}); });

View File

@ -9,6 +9,7 @@ export interface NavigationNode {
// always have `title`. // always have `title`.
title: string; title: string;
mode?: string;
url?: string; url?: string;
tooltip?: string; tooltip?: string;
hidden?: boolean; hidden?: boolean;
@ -18,7 +19,7 @@ export interface NavigationNode {
children?: NavigationNode[]; children?: NavigationNode[];
} }
export type NavigationResponse = {__versionInfo: VersionInfo } & { [name: string]: NavigationNode[]|VersionInfo }; export type NavigationResponse = { __versionInfo: VersionInfo } & { [name: string]: NavigationNode[] | VersionInfo };
export interface NavigationViews { export interface NavigationViews {
[name: string]: NavigationNode[]; [name: string]: NavigationNode[];