fix(token): token signature error
This commit is contained in:
@@ -62,14 +62,14 @@ export class HttpService {
|
||||
}
|
||||
if (o.body.code !== 0) {
|
||||
observer.error(o.body);
|
||||
errorService.httpException(o.body)
|
||||
errorService.httpException(o.body, request)
|
||||
} else {
|
||||
observer.next(o.body);
|
||||
}
|
||||
observer.complete();
|
||||
},
|
||||
error: err => {
|
||||
errorService.httpError(err);
|
||||
errorService.httpError(err,request);
|
||||
errorService.checkConnection();
|
||||
this.subscriptionQueue.splice(this.subscriptionQueue.indexOf(subscription), 1)
|
||||
},
|
||||
|
||||
@@ -1,40 +1,48 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Injectable, Injector} from '@angular/core';
|
||||
import {RequestObj, Response} from '../class/HttpReqAndResp';
|
||||
import {HttpService} from '../api/http/http.service';
|
||||
import {environment} from '../../environments/environment';
|
||||
import {Router} from '@angular/router';
|
||||
import {ComponentStateService} from './component-state.service';
|
||||
import {NzNotificationService} from 'ng-zorro-antd';
|
||||
import {HttpService} from '../api/http/http.service';
|
||||
import {LocalStorageService} from './local-storage.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ErrorService {
|
||||
|
||||
constructor(private httpService: HttpService, private router: Router,
|
||||
constructor(/*private httpService: HttpService,*/
|
||||
private router: Router,
|
||||
private injector: Injector,
|
||||
private componentStateService: ComponentStateService,
|
||||
private notification: NzNotificationService) {
|
||||
private notification: NzNotificationService,
|
||||
private localStorageService: LocalStorageService) {
|
||||
}
|
||||
|
||||
private static HTTP_ERROR_COUNT: number = 0;
|
||||
private readonly MAINTAIN_PAGE_PREFIX = '/maintain'
|
||||
private readonly ADMIN_PAGE_PREFIX = '/admin'
|
||||
|
||||
public httpError(err: any) {
|
||||
public httpError(err: any, request: RequestObj) {
|
||||
if (!environment.production) {
|
||||
console.log('error=>', err)
|
||||
console.log('error=>', err, request)
|
||||
}
|
||||
ErrorService.HTTP_ERROR_COUNT++;
|
||||
// this.httpService.getSubscriptionQueue().map(a => a.unsubscribe())
|
||||
}
|
||||
|
||||
public httpException(response: Response<any>) {
|
||||
public httpException(response: Response<any>, request: RequestObj) {
|
||||
if (!environment.production)
|
||||
console.log('exception=>', response)
|
||||
console.log('exception=>', response, request)
|
||||
if (response.code === -1 && response.msg === '重复请求') return
|
||||
if (this.componentStateService.currentPath === this.ADMIN_PAGE_PREFIX) {
|
||||
this.notification.create('error', `请求失败<${response.code}>`, `${response.msg}`);
|
||||
}
|
||||
// 3830 token签名错误
|
||||
if (response.code === 3830) {
|
||||
this.localStorageService.removeToken();
|
||||
}
|
||||
}
|
||||
|
||||
public checkConnection() {
|
||||
@@ -45,7 +53,7 @@ export class ErrorService {
|
||||
method: 'GET',
|
||||
url: environment.host + '/headerInfo'
|
||||
}
|
||||
this.httpService.get(req).subscribe({
|
||||
this.injector.get(HttpService).get(req).subscribe({
|
||||
next: () => null,
|
||||
error: () => {
|
||||
if (this.componentStateService.currentPath !== this.MAINTAIN_PAGE_PREFIX) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
export const environment = {
|
||||
production: false,
|
||||
logger: true,
|
||||
host: 'http://celess.cn:8082/'
|
||||
host: 'http://127.0.0.1/'
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user