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