完善路由守卫功能

This commit is contained in:
小海
2020-05-15 20:46:02 +08:00
parent e54726b4e8
commit b266340ef1
4 changed files with 23 additions and 10 deletions

View File

@@ -33,7 +33,8 @@ export class GlobalUserService {
}
if (this.lastRequestTime && Date.now() - this.lastRequestTime < 1000) {
return {
unsubscribe() {
unsubscribe: () => {
this.userObserverArray.splice(this.userObserverArray.indexOf(observer), 1);
observer.complete();
}
}
@@ -44,7 +45,8 @@ export class GlobalUserService {
// 获取数据
const subscription = this.getUserInfoFromServer();
return {
unsubscribe() {
unsubscribe:()=>{
this.userObserverArray.splice(this.userObserverArray.indexOf(observer), 1);
observer.complete();
subscription.unsubscribe()
}

View File

@@ -9,8 +9,8 @@ export class LocalStorageService {
constructor() {
}
// 1分钟
readonly place = 60 * 1000;
// 30s
readonly place = 30 * 1000;
getToken(): string {
return localStorage.getItem('token');