From f2791ee1500e9b2088bdd142e1c94a5ff1e781e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=B5=B7?= Date: Sun, 15 Dec 2019 22:20:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/app/app-routing.module.ts | 1 + admin/src/app/services/user/user.service.ts | 9 +-------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/admin/src/app/app-routing.module.ts b/admin/src/app/app-routing.module.ts index 9746381..32a5ddb 100644 --- a/admin/src/app/app-routing.module.ts +++ b/admin/src/app/app-routing.module.ts @@ -42,6 +42,7 @@ export class AppRoutingModule { if (!this.userService.userInfo) { this.userService.getUserInfo().subscribe(data => { if (data.code === 0) { + this.userService.userInfo = data.result; this.checkPermission(event); } else if (data.code === 301) { window.location.href = '/login'; diff --git a/admin/src/app/services/user/user.service.ts b/admin/src/app/services/user/user.service.ts index 106855c..2a5a9d1 100644 --- a/admin/src/app/services/user/user.service.ts +++ b/admin/src/app/services/user/user.service.ts @@ -14,7 +14,6 @@ export class UserService { avatarHost: string = 'http://cdn.celess.cn'; constructor(public http: HttpService) { - this.getUserInfo(); } userPage: Page[] = []; @@ -24,13 +23,7 @@ export class UserService { * 获取用户信息 */ getUserInfo() { - const observable = this.http.get('/user/userInfo'); - observable.subscribe((data: any) => { - if (data.code === 0) { - this.userInfo = data.result; - } - }); - return observable; + return this.http.get('/user/userInfo'); } /**