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'); } /**