From 446d7e06e404e2397b4b674ef15667b19d8ee916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=B5=B7?= Date: Sat, 16 May 2020 21:55:35 +0800 Subject: [PATCH] =?UTF-8?q?=E9=92=88=E5=AF=B9=E6=99=AE=E9=80=9A=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=9A=84=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin-comment/admin-comment.component.ts | 31 +++++- .../admin-dashboard.component.html | 105 +++++++++++------- .../admin-dashboard.component.ts | 12 +- .../admin-dashboard/admin-dashboard.module.ts | 13 ++- index/src/app/view/admin/admin.component.html | 33 +++--- 5 files changed, 132 insertions(+), 62 deletions(-) diff --git a/index/src/app/view/admin/admin-comment/admin-comment.component.ts b/index/src/app/view/admin/admin-comment/admin-comment.component.ts index c17b567..f1693d1 100644 --- a/index/src/app/view/admin/admin-comment/admin-comment.component.ts +++ b/index/src/app/view/admin/admin-comment/admin-comment.component.ts @@ -3,6 +3,7 @@ import {NzMessageService} from 'ng-zorro-antd'; import {ApiService} from '../../../api/api.service'; import {PageList} from '../../../class/HttpReqAndResp'; import {Comment, CommentReq} from '../../../class/Comment'; +import {GlobalUserService} from '../../../services/global-user.service'; @Component({ selector: 'app-admin-comment', @@ -11,7 +12,23 @@ import {Comment, CommentReq} from '../../../class/Comment'; }) export class AdminCommentComponent implements OnInit { - constructor(private apiService: ApiService, private messageService: NzMessageService) { + constructor(private apiService: ApiService, private messageService: NzMessageService, private userService: GlobalUserService) { + this.userService.watchUserInfo({ + next: data => { + if (data.result) { + if (data.result.role === 'admin') { + this.getComment = this.getCommentForAdmin; + } else { + this.getComment = this.getCommentForUser; + } + } else { + this.getComment = this.getCommentForUser; + } + this.getComment() + }, + error: null, + complete: null + }) } loading: boolean = true; @@ -23,12 +40,20 @@ export class AdminCommentComponent implements OnInit { content: new CommentReq(true), editFocus: false, } + getComment: any;// 存放获取评论的方法 + ngOnInit(): void { - this.getComment(); } - getComment = () => this.apiService.getCommentByTypeForAdmin(true, this.pageIndex, this.pageSize).subscribe({ + + getCommentForAdmin = () => this.apiService.getCommentByTypeForAdmin(true, this.pageIndex, this.pageSize).subscribe({ + next: data => this.pageList = data.result, + complete: () => this.loading = false, + error: err => this.loading = false + }) + + getCommentForUser = () => this.apiService.getCommentByTypeForUser(true, this.pageIndex, this.pageSize).subscribe({ next: data => this.pageList = data.result, complete: () => this.loading = false, error: err => this.loading = false diff --git a/index/src/app/view/admin/admin-dashboard/admin-dashboard.component.html b/index/src/app/view/admin/admin-dashboard/admin-dashboard.component.html index 4678b48..90fd9d9 100644 --- a/index/src/app/view/admin/admin-dashboard/admin-dashboard.component.html +++ b/index/src/app/view/admin/admin-dashboard/admin-dashboard.component.html @@ -1,42 +1,67 @@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + +
{{logText}}
+
+
+
-
- - - - - -
{{logText}}
-
-
+
+
+ + + + +

此博客由 禾几海(郑海) 设计并实现的

+

博客自2019年3月开始开发编写 5月开始正式运行至今

+

博客所有代码都是开源的,你可以随意修改,运行和发布

+

+ 后端代码可以在此处找到 + + 前端代码可以在此处找到 +

+

如果觉得博客还不错,请前往Github支持我,给我点一个star吧

+
+ +

坚强的信心,能使平凡的人做出惊人的事业。

+

——马尔顿

+
+
diff --git a/index/src/app/view/admin/admin-dashboard/admin-dashboard.component.ts b/index/src/app/view/admin/admin-dashboard/admin-dashboard.component.ts index 0c3b807..e007eaf 100644 --- a/index/src/app/view/admin/admin-dashboard/admin-dashboard.component.ts +++ b/index/src/app/view/admin/admin-dashboard/admin-dashboard.component.ts @@ -11,9 +11,6 @@ import {User} from '../../../class/User'; }) export class AdminDashboardComponent implements OnInit { constructor(private apiService: ApiService, private userService: GlobalUserService, private http: HttpClient) { - this.getLog(); - this.getCounts(); - this.getDayVisitCount(); this.getUserInfo(); } @@ -50,7 +47,14 @@ export class AdminDashboardComponent implements OnInit { }) getUserInfo = () => this.userService.watchUserInfo({ - next: data => this.userInfo = data.result, + next: data => { + this.userInfo = data.result + if (data.result && data.result.role === 'admin') { + this.getLog(); + this.getCounts(); + this.getDayVisitCount(); + } + }, error: null, complete: null }) diff --git a/index/src/app/view/admin/admin-dashboard/admin-dashboard.module.ts b/index/src/app/view/admin/admin-dashboard/admin-dashboard.module.ts index 014d469..38c15ea 100644 --- a/index/src/app/view/admin/admin-dashboard/admin-dashboard.module.ts +++ b/index/src/app/view/admin/admin-dashboard/admin-dashboard.module.ts @@ -2,7 +2,15 @@ import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; import {AdminDashboardComponent} from './admin-dashboard.component'; import {RouterModule} from '@angular/router'; -import {NzButtonModule, NzCardModule, NzGridModule, NzIconModule, NzSpinModule, NzStatisticModule} from 'ng-zorro-antd'; +import { + NzButtonModule, + NzCardModule, + NzDividerModule, + NzGridModule, + NzIconModule, + NzSpinModule, + NzStatisticModule +} from 'ng-zorro-antd'; @NgModule({ @@ -15,7 +23,8 @@ import {NzButtonModule, NzCardModule, NzGridModule, NzIconModule, NzSpinModule, NzButtonModule, NzSpinModule, NzIconModule, - NzStatisticModule + NzStatisticModule, + NzDividerModule ] }) export class AdminDashboardModule { diff --git a/index/src/app/view/admin/admin.component.html b/index/src/app/view/admin/admin.component.html index 6ff73c2..5d8d204 100644 --- a/index/src/app/view/admin/admin.component.html +++ b/index/src/app/view/admin/admin.component.html @@ -43,10 +43,10 @@ - - - - +
  • + + 查看信息 +
  • @@ -95,19 +95,26 @@

    - - {{user.email}} - + +
    + + {{user.email}} + +
    - - {{user.displayName}} - +
    + + {{user.displayName}} + +
    - - {{user.desc}} - +
    + + {{user.desc}} + +