Browse Source

[完善] 项目说明完善

master
陈鹏飞 4 years ago
parent
commit
be41d36158
  1. 4
      README.md
  2. 14
      src/app/app.component.ts
  3. 19
      src/app/http-interceptors/base-interceptor.ts

4
README.md

@ -1,6 +1,4 @@
智能实战指挥平台-前端项目
---广西 演示
指挥员指挥能力考评抽签-前端项目
项目初始化:npm install

14
src/app/app.component.ts

@ -16,20 +16,6 @@ export class AppComponent {
constructor(private http:HttpClient,private router:Router,public token:CacheTokenService) { }
ngOnInit(): void {
var token = sessionStorage.getItem("token");
var refreshToken = sessionStorage.getItem("refreshToken");
if(token && refreshToken) {
this.http.post('/api/Account/RefreshToken', {
token: token,
refreshToken: refreshToken
}).subscribe((data: Data) => {
sessionStorage.setItem("level",data.level);
sessionStorage.setItem("token",data.token);
sessionStorage.setItem("refreshToken",data.refreshToken);
this.token.startUp()
})
}
}

19
src/app/http-interceptors/base-interceptor.ts

@ -44,26 +44,13 @@ export class BaseInterceptor implements HttpInterceptor {
private handleError(error: HttpErrorResponse) {
// 用户认证失败返回登录页
if (error.status === 401||error.status === 614) {
this.token.delete()
sessionStorage.clear()
window.localStorage.clear()
this.router.navigate(['ui/plan'])
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('用户认证信息过期,请重新登录','确定',config);
}
if (error.status === 403) {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('对不起,您无此权限','确定',config);
}
if (error.status === 400) {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('请核对您的输入格式是否正确','确定',config);
}
if (error.error instanceof ErrorEvent) {

Loading…
Cancel
Save