Browse Source

[完善]更改cookie存储为会话存储

develop
陈鹏飞 5 years ago
parent
commit
4743f4d197
  1. 5
      src/app/app.component.ts
  2. 4
      src/app/home/home.component.scss
  3. 4
      src/app/home/home.component.ts
  4. 5
      src/app/http-interceptors/cache-token.service.ts
  5. 5
      src/app/pages/login/login.component.ts
  6. 4
      src/app/ui/uploading-cad/uploading-cad.component.html
  7. 11
      src/app/ui/uploading-cad/uploading-cad.component.scss

5
src/app/app.component.ts

@ -14,7 +14,6 @@ import { CookieService } from 'ngx-cookie-service';
})
export class AppComponent {
title = '数据采集管理平台';
time: number = 2*60*60*1000;// cookie过期时间两个小时 2*60*60*1000
constructor(private http:HttpClient,private router:Router,public token:CacheTokenService,private cookieService: CookieService) { }
@ -30,8 +29,8 @@ export class AppComponent {
}
).subscribe(
(data: Data) => {
this.cookieService.set("token",data.token,new Date(new Date().getTime() + this.time),'/');
this.cookieService.set("refreshToken",data.refreshToken,new Date(new Date().getTime() + this.time),'/');
this.cookieService.set("token",data.token,null,'/');
this.cookieService.set("refreshToken",data.refreshToken,null,'/');
this.token.startUp()
console.log('已重启定时器')
}

4
src/app/home/home.component.scss

@ -1,4 +0,0 @@
// .mat-drawer-inner-container{
// overflow-x: hidden;
// }

4
src/app/home/home.component.ts

@ -5,14 +5,14 @@ import { Component, OnInit } from '@angular/core';
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
}

5
src/app/http-interceptors/cache-token.service.ts

@ -12,7 +12,6 @@ export class CacheTokenService {
public timer;
public settime = null;
time: number = 2*60*60*1000;// cookie过期时间两个小时 2*60*60*1000
//刷新token令牌定时器
startUp = ():void=>{
@ -31,8 +30,8 @@ export class CacheTokenService {
).subscribe(
(data:any) => {
console.log(data)
this.cookieService.set("token",data.token,new Date(new Date().getTime() + this.time),'/');
this.cookieService.set("refreshToken",data.refreshToken,new Date(new Date().getTime() + this.time),'/');
this.cookieService.set("token",data.token,null,'/');
this.cookieService.set("refreshToken",data.refreshToken,null,'/');
}
)
}

5
src/app/pages/login/login.component.ts

@ -22,7 +22,6 @@ export class LoginComponent implements OnInit {
ngOnInit() {}
errmsg :string = ''; //错误信息
time: number = 2*60*60*1000;// cookie过期时间两个小时 2*60*60*1000
//提交登录表单
onSubmit(e){
@ -31,8 +30,8 @@ export class LoginComponent implements OnInit {
password: e.password}).subscribe(
(data: Data) =>
{
this.cookieService.set("token",data.token,new Date(new Date().getTime() + this.time),'/');
this.cookieService.set("refreshToken",data.refreshToken,new Date(new Date().getTime() + this.time),'/');
this.cookieService.set("token",data.token,null,'/');
this.cookieService.set("refreshToken",data.refreshToken,null,'/');
this.router.navigate(['/datacollection/basicinfo'])
//调用服务中的function刷新token

4
src/app/ui/uploading-cad/uploading-cad.component.html

@ -9,12 +9,12 @@
<div class="progressBox" *ngIf="uploadisLoading">
<button mat-raised-button style="margin-right: 5px;" (click)="cancel()">取消上传</button>
<span style="font-size: 12px;">上传中...</span>
<mat-progress-bar mode="determinate" [value]="progress" class="uploadProgress"></mat-progress-bar>
<mat-progress-bar mode="determinate" [value]="progress" class="progress"></mat-progress-bar>
</div>
<div class="progressBox" *ngIf="downloadisLoading">
<button mat-raised-button style="margin-right: 5px;">取消下载</button>
<span style="font-size: 12px;">下载中...</span>
<mat-progress-bar mode="determinate" [value]="downloadProgress" class="downloadProgress"></mat-progress-bar>
<mat-progress-bar mode="determinate" [value]="downloadProgress" class="progress"></mat-progress-bar>
</div>
</div>
<div>

11
src/app/ui/uploading-cad/uploading-cad.component.scss

@ -25,15 +25,8 @@
display: inline-block;
width: 500px;
}
//上传进度条
.uploadProgress{
position: absolute;
width: 300px;
top: 18px;
left: 160px;
}
//下载进度条
.downloadProgress {
//进度条
.progress{
position: absolute;
width: 300px;
top: 18px;

Loading…
Cancel
Save