From 7519a00ada89966f9caf93d315830dd628253d73 Mon Sep 17 00:00:00 2001 From: Netfan Date: Sun, 23 May 2021 09:02:47 +0800 Subject: [PATCH] fix(avatar): show current user's avatar (#640) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在显示头像的地方正确显示当前登录用户的头像,已补充mock接口返回的avatar字段。 --- mock/sys/user.ts | 2 ++ src/api/sys/model/userModel.ts | 2 ++ .../header/components/lock/LockModal.vue | 9 ++++-- .../header/components/user-dropdown/index.vue | 7 ++--- .../workbench/components/WorkbenchHeader.vue | 11 ++++--- src/views/demo/page/account/center/index.vue | 9 ++++-- .../demo/page/account/setting/BaseSetting.vue | 13 +++++++-- src/views/sys/lock/LockPage.vue | 29 ++++++++++++++----- types/store.ts | 1 + 9 files changed, 60 insertions(+), 23 deletions(-) diff --git a/mock/sys/user.ts b/mock/sys/user.ts index a3346c66b5e..6c1a9849567 100644 --- a/mock/sys/user.ts +++ b/mock/sys/user.ts @@ -7,6 +7,7 @@ function createFakeUserList() { userId: '1', username: 'vben', realName: 'Vben Admin', + avatar: 'http://q1.qlogo.cn/g?b=qq&nk=190848757&s=640', desc: 'manager', password: '123456', token: 'fakeToken1', @@ -22,6 +23,7 @@ function createFakeUserList() { username: 'test', password: '123456', realName: 'test user', + avatar: 'http://q1.qlogo.cn/g?b=qq&nk=339449197&s=640', desc: 'tester', token: 'fakeToken2', roles: [ diff --git a/src/api/sys/model/userModel.ts b/src/api/sys/model/userModel.ts index 170430c5ce8..a7a74442c59 100644 --- a/src/api/sys/model/userModel.ts +++ b/src/api/sys/model/userModel.ts @@ -38,6 +38,8 @@ export interface GetUserInfoByUserIdModel { username: string; // 真实名字 realName: string; + // 头像 + avatar: string; // 介绍 desc?: string; } diff --git a/src/layouts/default/header/components/lock/LockModal.vue b/src/layouts/default/header/components/lock/LockModal.vue index 698b7629f81..fb13f08570d 100644 --- a/src/layouts/default/header/components/lock/LockModal.vue +++ b/src/layouts/default/header/components/lock/LockModal.vue @@ -8,7 +8,7 @@ >
- +

{{ getRealName }}

@@ -71,6 +71,11 @@ await resetFields(); } + const avatar = computed(() => { + const { avatar } = userStore.getUserInfo; + return avatar || headerImg; + }); + return { t, prefixCls, @@ -78,7 +83,7 @@ register, registerForm, handleLock, - headerImg, + avatar, }; }, }); diff --git a/src/layouts/default/header/components/user-dropdown/index.vue b/src/layouts/default/header/components/user-dropdown/index.vue index e51d931c220..2c3669a4334 100644 --- a/src/layouts/default/header/components/user-dropdown/index.vue +++ b/src/layouts/default/header/components/user-dropdown/index.vue @@ -1,7 +1,7 @@