From df3977a07fcfa08fe817446c0f835fcaf0f91a8b Mon Sep 17 00:00:00 2001 From: wangxiang <1827945911@qq.com> Date: Mon, 20 Feb 2023 10:51:23 +0800 Subject: [PATCH] =?UTF-8?q?:rocket:=20=E8=AE=BE=E7=BD=AE=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E5=A4=B4=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/user.ts | 5 ++- src/views/system/user/user.data.ts | 7 ++++ src/views/system/user/userInfo/index.vue | 47 ++++++++++++++++++------ 3 files changed, 46 insertions(+), 13 deletions(-) diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index d486767..a38a809 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -18,6 +18,9 @@ import { router } from '/@/router'; import { usePermissionStore } from '/@/store/modules/permission'; import { RouteRecordRaw } from 'vue-router'; import defaultAvatar from '/@/assets/images/defaultAvatar.svg'; +import { isUrl } from '/@/utils/is'; +import { useGlobSetting } from '/@/hooks/setting'; +const { apiUrl } = useGlobSetting(); interface UserState { userInfo: Nullable; @@ -134,7 +137,7 @@ export const useUserStore = defineStore({ /** 获取用户信息 */ async getUserInfoAction(): Promise { const userInfo = await getUserInfo().catch(()=> this.resetState()); - userInfo.avatar || (userInfo.avatar = defaultAvatar); + userInfo.avatar ? (userInfo.avatar = isUrl(userInfo.avatar) ? userInfo.avatar : apiUrl + userInfo.avatar) : (userInfo.avatar = defaultAvatar); userInfo.tenantIds = String(userInfo.tenantId).split(','); // 存储用户扩展信息,便于鉴权 this.setUserInfo(userInfo); diff --git a/src/views/system/user/user.data.ts b/src/views/system/user/user.data.ts index e9f90c7..7f397d2 100644 --- a/src/views/system/user/user.data.ts +++ b/src/views/system/user/user.data.ts @@ -122,6 +122,13 @@ export const userFormSchema: FormSchema[] = [ span: 12 } }, + { + field: 'avatar', + label: '头像', + component: 'Input', + defaultValue: 'https://godolphinx.org/dolphin1024x1024.png', + show: false + }, { field: 'deptId', label: '归属机构', diff --git a/src/views/system/user/userInfo/index.vue b/src/views/system/user/userInfo/index.vue index abde766..69b2024 100644 --- a/src/views/system/user/userInfo/index.vue +++ b/src/views/system/user/userInfo/index.vue @@ -12,7 +12,7 @@