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 @@