合并为一个项目 #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

@@ -45,7 +45,7 @@ export class GlobalUserService {
// 获取数据
const subscription = this.getUserInfoFromServer();
return {
unsubscribe:()=>{
unsubscribe: () => {
this.userObserverArray.splice(this.userObserverArray.indexOf(observer), 1);
observer.complete();
subscription.unsubscribe()

View File

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

View File

@@ -89,7 +89,7 @@
</nz-layout>
</nz-layout>
<nz-drawer [nzClosable]="false" [nzVisible]="infoDrawerVisible" nzPlacement="right"
[nzTitle]="sayHelloTemp" (nzOnClose)="infoDrawerVisible = false" >
[nzTitle]="sayHelloTemp" (nzOnClose)="infoDrawerVisible = false">
<p>您最近一次登录是在:</p>
<p>{{user.recentlyLandedDate}}</p>
<br><br>
@@ -110,6 +110,11 @@
<i nz-icon nzType="edit" class="edit-icon" nzTheme="twotone" (click)="showEditInfoModal()"></i>
</nz-descriptions-item>
</nz-descriptions>
<div nz-row style="text-align: center">
<a (click)="logout()" style="width: 100%">注销</a>
</div>
<!-- TODO: 展示更多信息 -->
</nz-drawer>

View File

@@ -1,6 +1,7 @@
import {Component, OnInit} from '@angular/core';
import {FormControl, FormGroup} from '@angular/forms';
import {NzMessageService} from 'ng-zorro-antd';
import {Router} from '@angular/router';
import {GlobalUserService} from '../../services/global-user.service';
import {User} from '../../class/User';
import {ApiService} from '../../api/api.service';
@@ -12,14 +13,15 @@ import {ApiService} from '../../api/api.service';
})
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({
complete: () => null,
error: (err) => null,
next: data => {
console.log('更新user')
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;
logout() {
this.gUserService.logout();
this.router.navigateByUrl('/')
}
ngOnInit(): void {
this.editInfoFormGroup = new FormGroup({
desc: new FormControl(),
@@ -81,4 +88,5 @@ export class AdminComponent implements OnInit {
});
this.editInfoModalVisible = false;
}
}