-
-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support for multiple think tank
- Loading branch information
Showing
10 changed files
with
81 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
<component-markdown-render [data]="data" showToc="true"></component-markdown-render> | ||
<div *ngIf="content"> | ||
<component-markdown-render [data]="content" showToc="true"></component-markdown-render> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,57 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import * as mdData from 'raw-loader!../../../assets/docs/think-tank/qa.md'; | ||
import { Title } from '@angular/platform-browser'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { HttpClient, HttpHeaders } from '@angular/common/http'; | ||
import { Thinktanks, thinktanks } from './thinktanks'; | ||
|
||
@Component({ | ||
selector: 'app-think-tank', | ||
templateUrl: './think-tank.component.html', | ||
styleUrls: ['./think-tank.component.scss'], | ||
}) | ||
export class ThinkTankComponent implements OnInit { | ||
data = mdData.default; | ||
currentSource: string; | ||
src: string; | ||
content: string; | ||
tanks: Thinktanks = thinktanks; | ||
|
||
constructor(title: Title) { | ||
title.setTitle('Ledge DevOps 知识平台 - 智库'); | ||
constructor( | ||
private title: Title, | ||
private activatedRoute: ActivatedRoute, | ||
private http: HttpClient | ||
) {} | ||
|
||
ngOnInit(): void { | ||
this.activatedRoute.paramMap.subscribe((p) => { | ||
const param = p.get('tank'); | ||
const currentCase = this.tanks.find((ca) => ca.source === param); | ||
this.title.setTitle( | ||
`${currentCase.displayName} DevOps 案例学习(互联网公司/传统公司) - Ledge DevOps 知识平台` | ||
); | ||
this.configSource(param); | ||
}); | ||
} | ||
|
||
private configSource(value: string) { | ||
this.getCase(value); | ||
} | ||
|
||
ngOnInit(): void {} | ||
async getCase(source: string) { | ||
this.src = this.buildSrc(source); | ||
this.currentSource = source; | ||
|
||
const headers = new HttpHeaders().set( | ||
'Content-Type', | ||
'text/plain; charset=utf-8' | ||
); | ||
this.http | ||
.get(this.src, { headers, responseType: 'text' }) | ||
.subscribe((response) => { | ||
this.content = response; | ||
}); | ||
} | ||
|
||
private buildSrc(source: string) { | ||
return `assets/docs/think-tank/${source}.md`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export interface Thinktank { | ||
displayName: string; | ||
source: string; | ||
default?: boolean; | ||
} | ||
|
||
export type Thinktanks = Array<Thinktank>; | ||
|
||
// todo: 优先级根据内容的质量重新排序。现在的是后来的在后面 + 内容多的在前面,随机组合 | ||
export const thinktanks: Thinktanks = [ | ||
{ displayName: 'QA', source: 'qa', default: true }, | ||
{ displayName: 'Android', source: 'mobile-android', default: true }, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.