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 new file mode 100644 index 0000000..72daad6 --- /dev/null +++ b/index/src/app/view/admin/admin-dashboard/admin-dashboard.component.html @@ -0,0 +1,41 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + +
{{logText}}
+
+
+
diff --git a/index/src/app/view/admin/admin-dashboard/admin-dashboard.component.less b/index/src/app/view/admin/admin-dashboard/admin-dashboard.component.less new file mode 100644 index 0000000..e69de29 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 new file mode 100644 index 0000000..200f37b --- /dev/null +++ b/index/src/app/view/admin/admin-dashboard/admin-dashboard.component.ts @@ -0,0 +1,55 @@ +import {Component, OnInit} from '@angular/core'; +import {HttpClient} from '@angular/common/http'; +import {ApiService} from '../../../api/api.service'; +import {GlobalUserService} from '../../../services/global-user.service'; +import {User} from '../../../class/User'; + +@Component({ + selector: 'app-admin-dashboard', + templateUrl: './admin-dashboard.component.html', + styleUrls: ['./admin-dashboard.component.less'] +}) +export class AdminDashboardComponent implements OnInit { + constructor(private apiService: ApiService, private userService: GlobalUserService, private http: HttpClient) { + this.getLog(); + this.getCounts(); + this.getDayVisitCount(); + this.getUserInfo(); + } + + logLoading: true; + logText: string; + counts: { + articleCount: number, + visitorCount: number, + categoryCount: number, + leaveMsgCount: number, + tagCount: number, + commentCount: number + } + dayVisitCount: number + userInfo: User; + + ngOnInit(): void { + } + + getLog() { + this.http.get('https://api.celess.cn/blog.log', {responseType: 'text'}).subscribe(data => { + this.logText = data; + }); + } + + getCounts = () => this.apiService.counts().subscribe({ + next: data => this.counts = data.result + }) + + getDayVisitCount = () => this.apiService.dayVisitCount().subscribe({ + next: data => this.dayVisitCount = data.result + }) + + getUserInfo = () => this.userService.watchUserInfo({ + next: data => this.userInfo = data.result, + 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 new file mode 100644 index 0000000..014d469 --- /dev/null +++ b/index/src/app/view/admin/admin-dashboard/admin-dashboard.module.ts @@ -0,0 +1,22 @@ +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'; + + +@NgModule({ + declarations: [AdminDashboardComponent], + imports: [ + CommonModule, + RouterModule.forChild([{path: '', component: AdminDashboardComponent}]), + NzGridModule, + NzCardModule, + NzButtonModule, + NzSpinModule, + NzIconModule, + NzStatisticModule + ] +}) +export class AdminDashboardModule { +} diff --git a/index/src/app/view/admin/admin-routing.module.ts b/index/src/app/view/admin/admin-routing.module.ts index c5d2359..9053df7 100644 --- a/index/src/app/view/admin/admin-routing.module.ts +++ b/index/src/app/view/admin/admin-routing.module.ts @@ -47,7 +47,7 @@ const routes: Routes = [ }, { path: '**', - loadChildren: () => import('./admin-index/admin-index.module').then(mod => mod.AdminIndexModule), + loadChildren: () => import('./admin-dashboard/admin-dashboard.module').then(mod => mod.AdminDashboardModule), canActivate: [AuthGuard] } ]