合并为一个项目 #14

Merged
xiaohai2271 merged 56 commits from issue11 into master 2020-05-16 22:35:08 +08:00
4 changed files with 24 additions and 9 deletions
Showing only changes of commit dc17bba056 - Show all commits

View File

@@ -17,8 +17,8 @@ export class AdminDashboardComponent implements OnInit {
this.getUserInfo(); this.getUserInfo();
} }
logLoading: true; logLoading: boolean = true;
logText: string; logText: string = null;
counts: { counts: {
articleCount: number, articleCount: number,
visitorCount: number, visitorCount: number,
@@ -26,9 +26,10 @@ export class AdminDashboardComponent implements OnInit {
leaveMsgCount: number, leaveMsgCount: number,
tagCount: number, tagCount: number,
commentCount: number commentCount: number
} } = {articleCount: 0, visitorCount: 0, categoryCount: 0, tagCount: 0, commentCount: 0, leaveMsgCount: 0}
dayVisitCount: number
userInfo: User; dayVisitCount: number = 0;
userInfo: User = new User();
ngOnInit(): void { ngOnInit(): void {
} }
@@ -36,6 +37,7 @@ export class AdminDashboardComponent implements OnInit {
getLog() { getLog() {
this.http.get('https://api.celess.cn/blog.log', {responseType: 'text'}).subscribe(data => { this.http.get('https://api.celess.cn/blog.log', {responseType: 'text'}).subscribe(data => {
this.logText = data; this.logText = data;
this.logLoading = false
}); });
} }

View File

@@ -110,6 +110,11 @@
<i nz-icon nzType="edit" class="edit-icon" nzTheme="twotone" (click)="showEditInfoModal()"></i> <i nz-icon nzType="edit" class="edit-icon" nzTheme="twotone" (click)="showEditInfoModal()"></i>
</nz-descriptions-item> </nz-descriptions-item>
</nz-descriptions> </nz-descriptions>
<div nz-row style="text-align: center">
<a (click)="logout()" style="width: 100%">注销</a>
</div>
<!-- TODO: 展示更多信息 --> <!-- TODO: 展示更多信息 -->
</nz-drawer> </nz-drawer>

View File

@@ -1,6 +1,7 @@
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {FormControl, FormGroup} from '@angular/forms'; import {FormControl, FormGroup} from '@angular/forms';
import {NzMessageService} from 'ng-zorro-antd'; import {NzMessageService} from 'ng-zorro-antd';
import {Router} from '@angular/router';
import {GlobalUserService} from '../../services/global-user.service'; import {GlobalUserService} from '../../services/global-user.service';
import {User} from '../../class/User'; import {User} from '../../class/User';
import {ApiService} from '../../api/api.service'; import {ApiService} from '../../api/api.service';
@@ -12,14 +13,15 @@ import {ApiService} from '../../api/api.service';
}) })
export class AdminComponent implements OnInit { export class AdminComponent implements OnInit {
constructor(public gUserService: GlobalUserService, private apiService: ApiService, private messageService: NzMessageService) { constructor(public gUserService: GlobalUserService, private apiService: ApiService, private messageService: NzMessageService,
private router: Router) {
this.gUserService.watchUserInfo({ this.gUserService.watchUserInfo({
complete: () => null, complete: () => null,
error: (err) => null, error: (err) => null,
next: data => { next: data => {
console.log('更新user') console.log('更新user')
this.user = data.result this.user = data.result
this.initHelloWords() if (data.result) this.initHelloWords()
} }
} }
) )
@@ -34,6 +36,11 @@ export class AdminComponent implements OnInit {
showInfoDrawer = () => this.infoDrawerVisible = !this.infoDrawerVisible; showInfoDrawer = () => this.infoDrawerVisible = !this.infoDrawerVisible;
logout() {
this.gUserService.logout();
this.router.navigateByUrl('/')
}
ngOnInit(): void { ngOnInit(): void {
this.editInfoFormGroup = new FormGroup({ this.editInfoFormGroup = new FormGroup({
desc: new FormControl(), desc: new FormControl(),
@@ -81,4 +88,5 @@ export class AdminComponent implements OnInit {
}); });
this.editInfoModalVisible = false; this.editInfoModalVisible = false;
} }
} }