|
|
@ -11,7 +11,7 @@ |
|
|
|
<div class="change-avatar"> |
|
|
|
<div class="change-avatar"> |
|
|
|
<CropperAvatar |
|
|
|
<CropperAvatar |
|
|
|
:uploadApi="commonUpload" |
|
|
|
:uploadApi="commonUpload" |
|
|
|
:value="getUserInfo.avatar" |
|
|
|
:value="userInfoStore.avatar" |
|
|
|
btnText="更换头像" |
|
|
|
btnText="更换头像" |
|
|
|
:btnProps="{ preIcon: 'ant-design:cloud-upload-outlined' }" |
|
|
|
:btnProps="{ preIcon: 'ant-design:cloud-upload-outlined' }" |
|
|
|
:width="150" |
|
|
|
:width="150" |
|
|
@ -34,8 +34,7 @@ |
|
|
|
import { commonUpload } from '/@/api/platform/core/controller/upload'; |
|
|
|
import { commonUpload } from '/@/api/platform/core/controller/upload'; |
|
|
|
import { useContentHeight } from '/@/hooks/web/useContentHeight'; |
|
|
|
import { useContentHeight } from '/@/hooks/web/useContentHeight'; |
|
|
|
import { User } from '/@/api/platform/core/entity/user'; |
|
|
|
import { User } from '/@/api/platform/core/entity/user'; |
|
|
|
import {isBase64image, isEmpty, isUrl} from '/@/utils/is'; |
|
|
|
import { isBase64image, isUrl } from '/@/utils/is'; |
|
|
|
import { assignWith } from 'lodash-es'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface State { |
|
|
|
interface State { |
|
|
|
baseInfoBtnLoading: boolean; |
|
|
|
baseInfoBtnLoading: boolean; |
|
|
@ -93,26 +92,16 @@ |
|
|
|
const formData = await validate(); |
|
|
|
const formData = await validate(); |
|
|
|
// 设置图片路径 |
|
|
|
// 设置图片路径 |
|
|
|
!isBase64image(state.userInfo.avatar) && |
|
|
|
!isBase64image(state.userInfo.avatar) && |
|
|
|
(formData.avatar = isUrl(state.userInfo.avatar) |
|
|
|
(formData.avatar = state.userInfo.avatar); |
|
|
|
? state.userInfo.avatar |
|
|
|
|
|
|
|
: state.userInfo.avatar.replace(/\/[^\/]+/, '')); |
|
|
|
|
|
|
|
state.baseInfoBtnLoading = true; |
|
|
|
state.baseInfoBtnLoading = true; |
|
|
|
await editUser(formData); |
|
|
|
await editUser(formData); |
|
|
|
createMessage.success('保存成功!'); |
|
|
|
createMessage.success('保存成功!'); |
|
|
|
const result = await getUser(userInfoStore.id); |
|
|
|
await userStore.getUserInfoAction(); |
|
|
|
state.userInfo = result.result; |
|
|
|
|
|
|
|
// 更新用户状态管理与用户信息数据 |
|
|
|
|
|
|
|
const userinfo = userStore.getUserInfo; |
|
|
|
|
|
|
|
assignWith(userinfo, state.userInfo, (objValue, srcValue)=> !isEmpty(srcValue) ? srcValue : objValue); |
|
|
|
|
|
|
|
userStore.setUserInfo(userinfo); |
|
|
|
|
|
|
|
await setFieldsValue(result.result); |
|
|
|
|
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
state.baseInfoBtnLoading = false; |
|
|
|
state.baseInfoBtnLoading = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const getUserInfo = computed((): User => state.userInfo || {}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function handleAvatarChange({ src, data }) { |
|
|
|
function handleAvatarChange({ src, data }) { |
|
|
|
state.userInfo.avatar = data.url; |
|
|
|
state.userInfo.avatar = data.url; |
|
|
|
} |
|
|
|
} |
|
|
@ -120,7 +109,7 @@ |
|
|
|
return { |
|
|
|
return { |
|
|
|
register, |
|
|
|
register, |
|
|
|
wrapperRef, |
|
|
|
wrapperRef, |
|
|
|
getUserInfo, |
|
|
|
userInfoStore, |
|
|
|
commonUpload, |
|
|
|
commonUpload, |
|
|
|
handleAvatarChange, |
|
|
|
handleAvatarChange, |
|
|
|
getContentStyle, |
|
|
|
getContentStyle, |
|
|
|