合并为一个项目 #14
@@ -45,7 +45,7 @@ export class GlobalUserService {
|
|||||||
// 获取数据
|
// 获取数据
|
||||||
const subscription = this.getUserInfoFromServer();
|
const subscription = this.getUserInfoFromServer();
|
||||||
return {
|
return {
|
||||||
unsubscribe:()=>{
|
unsubscribe: () => {
|
||||||
this.userObserverArray.splice(this.userObserverArray.indexOf(observer), 1);
|
this.userObserverArray.splice(this.userObserverArray.indexOf(observer), 1);
|
||||||
observer.complete();
|
observer.complete();
|
||||||
subscription.unsubscribe()
|
subscription.unsubscribe()
|
||||||
|
|||||||
@@ -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
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@
|
|||||||
</nz-layout>
|
</nz-layout>
|
||||||
</nz-layout>
|
</nz-layout>
|
||||||
<nz-drawer [nzClosable]="false" [nzVisible]="infoDrawerVisible" nzPlacement="right"
|
<nz-drawer [nzClosable]="false" [nzVisible]="infoDrawerVisible" nzPlacement="right"
|
||||||
[nzTitle]="sayHelloTemp" (nzOnClose)="infoDrawerVisible = false" >
|
[nzTitle]="sayHelloTemp" (nzOnClose)="infoDrawerVisible = false">
|
||||||
<p>您最近一次登录是在:</p>
|
<p>您最近一次登录是在:</p>
|
||||||
<p>{{user.recentlyLandedDate}}</p>
|
<p>{{user.recentlyLandedDate}}</p>
|
||||||
<br><br>
|
<br><br>
|
||||||
@@ -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>
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user