主菜单令牌检测

change
panqihua 5 years ago
parent bea1f26c0a
commit 5185cba901
  1. 10
      src/app/account/score/score.component.ts
  2. 8
      src/app/forum/forum/forum.component.ts
  3. 5
      src/app/forum/notice/notice.component.ts
  4. 10
      src/app/visitor/visitor/visitor.component.ts

@ -5,6 +5,8 @@ import {ScoreService} from './score.service';
import {MessageInterface, MessageUtil} from '../../message/message.service';
import {Page} from '../../interface/Page';
import {Info} from '../../interface/Info';
import {AbstractRoute} from '../../AbstractRoute';
import {Router} from '@angular/router';
@Component({
selector: 'app-score',
@ -40,7 +42,9 @@ export class ScoreComponent extends Commons implements OnInit, MessageInterface
constructor(
private fb: FormBuilder,
private scoreService: ScoreService,
private messageUtil: MessageUtil
private messageUtil: MessageUtil,
private abstractRoute: AbstractRoute,
private router: Router,
) {
super();
}
@ -70,7 +74,11 @@ export class ScoreComponent extends Commons implements OnInit, MessageInterface
}
ngOnInit(): void {
if (this.abstractRoute.isLogin()) {
this.loadAll(this.currentPage);
} else {
this.router.navigateByUrl('/login');
}
}
prefix(key: string): string {

@ -8,6 +8,7 @@ import {MessageInterface, MessageUtil} from '../../message/message.service';
import {NoticeService} from '../notice/notice.service';
import {TranslateService} from '@ngx-translate/core';
import {ForumNewResponse} from '../../interface/Response';
import {AbstractRoute} from '../../AbstractRoute';
/**
*
@ -57,7 +58,8 @@ export class ForumComponent implements OnInit, MessageInterface {
private forumService: ForumService,
private noticeService: NoticeService,
private messageUtil: MessageUtil,
private translate: TranslateService
private translate: TranslateService,
private abstractRoute: AbstractRoute
) {
}
@ -129,8 +131,12 @@ export class ForumComponent implements OnInit, MessageInterface {
}
ngOnInit(): void {
if (this.abstractRoute.isLogin()) {
this.getAllNotices();
this.getAllPosts(this.currentPage);
} else {
this.router.navigateByUrl('/login');
}
}
prefix(key: string): string {

@ -7,6 +7,7 @@ import {MessageInterface, MessageUtil} from '../../message/message.service';
import {CookieService} from 'ngx-cookie-service';
import {environment} from '../../../environments/environment';
import {Router} from '@angular/router';
import {AbstractRoute} from '../../AbstractRoute';
@Component({
selector: 'app-notice',
@ -31,6 +32,7 @@ export class NoticeComponent extends Commons implements OnInit, MessageInterface
private messageUtil: MessageUtil,
private cookieService: CookieService,
private router: Router,
private abstractRoute: AbstractRoute
) {
super();
}
@ -56,6 +58,9 @@ export class NoticeComponent extends Commons implements OnInit, MessageInterface
}
ngOnInit(): void {
if (!this.abstractRoute.isLogin()) {
this.router.navigateByUrl('/login');
}
}

@ -6,6 +6,8 @@ import {Visitor} from '../../interface/Visitor';
import {Page} from '../../interface/Page';
import {environment} from '../../../environments/environment';
import {CookieService} from 'ngx-cookie-service';
import {AbstractRoute} from '../../AbstractRoute';
import {Router} from '@angular/router';
@Component({
selector: 'app-visitor',
@ -16,7 +18,9 @@ export class VisitorComponent implements OnInit, MessageInterface {
constructor(private visitorService: VisitorService,
private messageUtil: MessageUtil,
private cookieService: CookieService
private cookieService: CookieService,
private abstractRoute: AbstractRoute,
private router: Router,
) {
}
@ -55,7 +59,11 @@ export class VisitorComponent implements OnInit, MessageInterface {
}
ngOnInit(): void {
if (this.abstractRoute.isLogin()) {
this.loadAll(this.currentPage);
} else {
this.router.navigateByUrl('/login');
}
}
}

Loading…
Cancel
Save