合并为一个项目 #14
@@ -1,5 +1,5 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {UserService} from '../../services/user.service';
|
||||
import {Component, EventEmitter, OnInit, Output} from '@angular/core';
|
||||
import {GlobalUserService} from '../../services/global-user.service';
|
||||
import {User} from '../../class/User';
|
||||
|
||||
@Component({
|
||||
@@ -9,12 +9,14 @@ import {User} from '../../class/User';
|
||||
})
|
||||
export class AdminHeaderComponent implements OnInit {
|
||||
|
||||
constructor(private userService: UserService) {
|
||||
constructor(private userService: GlobalUserService) {
|
||||
}
|
||||
|
||||
user: User
|
||||
@Output() infoClicked = new EventEmitter<void>()
|
||||
|
||||
logout = () => this.userService.logout();
|
||||
infoClickedEvent = () => this.infoClicked.emit();
|
||||
|
||||
ngOnInit(): void {
|
||||
this.userService.watchUserInfo({
|
||||
|
||||
@@ -4,7 +4,7 @@ import {windowWidthChange} from '../../utils/util';
|
||||
import {ApiService} from '../../api/api.service';
|
||||
import {User} from '../../class/User';
|
||||
import {ComponentStateService} from '../../services/component-state.service';
|
||||
import {UserService} from '../../services/user.service';
|
||||
import {GlobalUserService} from '../../services/global-user.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-header',
|
||||
@@ -15,7 +15,7 @@ export class HeaderComponent implements OnInit {
|
||||
|
||||
constructor(private router: Router,
|
||||
public componentStateService: ComponentStateService,
|
||||
private userService: UserService) {
|
||||
private userService: GlobalUserService) {
|
||||
this.pageList = [
|
||||
{name: '首页', path: '/', icon: 'home', iconType: 'fill', show: true},
|
||||
{name: '分类', path: '/categories', icon: 'project', iconType: 'fill', show: true},
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {UserService} from '../../services/user.service';
|
||||
import {GlobalUserService} from '../../services/global-user.service';
|
||||
import {User} from '../../class/User';
|
||||
import {ApiService} from '../../api/api.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-admin',
|
||||
@@ -9,14 +10,16 @@ import {User} from '../../class/User';
|
||||
})
|
||||
export class AdminComponent implements OnInit {
|
||||
|
||||
constructor(public userService: UserService) {
|
||||
constructor(public gUserService: GlobalUserService, private apiService: ApiService) {
|
||||
}
|
||||
|
||||
user: User;
|
||||
isCollapsed: boolean = false;
|
||||
infoDrawerVisible: boolean = false;
|
||||
sayHelloContent: string;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.userService.watchUserInfo({
|
||||
this.gUserService.watchUserInfo({
|
||||
complete: () => null,
|
||||
error: (err) => null,
|
||||
next: data => {
|
||||
@@ -25,6 +28,23 @@ export class AdminComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
)
|
||||
const hours = new Date().getHours();
|
||||
if (hours < 6) {
|
||||
this.sayHelloContent = `夜深了,注意早点休息哦!${this.user.displayName}`
|
||||
} else if (hours < 10) {
|
||||
this.sayHelloContent = `早上好呀!${this.user.displayName}`
|
||||
} else if (hours < 14) {
|
||||
this.sayHelloContent = `中午好呀!${this.user.displayName}`
|
||||
} else if (hours < 19) {
|
||||
this.sayHelloContent = `下午好呀!${this.user.displayName}`
|
||||
} else if (hours < 22) {
|
||||
this.sayHelloContent = `晚上好呀!${this.user.displayName}`
|
||||
} else {
|
||||
this.sayHelloContent = `时间不早了,注意休息哦!${this.user.displayName}`
|
||||
}
|
||||
}
|
||||
|
||||
showInfoDrawer() {
|
||||
this.infoDrawerVisible = !this.infoDrawerVisible;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@ import {Injectable} from '@angular/core';
|
||||
import {CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree} from '@angular/router';
|
||||
import {Observable} from 'rxjs';
|
||||
import {User} from '../../class/User';
|
||||
import {UserService} from '../../services/user.service';
|
||||
import {GlobalUserService} from '../../services/global-user.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AuthGuard implements CanActivate {
|
||||
|
||||
constructor(private userService: UserService) {
|
||||
constructor(private userService: GlobalUserService) {
|
||||
userService.watchUserInfo({
|
||||
complete: () => null,
|
||||
error: (err) => {
|
||||
|
||||
@@ -7,7 +7,7 @@ import {User} from '../../class/User';
|
||||
import {CommentReq} from '../../class/Comment';
|
||||
import {PageList} from '../../class/HttpReqAndResp';
|
||||
import {Comment} from '../../class/Comment';
|
||||
import {UserService} from '../../services/user.service';
|
||||
import {GlobalUserService} from '../../services/global-user.service';
|
||||
|
||||
declare var editormd;
|
||||
declare var $;
|
||||
@@ -21,7 +21,7 @@ export class ArticleComponent implements OnInit {
|
||||
|
||||
constructor(private activatedRoute: ActivatedRoute,
|
||||
private apiService: ApiService,
|
||||
private userService: UserService,
|
||||
private userService: GlobalUserService,
|
||||
private titleService: Title,
|
||||
private router: Router) {
|
||||
this.articleId = +activatedRoute.snapshot.paramMap.get('id');
|
||||
|
||||
@@ -4,7 +4,7 @@ import {LoginReq} from '../../../../class/User';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {LoginRegistrationService} from '../../service/login-registration.service';
|
||||
import {Title} from '@angular/platform-browser';
|
||||
import {UserService} from '../../../../services/user.service';
|
||||
import {GlobalUserService} from '../../../../services/global-user.service';
|
||||
|
||||
@Component({
|
||||
selector: 'c-login',
|
||||
@@ -14,7 +14,7 @@ import {UserService} from '../../../../services/user.service';
|
||||
export class LoginComponent implements OnInit {
|
||||
|
||||
constructor(private nzMessageService: NzMessageService,
|
||||
private userService: UserService,
|
||||
private userService: GlobalUserService,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private router: Router,
|
||||
private loginRegistrationService: LoginRegistrationService,
|
||||
|
||||
@@ -7,7 +7,7 @@ import {NzMessageService} from 'ng-zorro-antd';
|
||||
import {User} from '../../class/User';
|
||||
import {Tag} from '../../class/Tag';
|
||||
import {Title} from '@angular/platform-browser';
|
||||
import {UserService} from '../../services/user.service';
|
||||
import {GlobalUserService} from '../../services/global-user.service';
|
||||
|
||||
@Component({
|
||||
selector: 'view-write',
|
||||
@@ -19,7 +19,7 @@ export class WriteComponent implements OnInit {
|
||||
constructor(private router: Router,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private apiService: ApiService,
|
||||
private userService: UserService,
|
||||
private userService: GlobalUserService,
|
||||
private message: NzMessageService,
|
||||
private titleService: Title) {
|
||||
this.titleService.setTitle('小海博客 | 创作');
|
||||
|
||||
Reference in New Issue
Block a user